verify_gmx_order_execution

Documentation for eth_defi.gmx.verification.verify_gmx_order_execution function.

verify_gmx_order_execution(web3, receipt, order_key=None)

Verify GMX order execution from transaction receipt.

This function parses GMX events from the receipt to determine the true order execution status. A transaction can have receipt.status == 1 but still contain OrderCancelled or OrderFrozen events indicating failure.

Success pattern:

  • Has OrderExecuted event

  • Has PositionIncrease or PositionDecrease event

  • Typically 20-32+ GMX events

Failure pattern:

  • Has OrderCancelled or OrderFrozen event

  • No OrderExecuted event

  • Typically 6-10 GMX events

  • Error reason in reasonBytes field

Parameters
  • web3 (web3.main.Web3) – Web3 instance connected to the appropriate chain

  • receipt (dict) – Transaction receipt from keeper execution

  • order_key (bytes | None) – Optional order key to filter for. If not provided, returns result for the first order event found.

Returns

GMXOrderVerificationResult with success flag and execution details

Return type

eth_defi.gmx.verification.GMXOrderVerificationResult

Example:

receipt = web3.eth.wait_for_transaction_receipt(tx_hash)
result = verify_gmx_order_execution(web3, receipt)

if not result.success:
    logger.error(
        "Order %s failed: %s",
        result.order_key.hex() if result.order_key else "unknown",
        result.decoded_error or result.reason,
    )