BTB Finance for agents

Protocols / Prediction Market

Polymarket

Prediction market on Polygon. Agents discover markets with the Gamma API, trade outcome shares through the off-chain CLOB (EIP-712-signed orders settled on-chain by the CTF Exchange contracts), read positions from the Data API, and split/merge/redeem outcome tokens against pUSD collateral directly on-chain.

On-chain + APIEVM12 contractsWebsite · Docs

get_protocol({ "protocol": "polymarket" })

Risks an agent should know

What an agent can do

find marketsSearch events/markets and get token ids
GET https://gamma-api.polymarket.com/public-search?q=... or /markets/slug/{slug}; read conditionId, clobTokenIds (v1) or positionIds (v2), version; then GET https://clob.polymarket.com/book?token_id= for tick_size and neg_risk.
get pUSDFund the trading wallet with collateral
USDC.e.approve(CollateralOnramp, amt) then CollateralOnramp.wrap(USDC.e, to, amt); or use the Bridge API deposit addresses from other chains (auto-wraps to pUSD).
approve tradingOne-time approvals before trading
pUSD.approve(CTF Exchange / Neg Risk Exchange) for BUY; ConditionalTokens.setApprovalForAll(exchange, true) for SELL; for neg-risk markets also approve the Neg Risk Adapter 0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296 (pUSD and Conditional Tokens). For v2 books: pUSD.approve(ExchangeV3) and PositionManager.setApprovalForAll(ExchangeV3, true). Existing CTF approvals do not carry over to v2.
place orderBuy or sell outcome shares
Derive L2 API creds (L1 ClobAuth signature), build and EIP-712-sign an Order for the correct exchange domain, POST https://clob.polymarket.com/order with L2 headers and {order, owner: apiKey, orderType: GTC|GTD|FOK|FAK}.
cancel orderCancel one, several or all orders
DELETE https://clob.polymarket.com/order {orderID}, DELETE /orders, DELETE /cancel-market-orders, or DELETE /cancel-all, with L2 headers. On-chain emergency: exchange.pauseUser().
read positionsList a wallet's positions and value
GET https://data-api.polymarket.com/v2/positions?user=<address> and /v2/value?user=; on-chain ConditionalTokens.balanceOf(user, tokenId).
split / mergeMint or burn complete YES+NO sets
v1 standard: CtfCollateralAdapter.splitPosition/mergePositions(pUSD, 0x0, conditionId, [1,2], amount); v1 neg-risk: NegRiskCtfCollateralAdapter (same signatures); v2: Router.split/merge(bytes31 conditionId, amount).
redeemClaim pUSD for winning shares after resolution
v1: CtfCollateralAdapter or NegRiskCtfCollateralAdapter .redeemPositions(pUSD, 0x0, conditionId, [1,2]) after ConditionalTokens.setApprovalForAll(adapter, true); v2: Router.redeem(conditionId, outcomeIndex, amount) after PositionManager.setApprovalForAll(Router, true).
withdrawTurn pUSD back into USDC.e
pUSD.approve(CollateralOfframp, amt) then CollateralOfframp.unwrap(USDC.e, to, amt); or use the Bridge API withdraw flow to other chains.

Contracts

polygon · chain id 137

ContractAddressKey functionsTry
CTF Exchange (CTFExchangeV2, standard binary markets)
exchange
0xE111180000d2663C0091e4f400237545B87B996B
source
readgetOrderStatus(bytes32)
readhashOrder((uint256,address,address,uint256,uint256,uint256,uint8,uint8,uint256,bytes32,bytes32,bytes))
readvalidateOrder((uint256,address,address,uint256,uint256,uint256,uint8,uint8,uint256,bytes32,bytes32,bytes))
readisUserPaused(address)
writepauseUser()
writeunpauseUser()
readgetCollateral()
readgetCtf()
Full ABI
Neg Risk CTF Exchange (NegRiskCtfExchangeV2, multi-outcome markets)
exchange
0xe2222d279d744050d28e00520010520000310F59
source
readgetOrderStatus(bytes32)
readhashOrder((uint256,address,address,uint256,uint256,uint256,uint8,uint8,uint256,bytes32,bytes32,bytes))
writepauseUser()
readisUserPaused(address)
Full ABI
Neg Risk Adapter
other
0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296
source
readgetConditionId(bytes32)
readgetPositionId(bytes32,bool)
readbalanceOf(address,uint256)
writeconvertPositions(bytes32,uint256,uint256)
Full ABI
Conditional Tokens (CTF, ERC1155 outcome tokens for v1 markets)
token
0x4D97DCd97eC945f40cF65F87097ACe5EA0476045
source
readbalanceOf(address,uint256)
writesetApprovalForAll(address,bool)
readisApprovedForAll(address,address)
writesafeTransferFrom(address,address,uint256,uint256,bytes)
readpayoutDenominator(bytes32)
readpayoutNumerators(bytes32,uint256)
readgetOutcomeSlotCount(bytes32)
readgetCollectionId(bytes32,bytes32,uint256)
+1 more via get_protocol
Full ABI
pUSD (Polymarket USD, CollateralToken) - trading collateral
token · proxy
0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB
source
writeapprove(address,uint256)
readbalanceOf(address)
readallowance(address,address)
writetransfer(address,uint256)
Full ABI
CollateralOnramp (USDC.e -> pUSD)
other
0x93070a847efEf7F70739046A929D47a521F5B8ee
source
writewrap(address,address,uint256)
Full ABI
CollateralOfframp (pUSD -> USDC.e)
other
0x2957922Eb93258b93368531d39fAcCA3B4dC5854
source
writeunwrap(address,address,uint256)
Full ABI
USDC.e (bridged USDC, Polygon) - asset wrapped into pUSD
token
0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
source
writeapprove(address,uint256)
readbalanceOf(address)
Full ABI
Router (Polymarket Protocol V2)
router · proxy
0x12121212006e4CD160D18e3f00711DA5c3372600
source
writesplit(bytes31,uint256)
writemerge(bytes31,uint256)
writeredeem(bytes31,uint256,uint256)
Full ABI
PositionManager (Polymarket Protocol V2 position ledger)
token · proxy
0x006F54F7f9A22e0000CC2AB60031000000ae9fEF
source
writesetApprovalForAll(address,bool)
readgetPayout(uint256,uint256)
Full ABI
ExchangeV3 (Polymarket Protocol V2 order book settlement)
exchange · proxy
0xe3333700cA9d93003F00f0F71f8515005F6c00Aa
source
Full ABI
AutoRedeemer (Polymarket Protocol V2)
other · proxy
0xa1200000d0002264C9a1698e001292D00E1b00af
source
Full ABI

APIs

CLOB API (order book and trading)
auth: signature
https://clob.polymarket.com
Public (no auth): GET /book?token_id= (tick_size, min_order_size, neg_risk, version), prices, midpoints. L1 auth (EIP-712 ClobAuth, domain {name 'ClobAuthDomain', version '1', chainId 137}, message {address, timestamp, nonce, message 'This message attests that I control the given wallet'}; headers POLY_ADDRESS, POLY_SIGNATURE, POLY_TIMESTAMP, POLY_NONCE): POST /auth/api-key to create or GET /auth/derive-api-key to derive {apiKey, secret, passphrase}. L2 auth (headers POLY_ADDRESS, POLY_API_KEY, POLY_PASSPHRASE, POLY_TIMESTAMP, POLY_SIGNATURE = urlsafe-base64 HMAC-SHA256 keyed by base64-decoded secret over timestamp+METHOD+path+body): POST /order (one signed order), POST /orders (1-15), DELETE /order {orderID}, DELETE /orders [ids], DELETE /cancel-market-orders {asset_id|market}, DELETE /cancel-all, GET /data/orders, GET /data/order/{id}, GET /data/trades, POST /v1/heartbeats (dead-man switch). Orders are EIP-712 'Order' structs signed with domain {name 'Polymarket CTF Exchange', chainId 137, version '2' + verifyingContract CTF Exchange (neg_risk false) or Neg Risk CTF Exchange (neg_risk true); version '3' + ExchangeV3 for v2 books}. Order types GTC, GTD (expiration >= 3 min ahead), FOK, FAK; optional postOnly. BUY: makerAmount = pUSD, takerAmount = shares (6-decimal ints); SELL reversed. Use the official SDK where possible.
Gamma API (markets and events metadata)
auth: none
https://gamma-api.polymarket.com
Discover markets: GET /events/keyset, /events/{id}, /events/slug/{slug}, /markets/keyset, /markets/{id}, /markets/slug/{slug}, /public-search?q=, /tags, /series, /sports. Params: closed, limit, after_cursor, tag_id, version (v1 CTF | v2). Market fields: conditionId, clobTokenIds (v1 YES/NO token ids, JSON string), positionIds (v2), version.
Data API (positions, activity, value)
auth: none
https://data-api.polymarket.com
Read a wallet's positions (GET /v2/positions?user=, status OPEN default), portfolio value (/v2/value?user=), activity (/v2/activity?user=), trades, approvals state (/v2/approvals?user=), price history, holders, open interest.
Bridge API (deposits/withdrawals from other chains)
auth: none
https://bridge.polymarket.com
POST /deposit returns per-chain deposit addresses (evm, svm, btc, tron) for a Polymarket wallet; funds are bridged and swapped into pUSD on Polygon. GET /supported-assets lists tokens and minimums; GET /status/{address} tracks progress. Withdraw and quote endpoints are documented in the bridge section.
Geoblock check
auth: none
https://polymarket.com/api/geoblock
GET returns {blocked, ip, country, region}; check before placing orders on behalf of a user.
CLOB WebSocket
auth: none
wss://ws-subscriptions-clob.polymarket.com/ws/market
Public order book, price and market lifecycle updates (incl. tick_size_change). Authenticated per-account order/trade updates at wss://ws-subscriptions-clob.polymarket.com/ws/user.
Relayer API
auth: signature
https://relayer-v2.polymarket.com
Submit Polymarket wallet (proxy/safe/deposit wallet) transactions without holding POL for gas.

Notes

All addresses are Polygon mainnet (137) from https://docs.polymarket.com/resources/contracts. The Polymarket/ctf-exchange-v2 GitHub README lists different addresses for CtfCollateralAdapter (0xADa100874d00e3331D00F2007a9c336a65009718) and NegRiskCtfCollateralAdapter (0xAdA200001000ef00D07553cEE7006808F895c6F1) than the docs; this file uses the docs' addresses, which the docs' positions guide also uses. Other official contracts not detailed here: PermissionedRamp 0xebC2459Ec962869ca4c0bd1E06368272732BCb08, Deposit Wallet Factory 0x00000000000Fb5C9ADea0298D729A0CB3823Cc07, Polymarket Proxy Factory 0xaB45c5A4B0c941a2F231C04C3f49182e1A254052, BinaryModule/NegRiskModule/CombinatorialModule (V2), UmaCtfAdapter v3.1.0 0x157Ce2d672854c848c9b79C49a8Cc6cc89176a49, V2 oracle modules - see the contracts page. The older v1 exchanges (e.g. Neg Risk CTF Exchange 0xC5d563A36AE78145C45a50134d48A1215220f80a in the neg-risk-ctf-adapter repo) are no longer listed in the docs. Exchange V2 removed fillOrder/fillOrders and nonce-based on-chain cancel; only the operator calls matchOrders. ExchangeV3 and AutoRedeemer ABIs were not confirmed, so no key functions are listed for them. Withheld until Polymarket resolves a mismatch: the collateral adapters (CtfCollateralAdapter, NegRiskCtfCollateralAdapter) have different addresses in the docs (0xAdA100Db00Ca00073811820692005400218FcE1f, 0xadA2005600Dec949baf300f4C6120000bDB6eAab) and in the ctf-exchange-v2 GitHub README. Check https://docs.polymarket.com before using them.

Sources

Researched 2026-11-24. Addresses are copied from the official sources above; check them before moving large amounts.