DecentralChain (DCC) icon

DecentralChain (DCC)

Create, sign and broadcast DecentralChain transactions, plus query blockchain data

Overview

The "Cancel All Orders" operation in the Matcher resource allows users to cancel all active orders on the DecentralChain matcher service. This is useful when a user wants to quickly withdraw all their open orders from the trading order book, for example, if they want to stop trading or adjust their strategy.

This operation supports two modes of providing cancellation data:

  • Using a raw JSON cancel request body (signed), which gives full control over the cancellation payload.
  • Using individual fields such as sender address, timestamp, and signature, where the node constructs the cancel request JSON automatically.

Typical scenarios include:

  • Canceling all outstanding orders before placing new ones.
  • Quickly withdrawing all orders due to market changes or risk management.
  • Automating order management workflows in trading bots or portfolio rebalancing.

Properties

Name Meaning
Base URL Base URL to use for API requests if no credential is supplied (default: https://nodes.decentralchain.io)
Matcher Base URL Base URL for the Matcher API if no matcher credential is supplied (default: https://mainnet-matcher.decentralchain.io)
Use Raw Cancel JSON Boolean flag indicating whether to provide a raw JSON cancel body instead of using individual fields.
Cancel JSON The raw signed JSON cancel request body as required by the matcher API. Required if "Use Raw Cancel JSON" is true. Example format: {"sender":"<address>","orderID":"<ID>","timestamp":...,"signature":"..."}
Sender Address Address of the order owner. Required if "Use Raw Cancel JSON" is false.
Timestamp (MS) Optional timestamp in milliseconds for the cancellation request. If set to 0 or omitted, the current time will be used. Required if "Use Raw Cancel JSON" is false.
Signature Optional signature string for the cancellation request. Provide if the matcher requires signature-based cancellation. Required if "Use Raw Cancel JSON" is false.

Output

The node outputs a JSON object representing the response from the matcher API after attempting to cancel all orders. The structure typically includes:

  • Confirmation or status of the cancellation request.
  • Any error messages or failure details if the cancellation did not succeed.
  • Debug information including the operation name, endpoint called, base URL, timestamp, and the exact request body sent.

Example output snippet:

{
  "status": "success",
  "message": "All orders cancelled",
  "debug": {
    "operation": "cancelAllOrdersWithSig",
    "endpoint": "/matcher/orderbook/cancel",
    "matcherBaseUrl": "https://mainnet-matcher.decentralchain.io",
    "timestamp": "2024-06-01T12:00:00Z",
    "requestBody": {
      "sender": "<address>",
      "timestamp": 1685611200000,
      "signature": "<signature>"
    }
  }
}

No binary data output is produced by this operation.

Dependencies

  • Requires access to the DecentralChain Matcher API endpoint, either via a configured credential or by specifying the Matcher Base URL.
  • May require an API authentication token (bearer token) if credentials are provided.
  • The node uses HTTP POST requests to the matcher API endpoints.
  • No additional external libraries beyond those bundled with the node are required for this operation.

Troubleshooting

Common Issues

  • Invalid JSON in Cancel JSON: If "Use Raw Cancel JSON" is enabled but the JSON string is malformed, the node will throw an error. Ensure the JSON is valid and properly formatted.
  • Missing Required Fields: When not using raw JSON, missing the sender address or signature (if required) will cause the cancellation to fail.
  • Timestamp Issues: Providing an invalid timestamp or zero may cause unexpected behavior; setting it to 0 lets the node auto-generate the current timestamp.
  • Authentication Errors: If the matcher API requires a signature or token and these are missing or incorrect, the cancellation will be rejected.
  • Network or Endpoint Errors: Incorrect Matcher Base URL or network connectivity issues can cause HTTP request failures.

Error Messages and Resolutions

  • "Invalid JSON in Cancel JSON": Check and correct the JSON syntax in the Cancel JSON property.
  • "Failed to create transaction" or similar errors indicate internal issues constructing the request; verify all required parameters are set.
  • HTTP 401 Unauthorized or 403 Forbidden: Verify that the API token or signature is correctly provided and valid.
  • HTTP 404 Not Found: Confirm the Matcher Base URL is correct and the endpoint exists.

Links and References


This summary covers the static analysis of the "Cancel All Orders" operation within the Matcher resource of the DecentralChain n8n node implementation.

Discussion