Enable agents to place capital-backed bids on artifacts — going long (artifact is valuable)
or short (artifact is overvalued). Bids lock tokens from the agent's balance and create
positions that resolve when the artifact's lifecycle state changes.
validated state or price increasesdeprecated state or price decreasesdeprecated/flagged statevalidated stateCREATE TABLE market_positions (
id TEXT PRIMARY KEY,
agent_id TEXT NOT NULL,
artifact_id TEXT NOT NULL,
position_type TEXT NOT NULL CHECK(position_type IN ('long', 'short', 'bounty')),
tokens_committed REAL NOT NULL CHECK(tokens_committed > 0),
entry_price REAL NOT NULL, -- artifact market_price at time of bid
target_price REAL, -- for limit orders
status TEXT DEFAULT 'open' CHECK(status IN ('open', 'settled_profit', 'settled_loss', 'cancelled')),
settlement_price REAL, -- price at settlement
settlement_pnl REAL, -- profit/loss in tokens
settled_at TEXT,
created_at TEXT DEFAULT (datetime('now')),
FOREIGN KEY (agent_id) REFERENCES token_accounts(account_id),
FOREIGN KEY (artifact_id) REFERENCES artifacts(id)
);
CREATE TABLE bounties (
id TEXT PRIMARY KEY,
agent_id TEXT NOT NULL,
target_type TEXT NOT NULL, -- 'knowledge_gap', 'artifact', 'experiment'
target_id TEXT NOT NULL,
tokens_posted REAL NOT NULL,
tokens_remaining REAL NOT NULL,
description TEXT, -- what needs to happen for payout
status TEXT DEFAULT 'open' CHECK(status IN ('open', 'claimed', 'expired', 'cancelled')),
expires_at TEXT,
created_at TEXT DEFAULT (datetime('now'))
);
CREATE INDEX idx_positions_agent ON market_positions(agent_id);
CREATE INDEX idx_positions_artifact ON market_positions(artifact_id);
CREATE INDEX idx_positions_status ON market_positions(status);
CREATE INDEX idx_bounties_target ON bounties(target_type, target_id);market_bidding.py module with:place_bid(agent_id, artifact_id, position_type, tokens) — create positioncancel_position(position_id) — return unlocked tokens (minus 5% cancellation fee)post_bounty(agent_id, target_type, target_id, tokens, description, expires_at)claim_bounty(bounty_id, claimant_id, evidence) — distribute bounty tokensget_positions(agent_id) — all open positions for an agentget_artifact_demand(artifact_id) — total capital committed to this artifact
POST /api/market/bid — place a bidPOST /api/market/bounty — post a bountyGET /api/market/positions/{agent_id} — agent's portfolioGET /api/market/demand/{artifact_id} — demand signalsBids move artifact market_price via LMSR:
cost = b * ln(exp(q_yes + shares) / exp(q_yes) + exp(q_no) / exp(q_no))
# Where b is liquidity parameter, q is current market stateLarge bids move the price more. This means capital-rich agents have more influence,
but only if they're accurate — bad bets lose capital.
exch-cm-01-LEDG — Token ledger for balance managementexch-cm-02-EARN — Agents need tokens to bidexch-qm-01-MEXT — Artifacts need market prices to bid onexch-cm-04-BOOK — Order book extends bidding with limit ordersexch-cm-05-PORT — Portfolio tracks bid positionsexch-cm-06-SETL — Settlement resolves bid positionsWhat was done:
scidex/exchange/market_bidding.py with all six required functions:place_bid(agent_id, artifact_id, position_type, tokens) — creates long/short/bountymarket_positions, locks tokens via token_ledger.transfer, applies LMSRmarket_dynamics.compute_price_adjustment_marketcancel_position(position_id) — returns locked tokens minus 5% cancellation fee;post_bounty(agent_id, target_type, target_id, tokens, description, expires_at) —bounties table, locks tokensclaim_bounty(bounty_id, claimant_id, evidence) — records claim in events table,get_positions(agent_id) — returns all positions with artifact infoget_artifact_demand(artifact_id) — returns long/short/bounty breakdown and net demand
api.py:POST /api/market/bid — place a capital-backed bidPOST /api/market/bounty — post a bountyGET /api/market/positions/{agent_id} — agent's positionsGET /api/market/demand/{artifact_id} — demand signalsPOST /api/market/positions/{position_id}/cancel — cancel a positionPOST /api/market/bounties/{bounty_id}/claim — claim a bounty
place_bid locks tokens and creates position record correctlycancel_position returns tokens minus 5% feepost_bounty creates bounty and locks tokensclaim_bounty records claim and updates bounty statusget_positions returns positions with artifact infoget_artifact_demand returns correct long/short/bounty breakdown
market_positions and bounties tables (already existed on PostgreSQL)compute_price_adjustment_marketcf382381d