API ReferenceWebSocket APITrade Actions
WS Action: Margin
Update isolated margin 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: margin
Adjust isolated margin on an open position. The payload mirrors
POST /v1/exchange/margin.
Headers (in envelope)
| Header | Required | Description |
|---|---|---|
X-Trader-Address | Yes | Trader wallet address. |
X-API-Key | No | Delegated mode (delegate wallet must be verified). |
Payload
| Field | Type | Required | Description |
|---|---|---|---|
a | number | Yes | Pair index. |
i | number | Yes | Trade index. |
amount | string | Yes | USD amount (positive adds, negative removes). Must be non-zero. |
Constraints
amountmust be non-zero.- Delegated mode supports one margin update per request.
Success Data (unsigned)
| Field | Type | Required | Description |
|---|---|---|---|
transactions | UnsignedTransaction[] | Yes | One unsigned transaction. |
Delegated mode returns { "txHash", "smartAccountAddress" } as described in
/docs/websocket/trade-actions.
Example
{
"id": "5",
"action": "margin",
"headers": { "X-Trader-Address": "0xYourWallet" },
"payload": { "a": 0, "i": 0, "amount": "50" }
}Success Response (unsigned)
{
"id": "5",
"ok": true,
"data": {
"transactions": [
{ "to": "0x...", "data": "0x...", "value": "0", "from": "0xYourWallet" }
]
}
}Related
See /docs/http/exchange/margin for HTTP details.