async order with the /order-status endpoint (a sync response has nothing to track).
Poll GET /order-status with the signature of the transaction that opened the order and the lastValidBlockHeight from the order response, until the status is terminal: expired, failed, or closed. At pendingClose nothing more can fill, and keep polling until it is closed.
1
Set Up
Imports, env config, response types, and the opening signature and
lastValidBlockHeight of the order.Imports, env, and types
Imports, env, and types
2
Poll the Order Status Endpoint with Backoff
Poll
GET /order-status with exponential backoff until the status is terminal.Poll with backoff
Poll with backoff
3
Handle Each Terminal Status
Handle each terminal status:
expired, failed, and closed.Handle terminal statuses
Handle terminal statuses
4
Total the Fills and Reverts
Total the fills and reverts of a closed order and classify the outcome.
Total fills and reverts
Total fills and reverts