OstiumBuilder Service
API ReferenceHTTP APIExchange Operations

Exchange: Close

Build transactions to close positions.

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/close

Builds unsigned transactions to close existing positions.

Headers

HeaderRequiredDescription
X-Trader-AddressYesTrader wallet address.
X-API-KeyNoDelegated mode (delegate wallet must be verified).
Content-TypeYesapplication/json or text/plain (JSON string).

Request Body

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.
  • r must be between 1 and 100.
  • Delegated mode supports one close per request.

Response Body (unsigned)

FieldTypeRequiredDescription
transactionsUnsignedTransaction[]YesOne or more unsigned transactions.

Response Body (delegated)

FieldTypeRequiredDescription
txHashstringYesTransaction hash of the delegated action.
smartAccountAddressstringYesSmart account used for delegation.

Example Request

curl -X POST https://builder.ostiscan.xyz/v1/exchange/close \
  -H "Content-Type: application/json" \
  -H "X-Trader-Address: 0xYourWallet" \
  -d '{"closes":[{"a":0,"t":0,"p":"43000","r":50}],"sp":0.25}'

Response (200, unsigned)

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

Response (200, delegated)

{
  "txHash": "0x...",
  "smartAccountAddress": "0x..."
}

Errors

See /docs/errors.

On this page