Files

4.6 KiB

Cancel And Place

Rate limits

{% hint style="info" %} See more details in API Rate limits. {% endhint %}

Request

{% tabs %} {% tab title="Websocket" %} 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",
        "appendix": "1537",
        "nonce": "1757062078359666688"
      },
      "signature": "0x",
    }
  }
}

{% endtab %}

{% tab title="REST" %} POST [GATEWAY_REST_ENDPOINT]/execute

Body

{
  "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",
    }
  }
}

{% endtab %} {% endtabs %}

Request Parameters

ParameterTypeRequiredDescription
cancel_txobjectYesCancel order transaction object. See Cancel order signing for details on the transaction fields.
cancel_tx.senderstringYesHex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.
cancel_tx.productIdsnumber[]YesA list of product IDs, corresponding to the product ids of the orders in digests
cancel_tx.digestsstring[]YesA list of order digests, represented as hex strings.
cancel_tx.noncestringYesUsed to differentiate between the same cancellation multiple times. See Cancel order signing section for more details.
cancel_signaturestringYesSigned transaction. See SigningCancel order signing for more details.
place_orderobjectYesPayload of order to be placed. See Place order request parameters for payload details.

Signing

{% hint style="warning" %} Note: both cancel_tx and place_order objects must be signed using the same signer, otherwise the request will be rejected. {% endhint %}

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"
}