calculate_execution_fee

Documentation for eth_defi.gmx.gas_utils.calculate_execution_fee function.

calculate_execution_fee(gas_limits, gas_price, order_type='decrease_order', oracle_price_count=2)

Calculate execution fee using GMX’s formula.

GMX calculates minimum execution fee as:

adjustedGasLimit = baseGasLimit + (oracleCount * perOracleGas) + applyFactor(estimatedGasLimit, multiplierFactor) minExecutionFee = adjustedGasLimit * tx.gasprice

Where applyFactor(value, factor) = value * factor / 10^30

Parameters
  • gas_limits (dict[str, int]) – Gas limits dictionary from get_gas_limits()

  • gas_price (int) – Gas price in wei (should be maxFeePerGas for EIP-1559)

  • order_type (str) – Order type key: “increase_order”, “decrease_order”, “swap_order”, etc.

  • oracle_price_count (int) – Number of oracle prices needed (typically 2 for most orders)

Returns

Calculated execution fee in wei

Return type

int