Polymarket Close Position
Close (sell) a Polymarket position by selling shares. Sells all shares by default, or a specified number. Uses market pricing for immediate fills. Ideal for: exiting positions, taking profits, stop-loss automation, portfolio rebalancing.
Catalog action EVM Onchain wallet Gas swap
Close (sell) a Polymarket position by selling shares. Sells all shares by default, or a specified number. Uses market pricing for immediate fills. Ideal for: exiting positions, taking profits, stop-loss automation, portfolio rebalancing.
This action can require a wallet connector, gas, token movement, or an external side effect. Test with simulation or a controlled amount before using it in a live workflow.
At a Glance
| Field | Value |
|---|---|
| Action ID | polymarket-close-position |
| Category | EVM Onchain |
| Connector | wallet |
| Requires gas | Yes |
| Funds movement | swap |
| Tags | polymarket, trading, sell, position, write |
Payload Schema
| Field | Type | Required | Description |
|---|---|---|---|
tokenId | string | Yes | The token ID (condition ID / asset ID) of the position to close. This identifies which outcome shares to sell. |
shares | number | No | Number of shares to sell. If omitted, sells the entire position. |
orderType | string | No | Order type for the sell order. FAK (Fill And Kill) allows partial fills (default). FOK (Fill Or Kill) requires the entire order to fill or nothing. |
Result Schema
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | Status of the close position operation. |
tokenId | string | No | The token ID that was sold. |
sharesSold | number | No | Number of shares that were sold. |
pricePerShare | number | No | Price per share received. |
totalProceeds | number | No | Total USDC proceeds from the sale (sharesSold * pricePerShare). |
orderId | string | No | The unique identifier for the sell order. |
transactionHash | string | No | On-chain transaction hash if the order settled immediately. |
message | string | No | Additional context about the result. |
Examples
json{ "type": "polymarket-close-position", "payload": { "tokenId": "1" }, "children": [], "connector": { "type": "wallet", "id": "conn_wallet" }}
bashcurl -X POST "https://api.b3os.org/v1/actions/polymarket-close-position/test" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inputs": { "tokenId": "1" }}'
Payload fields can use workflow expressions such as {{$trigger.body.amount}}, {{$nodes.fetch.result.price}}, and {{$props.asset}} when the value should come from a trigger, prior node, or reusable workflow prop.
