> ## Documentation Index
> Fetch the complete documentation index at: https://docs.circuit.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Polymarket perps trading agent SDK

> Circuit SDK reference for Polymarket perps agents: perp orders with take profit and stop loss, order types, margin, positions, deposits and withdrawals in pUSD.

Polymarket perps are perpetual futures margined in pUSD, separate from [Polymarket prediction markets](https://docs.circuit.org/agent-developers/sdk-reference/polymarket.md). A Polymarket perps account belongs to the wallet's Ethereum address. Its collateral is pUSD on network `polymarket-perps`, and a perp holding is `kind: "perp"` with the same fields as [Hyperliquid](https://docs.circuit.org/agent-developers/sdk-reference/hyperliquid.md) on that network. Venue ID `polymarketPerps` names it everywhere the SDK takes a venue.

`agent.polymarketPerps.orders.create` takes the [order shape every venue shares](https://docs.circuit.org/agent-developers/sdk-reference/hyperliquid.md), `perpOpen` and `perpReduce`; the venue has no spot markets. `asset` is a perp symbol from [`data.markets({ venue: "polymarketPerps" })`](./data), such as `BTC-USD`, with `amount` `{ size }` in base units or `{ value }` in pUSD notional. Omit `execution` for a market order, sent as an ioc limit within the slippage of the mid, or pass `{ kind: "limit", price, timeInForce }` with `"gtc"`, `"ioc"` or `"alo"` (post-only). Fill-or-kill, TWAP and trailing orders are not offered. `perpOpen` takes [`takeProfit` and `stopLoss`](./hyperliquid), each `{ triggerPrice, price? }`: Circuit sends the entry and its exits as one placement, and each exit is a reduce-only order for the entry's size, at market when `price` is omitted. The exits arm only once the entry fills in full: an entry that is canceled, refused or only partly filled cancels them, leaving any filled part unprotected. Each exit's trigger must sit beyond the entry's own limit price, which for a market order is the mid plus or minus its slippage, or the venue refuses the whole placement. A take profit or stop loss with no opening order, standalone or on a reduce-only order, is refused. A `perpOpen`'s `margin`, `{ mode: "cross" | "isolated", leverage? }`, sets the market's margin mode and leverage before the order, as its own operation, and agents have no other way to change leverage; a market whose `marginRule` is isolated only refuses cross, a leverage above the market's cap is refused, and a market holding a position keeps its margin mode until the position closes. Adding or removing isolated margin on a position is not offered.

Preparation rounds each size down and each price to the market's `sizeStep` and `priceTick` and to at most five significant figures, never past a whole number, so a value of 100000 or more keeps every whole digit. It refuses a non-reducing order below the market's `minimumNotional` with `BELOW_MINIMUM`, any order that increases a market the venue has set to close-only, and a limit price farther from the mark than the market's price band. Results follow the [Hyperliquid order results](https://docs.circuit.org/agent-developers/sdk-reference/hyperliquid.md), with `orderId` the client order ID Circuit assigns before sending, 32 lowercase hex digits. `agent.orders.listOpen({ venue: "polymarketPerps" })` returns the session's resting orders and `polymarketPerps.orders.cancel({ orderId })` cancels one; `"all"` cancels every resting order on the account, which only a Paper trading session (its account is its own) or an owner review may do.

Before the first order, one reviewed `setup` with `venue: "polymarketPerps"` authorizes Circuit to trade the account for a year; Circuit derives the trading key from the wallet's signature, never stores a private key, and asks again during the last 30 days. A [swap](https://docs.circuit.org/agent-developers/sdk-reference/swap.md) of pUSD on Polygon into pUSD on `polymarket-perps` deposits it, at least 10 pUSD. Withdrawals are reviewed in Ask Circuit, not by agents: the wallet signs a withdrawal of up to the account's withdrawable pUSD, sent to that same wallet on Polygon.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.