Skip to content

Conditional orders

Conditional orders store a signed action in the delegated trading EOA. A registered keeper later submits it when the committed condition is satisfied.

Trigger creation is defined by the API but is disabled on the current testnet deployment. Do not build a production integration that assumes these methods are currently routable.

How triggers differ from immediate orders

  • Trigger creation and cancellation use an unordered one-shot nonce namespace.
  • This namespace is separate from the increasing nonce used by execute_batch and execute_replace_by_slot_packed.
  • conditionHash commits to a condition understood by the trigger service. The wallet contract does not evaluate the condition itself.
  • triggerExpiry limits when a keeper may fire the action. header.deadline separately limits when the trigger may be created.

wallet.create_batch_trigger

Use this to store the same native orders and cancellations accepted by wallet.execute_batch, plus a condition commitment:

{
  "requestId": "018f5ef2-88a1-7b41-a826-4b679010f87f",
  "method": "wallet.create_batch_trigger",
  "wallet": "0x1111111111111111111111111111111111111111",
  "payload": {
    "header": {
      "accountId": "123",
      "market": "0x2222222222222222222222222222222222222222",
      "authNonce": "1",
      "nonce": "1720000000997",
      "deadline": "1720000030",
      "clientOrderId": "0x0000000000000000000000000000000000000000000000000000000000000003",
      "builder": "0x0000000000000000000000000000000000000000",
      "builderFeePps": "0"
    },
    "triggerExpiry": "1720003600",
    "conditionSchema": "1",
    "condition": "0x...",
    "conditionHash": "0x...32 bytes...",
    "orders": [],
    "cancelSlotIdxs": ["3"],
    "expectedOrderIds": ["31"],
    "signature": "0x..."
  },
  "authorization7702": null
}

The signed type is CreateBatchTriggerIntent. It binds the common header, trigger expiry, condition hash, and hashes of all three action arrays.

wallet.create_replace_trigger

Use this to store a compact packed replacement:

{
  "requestId": "018f5ef2-88a1-7b41-a826-4b679010f880",
  "method": "wallet.create_replace_trigger",
  "wallet": "0x1111111111111111111111111111111111111111",
  "payload": {
    "header": {
      "accountId": "123",
      "market": "0x2222222222222222222222222222222222222222",
      "authNonce": "1",
      "nonce": "1720000000998",
      "deadline": "1720000030",
      "clientOrderId": "0x0000000000000000000000000000000000000000000000000000000000000004",
      "builder": "0x0000000000000000000000000000000000000000",
      "builderFeePps": "0"
    },
    "triggerExpiry": "1720003600",
    "conditionSchema": "1",
    "condition": "0x...",
    "conditionHash": "0x...32 bytes...",
    "packedOps": "0x...",
    "expectedOrderIds": ["31"],
    "signature": "0x..."
  },
  "authorization7702": null
}

The packed operation and binding rules are the same as the immediate packed method.

For both create methods, condition must hash exactly to conditionHash, and its encoded schema must match conditionSchema. The relay registers the condition before it sponsors the on-chain creation.

The examples illustrate the complete field structure but are not executable: the condition hash, action hashes, signatures, nonces, deadlines, and IDs must be generated from current state.

wallet.cancel_trigger

Cancel an active trigger with a newly signed cancellation:

{
  "requestId": "018f5ef2-88a1-7b41-a826-4b679010f87f",
  "method": "wallet.cancel_trigger",
  "wallet": "0x1111111111111111111111111111111111111111",
  "payload": {
    "accountId": "123",
    "authNonce": "1",
    "nonce": "1720000000999",
    "deadline": "1720000030",
    "triggerId": "0x...32 bytes...",
    "signature": "0x..."
  },
  "authorization7702": null
}

The nonce must be unused in the trigger nonce namespace. The trigger must be active, belong to the same account, and have been created by the same secondary trading EOA.

Verify the transaction receipt and TriggerCanceled event before treating the trigger as canceled.