Skip to main content
Create and deploy the Deposit Wallet explicitly before starting a pUSD agent; select that account for its allocation. Agents cannot deploy wallets or change their account identity. The selected account is either a Deposit Wallet derived from an EVM controller or an EOA with prior Polymarket trading history; the SDK is identical for both. Deploy a Deposit Wallet through explicit account setup before trading. Required approvals and USDC.e wrapping run as separate operations, each with its own 30-second deadline. A Deposit Wallet swap moves pUSD or USDC.e to the controller before the ordinary swap path. Never invent token ids. Search, verify the event, then retrieve its complete catalog:
events.list(rail) returns a curated rail. events.search returns event references (slug, title, startDate) and never markets; events.retrieve is the only complete catalog, merging the event’s companion events and returning every active, unarchived, open market accepting orders. markets.retrieve resolves an outcome asset under the same eligibility rule; prices.list({ asset }) returns pUSD history. markets.screen ranks soon-resolving outcomes by executable buy price:
Each returned outcome is fillable for stakePusd: the book is walked to that size and pricePusd is the resulting average, with fillableShares the shares it buys and quotedPricePusd the top-of-book price before size, so their difference is the slippage at that stake. The band is applied once, to the achieved average, so a row quoted inside the band with no depth behind the quote is excluded and a returned row is executable rather than advertised. Rows also carry conditionId, volume24hPusd, sportsMarketType, line and gameStartTime for ranking without a second call. Outcomes arrive grouped under their event: each events[] entry carries the event slug (null for a market outside any event, which forms its own group) and its outcomes. negRisk and groupItemTitle identify an outcome’s sibling legs, and when negRisk is true exactly one of that event’s legs resolves YES, so a complete set costs less than its guaranteed payout only when the legs’ asks sum below 1. orderBy ranks the scan; each event is placed by its best-ranked outcome; sportsMarketTypes keeps only the sportsMarketType values an event’s index names. tagSlug keeps only markets carrying that tag, and excludeTagSlugs drops markets carrying any of those tags before their books are priced, so excludeTagSlugs: ["sports"] returns the window without games. Every fillable outcome is returned; scanned counts every market row the scan examined, readable or not, before any tag exclusion, and truncated is true when the scan hit its page limit before the window ended, in which case an exclusion only reaches the rows the scan reached.

Quote and create an order

A BUY caps total spending, including fees, at spendPusd; a SELL uses shares, rounded down to venue precision. Quotes include fees and executable share rounding. Both require at least 1 pUSD of venue value and should fit the session allocation. Results include the actual fill, price, collateral, and settlement hashes. Writes use a run-scoped idempotency key and submit exactly once. Completed trade and redemption links in Circuit activity and Terminal open Orbscan with the settlement hash. orders.quote returns price, signedSharesChange, and expectedPusdAmount. Read the market’s question and outcomes[].name through markets.retrieve(asset). Held positions expose conditionId through polymarketMetadata; redemption results also include it. Use position.size for session shares and nullable polymarketMetadata.entryPricePusd for session entry basis. Allocation metadata no longer contains duplicate contractAddress/decimals or wallet-wide shares, formattedShares, marketValuePusd, averagePricePusd, initialValuePusd, or P&L totals; existing agents using those fields must be updated.

Redeem positions

Trading prepares the selected exchange’s required approval and rechecks live balances before signing. Redemption readiness uses the on-chain resolution and balance. Each asset selects its entire resolved binary market: all YES and NO holdings are redeemed for pUSD, including losing shares. Deposit Wallets batch approval and redemption; eligible EOAs approve separately and pay Polygon gas. Multiple markets execute sequentially; sibling assets are deduplicated. The first error stops the call, preserving completed redemptions. The result contains redeemed entries for both outcomes (including zero holdings), with asset, conditionId, shares, formattedShares, question, and outcome, plus transactionHashes. Unresolved or empty markets fail.

Allocation guidance

Invocation-start pUSD and outcome-token positions come from agent.allocation. Size writes from it; redemption uses pooled account inventory, so allocation is guidance there. Failures throw ApiError with full engine evidence. See positions for the shape.