API

You can use ethers.js, viem or similar tools to automate trading.

You can also retrieve data from The Graph; see Subgraph.

Create an order

Contract struct

For marketID, see Metadata

struct Order {
    ActionType action; // Order action, 0 for OpenPosition, 1 for ReduceOnly
    uint256 marketId; // See link above
    /// @notice Use `amount` and `price` to control slippage
    int256 amount; // Amount of base token, 18 decimals
    uint256 price; // Order price, 18 decimals
    uint256 expiry; // Expiry timestamp
    TradeType tradeType; // Fill type, 0 for Fill or Kill, 1 for Partial Fill
    address owner; // Order address (must be same as signer)
    uint256 marginXCD; // Margin amount for the order, decimals match collateral
    /// @notice `relayFee` is 0.10 USDT; in the future this fee will be queryable via API
    uint256 relayFee; // Relayer fee, decimals match collateral
    bytes32 id; // User generated; may not repeat
}

API Endpoint

Request

Response

Cancel an order

Orders are cancelled using the signed order and orderID (not just orderID, since it would allow anyone to cancel another account's order).

API Endpoint

Request

Response

Examples

Create order

Cancel order

Last updated

Was this helpful?