OstiumBuilder Service
API ReferenceWebSocket APITrade Actions

WS Action: Close

Close positions via WebSocket.

Alpha Version

The Ostium Builder Service is in Alpha. API endpoints, specifications, and builder URLs may change without notice. Use with caution in production environments.

Action: close

Close existing positions. The payload mirrors POST /v1/exchange/close.

Headers (in envelope)

HeaderRequiredDescription
X-Trader-AddressYesTrader wallet address.
X-API-KeyNoDelegated mode (delegate wallet must be verified).

Payload

FieldTypeRequiredDescription
closesCloseItem[]YesOne or more close actions.
spnumberNoSlippage percentage (0-100). Default 0.25.

CloseItem

FieldTypeRequiredDescription
anumberYesPair index.
tnumberYesTrade index.
pstringYesCurrent market price (numeric string > 0).
rnumberYesClose percentage (1-100). Decimals allowed.

Constraints

  • closes must contain at least one item.
  • Delegated mode supports one close per request.

Success Data (unsigned)

FieldTypeRequiredDescription
transactionsUnsignedTransaction[]YesOne or more unsigned transactions.

Delegated mode returns { "txHash", "smartAccountAddress" } as described in /docs/websocket/trade-actions.

Example

{
  "id": "2",
  "action": "close",
  "headers": { "X-Trader-Address": "0xYourWallet" },
  "payload": {
    "closes": [
      {"a":0,"t":0,"p":"43000","r":50}
    ],
    "sp": 0.25
  }
}

Success Response (unsigned)

{
  "id": "2",
  "ok": true,
  "data": {
    "transactions": [
      { "to": "0x...", "data": "0x...", "value": "0", "from": "0xYourWallet" }
    ]
  }
}

See /docs/http/exchange/close for HTTP details.

On this page