Cancel And Place

Performs an order cancellation + order placement in a single request

Rate limits

See more details in API Rate limits.

Request

Connect

WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]

Message

{
  "cancel_and_place": {
    "cancel_tx": {
      "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
      "productIds": [2],
      "digests": ["0x"],
      "nonce": "1"
    },
    "cancel_signature": "0x",
    "place_order": {
      "product_id": 1,
      "order": {
        "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
        "priceX18": "1000000000000000000",
        "amount": "1000000000000000000",
        "expiration": "4294967295",
        "nonce": "1757062078359666688"
      },
      "signature": "0x",
    }
  }
}

Request Parameters

ParameterTypeRequiredDescription

cancel_tx

object

Yes

Cancel order transaction object. See Cancel order signing for details on the transaction fields.

cancel_tx.sender

string

Yes

Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.

cancel_tx.productIds

number[]

Yes

A list of product IDs, corresponding to the product ids of the orders in digests

cancel_tx.digests

string[]

Yes

A list of order digests, represented as hex strings.

cancel_tx.nonce

string

Yes

Used to differentiate between the same cancellation multiple times. See Cancel order signing section for more details.

cancel_signature

string

Yes

Signed transaction. See SigningCancel order signing for more details.

place_order

object

Yes

Payload of order to be placed. See Place order request parameters for payload details.

Signing

Note: both cancel_tx and place_order objects must be signed using the same signer, otherwise the request will be rejected.

Response

Success

{
  "status": "success",
  "signature": {signature},
  "data": { 
    "digest": {order digest} 
  },
  "request_type": "execute_cancel_and_place"
}

Failure

{
  "status": "failure",
  "signature": {signature}
  "error": "{error_msg}"
  "error_code": {error_code}
  "request_type": "execute_cancel_and_place"
}

Last updated