API ReferenceHTTP APIExchange Operations
Exchange: Margin
Add or remove isolated margin.
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.
POST /v1/exchange/margin
Builds an unsigned transaction to adjust isolated margin on an open position.
Headers
| Header | Required | Description |
|---|---|---|
X-Trader-Address | Yes | Trader wallet address. |
X-API-Key | No | Delegated mode (delegate wallet must be verified). |
Content-Type | Yes | application/json or text/plain (JSON string). |
Request Body
| 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.
Response Body (unsigned)
| Field | Type | Required | Description |
|---|---|---|---|
transactions | UnsignedTransaction[] | Yes | One unsigned transaction. |
Response Body (delegated)
| Field | Type | Required | Description |
|---|---|---|---|
txHash | string | Yes | Transaction hash of the delegated action. |
smartAccountAddress | string | Yes | Smart account used for delegation. |
Example Request
curl -X POST https://builder.ostiscan.xyz/v1/exchange/margin \
-H "Content-Type: application/json" \
-H "X-Trader-Address: 0xYourWallet" \
-d '{"a":0,"i":0,"amount":"50"}'Response (200, unsigned)
{
"transactions": [
{ "to": "0x...", "data": "0x...", "value": "0", "from": "0xYourWallet" }
]
}Response (200, delegated)
{
"txHash": "0x...",
"smartAccountAddress": "0x..."
}Errors
See /docs/errors.