Documentation Index
Fetch the complete documentation index at: https://mintlify.com/deniszidbaev-cmyk/polyclaw-cmyk/llms.txt
Use this file to discover all available pages before exploring further.
polyclaw buy executes trades on Polymarket using the Conditional Token Framework (CTF) split mechanism followed by a CLOB (Central Limit Order Book) sell. Instead of purchasing tokens directly, it deposits pUSD into the CTF contract to mint an equal quantity of YES and NO tokens, then sells the side you don’t want via a Fill-or-Kill order on the Polymarket order book. The result is a directional position at the market price, with partial cost recovery from selling the unwanted side.
polyclaw buy <market_id> YES|NO <amount>
Full usage
Market ID from
polyclaw markets trending, polyclaw markets search, or the Polymarket URL slug.Which outcome to purchase. Case-insensitive (
yes and no are also accepted).Amount in USD to spend. This exact number of pUSD tokens is deposited into the CTF contract: $50 becomes 50 YES + 50 NO tokens. Your wallet must hold at least this much pUSD.
Skip the CLOB sell step entirely. Both YES and NO tokens will remain in your wallet after the split. Useful if you want to hold both sides, run your own sell logic, or if CLOB liquidity is thin.
After the human-readable summary, output the full trade result as a JSON object.
How it works
Fetch market info
PolyClaw calls the Gamma API to retrieve the
condition_id, YES/NO token IDs, and current prices for the requested market.Check pUSD balance
The wallet’s pUSD balance is verified. If it’s less than
amount, the trade is aborted with an error message showing your current balance and a hint to wrap USDC.e if needed.Split position on-chain
A
splitPosition call is sent to the CTF contract (0x4D97DCd97eC945f40cF65F87097ACe5EA0476045), depositing amount pUSD and minting an equal number of YES and NO tokens (1 token per $1).Sell unwanted side via CLOB
Unless
--skip-sell is set, a Fill-or-Kill (FOK) sell order is placed on the Polymarket CLOB at approximately 10% below the current market price for the unwanted side. If filled, the proceeds partially offset your cost basis.Example
Trade result JSON fields
When using--json, the following object is printed after the human-readable summary:
| Field | Type | Description |
|---|---|---|
success | bool | true if the split succeeded (even if CLOB sell failed) |
market_id | string | The market ID that was traded |
position | string | "YES" or "NO" |
amount | float | USD amount deposited |
split_tx | string | On-chain transaction hash of the splitPosition call |
clob_order_id | string | null | Polymarket CLOB order identifier (see note below) |
clob_filled | bool | Whether the FOK sell order was matched |
error | string | null | CLOB error message if sell failed, or null |
question | string | Full market question text |
wanted_token_id | string | ERC-1155 token ID for the side you purchased |
entry_price | float | Market price at time of trade |
condition_id | string | CTF condition ID |
CLOB order IDs are not blockchain transaction hashes. An ID like
0xc93d6214515b2436... is an off-chain Polymarket order book identifier. CLOB orders are matched off-chain and settled in batches on-chain. There is no public block explorer for CLOB order IDs. To see your trade history, connect your wallet at polymarket.com → Portfolio → Activity.