check_order_status
Documentation for eth_defi.gmx.order_tracking.check_order_status function.
- check_order_status(web3, order_key, chain, search_blocks=1000, subsquid_timeout=10, subsquid_max_retries=5, subsquid_initial_delay=2.0, creation_block=None, wait_for_indexer=False, wait_for_indexer_timeout=60.0)
Check if a GMX order is still pending or has been executed/cancelled.
This function first checks the DataStore to see if the order exists in the pending orders list. If not, it queries Subsquid GraphQL indexer (primary) or falls back to scanning EventEmitter logs via RPC.
- Parameters
web3 (web3.main.Web3) – Web3 instance connected to the appropriate chain
order_key (bytes) – The 32-byte order key from the OrderCreated event
chain (str) – Chain name (“arbitrum”, “avalanche”, or “arbitrum_sepolia”)
search_blocks (int) – Number of recent blocks to search for execution events via RPC fallback. Only used if creation_block is not provided. (default: 1000)
subsquid_timeout (int) – Timeout in seconds for each Subsquid query attempt (default: 10)
subsquid_max_retries (int) – Maximum retry attempts for Subsquid queries (default: 5)
subsquid_initial_delay (float) – Initial delay between Subsquid retries in seconds (default: 2.0)
creation_block (int | None) – Block number where the order was created. If provided, log scanning will start from this block instead of (current_block - search_blocks). This enables accurate scanning after bot restarts.
wait_for_indexer (bool) – If True, keep polling Subsquid until indexer catches up (for fresh orders). Useful when checking status immediately after order creation.
wait_for_indexer_timeout (float) – Maximum time to wait for Subsquid indexer to catch up (default: 60s)
- Returns
OrderStatusResult with pending status and execution details if available
- Return type
Example:
from eth_defi.gmx.order_tracking import check_order_status from eth_defi.gmx.events import extract_order_key_from_receipt # After order creation order_key = extract_order_key_from_receipt(web3, creation_receipt) # Poll for execution while True: result = check_order_status(web3, order_key, "arbitrum") if not result.is_pending: break time.sleep(2) # Now verify the execution if result.execution_receipt: verification = verify_gmx_order_execution(web3, result.execution_receipt, order_key)