platforms.polymarket

Trade prediction markets on Polymarket directly from your agent. Execute market orders and redeem settled positions using your session wallet. All operations handle approvals, signing, and submission automatically.

Note: Position data is available via agent.currentPositions.

circle-info

Note: Right now, Polymarket's API accepts different decimal precision for buys and sells, this will result in dust positions if you are selling out of a position before expiry. Once expired, dust can be cleaned up during the redeem step.

platforms.polymarket.marketOrder()

Place a buy or sell market order on Polymarket for a specific outcome token.

Signature

agent.platforms.polymarket.marketOrder(
  request: {
    tokenId: string;
    size: number;
    side: string;
  }
): Promise<PolymarketMarketOrderResponse>

Parameters

Param
Type
Description

request

object

Market order configuration

request.tokenId

string

Market token ID for the position

request.size

number

BUY: USD amount to spend (e.g., 10 = $10) SELL: Number of shares to sell (e.g., 10 = 10 shares)

request.side

string

Order side; "BUY" | "SELL"

circle-exclamation

Returns

  • Promise<PolymarketMarketOrderResponse>

Examples

Buy Order

Sell Order

Common Errors

Error
Cause
Solution

"Could not get order"

Invalid tokenId or market doesn't exist

Verify tokenId from Polymarket API

"Insufficient balance"

Not enough USDC for BUY order

Check currentPositions for USDC balance

"Insufficient shares"

Not enough shares for SELL order

Check currentPositions for position

"Order too small"

Size below minimum

Use at least $1-2 for orders

"Market closed"

Market already resolved/ended

Check market status before trading

platforms.polymarket.redeemPositions()

Redeem settled positions on Polymarket and claim winnings. Can redeem all redeemable positions or specific ones by token ID.

Signature

Parameters

Param
Type
Description

request?

object

Optional redemption configuration

request.tokenId?

string[]

Specific token IDs to redeem. Omit or pass empty array to redeem all redeemable positions

Returns

  • Promise<PolymarketRedeemPositionsResponse>

Examples

Redeem All Positions

Redeem Specific Positions

Common Errors

Error
Cause
Solution

"No redeemable positions"

No winning positions to redeem

Check isRedeemable on positions first

"Invalid tokenId"

tokenId doesn't exist

Verify tokenId from currentPositions

Last updated