API Reference

Cancel an order and Create a new order on the SubAccount

Order Types

0 - LIMIT
1 - LIMIT_MAKER
2 - MARKET 
3 - STOP_LOSS          // Not implemented
4 - STOP_LOSS_LIMIT    // Not implemented
5 - TAKE_PROFIT        // Not implemented
6 - TAKE_PROFIT_LIMIT  // Not implemented

Time in Force

0 - GTC // Good 'Til Cancelled - basic limit order
1 - FOK // Fill or Kill - must be entirely filled immediately
2 - IOC // Immediate or Cancel - leftover is just dropped

Signature generation

The api expects a EIP712 signature constructed with the following typed data:

{
  EIP712Domain: [
    {
      name: 'name', // rysk
      type: 'string',
    },
    {
      name: 'version', // "0.0.0"
      type: 'string',
    },
    {
      name: 'chainId', 
      type: 'uint256',
    },
    {
      name: 'verifyingContract', // <OrderDispatchAddress> 
      type: 'address',
    },
	],
  Order: [
    {
			name: "account", // address of the account making the order
			type: "address",
		},
		{
			name: "subAccountId",  // subAccountId of the subaccount to execute the order on
			type: "uint8",
		},
		{
			name: "productId",  // the productId of the product to trade
			type: "uint32",
		},
		{
			name: "isBuy", // whether the account is buying or selling
			type: "bool",
		},
		{
			name: "orderType", // e.g. limit, market, etc.
			type: "uint8",
		},
		{
			name: "timeInForce", // e.g. GTC, IOC, FOK
			type: "uint8",
		},
		{
			name: "expiration",  // the expiration of the order, after this time the order is dropped from the orderbook
			type: "uint64",
		},
		{
			name: "price",  // the price to execute the trade at represented in the quote asset in e18 format (the trade will be executed at this price or better)
			type: "uint128",
		},
		{
			name: "quantity",  // the number of contracts to purchase at the given price
			type: "uint128",
		},
		{
			name: "nonce",  // unique nonce for the transaction, nonces are tracked globally across all actions and cannot be repeated
			type: "uint64",
		},
  ],
}

Example request:

{
"idToCancel": "0x1234",                // Order id to cancel
"newOrder": {                          // New order to replaced cancelled one
    "account": "0x1234",               // Account address
    "subAccountId": 0,                 // Subaccount id
    "productId": 1002,                 // Identifier for the product
    "isBuy": true,                     // Indicates if the order is a buy order (true) or sell order (false)
    "orderType": 0,                    // Type of the order: 0 Limit, 1 Limit Maker, 2 Market, 3 Stop Loss, 4 Stop Loss Limit, 5 Take Profit, 6 Take Profit Limit
    "timeInForce": 0,                  // Time in force policy: 0 GTC, 1 FOK, 2 IOC 
    "expiration": 1718804531305,       // Expiry time of the order in milliseconds since epoch
    "price": "3384300000000000000000", // Price of the order in e18 decimals
    "quantity": "10000000000000000",   // Quantity of the order in e18 decimals
    "nonce": 1718718131305466,         // Unique nonce for the transaction, nonces are tracked globally across all actions and cannot be repeated 
    "signature": "0x1234..."           // Signature for verifying the order
  }
}

Example response:

{
    "id": "0x123456",                                  // Unique identifier for the order
    "productId": 1002,                                 // Identifier for the product
    "productSymbol": "ethperp",                        // Symbol for the product
    "account": "0x123456",                             // Account address 
    "subAccountId": 0,                                 // Subaccount id
    "isBuy": true,                                     // Indicates if the order is a buy order (true) or sell order (false)
    "orderType": 1,                                    // Type of the order: 0 Limit, 1 Limit Maker, 2 Market, 3 Stop Loss, 4 Stop Loss Limit, 5 Take Profit, 6 Take Profit Limit
    "timeInForce": 1,                                  // Time in force policy (e.g., GTC, IOC)
    "price": "50000000000000000000000",                // Price of the order in e18 decimals
    "quantity": "1000000000000000000",                 // Quantity of the order in e18 decimals
    "nonce": 123456789,                                // Unique nonce for the transaction, nonces are tracked globally across all actions and cannot be repeated 
    "sender": "0x456",                                 // Address of the sender
    "signature": "0x123456...",                        // Signature for verifying the order
    "expiration": 1625812800000,                       // Expiry time of the order in milliseconds since epoch
    "txHash": "0x1234abcd...",                         // Transaction hash associated with the order
    "createdAt": 1625812800000,                        // Creation time of the order in milliseconds since epoch
    "status": "OPEN",                                  // Current status of the order: OPEN, FILLED, CANCELLED
    "residualQuantity": "500000000000000000",          // Remaining quantity of the order in e18 decimals
    "trades": [                                        // List of trades associated with the order
      {
        "price": "50000000000000000000000",            // Price of the trade in e18 decimals
        "quantity": "500000000000000000",              // Quantity of the trade in e18 decimals
        "isTaker": true,                               // Indicates if the trade was executed by the taker (true) or maker (false)
        "fee": "10000000000000000",                    // Fee for the trade in e18 decimals
        "createdAt": 1625812800000,                    // Timestamp of the trade in milliseconds since epoch
        "uid": "xxxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxxxxx" // Unique identifier for the trade
      }
    ]
  }
Language
Click Try It! to start a request and see the response here!