DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Incorrect Gas Price Calculation on EIP-1559 Chains (Avalanche & Arbitrum)

Summary


Avalanche recently changed its fee structure to make it more dynamic, which means that gas prices can fluctuate more frequently. Factors affecting gas prices include network congestion, increased network usage, and changes to the network's fee structure.

The positionExcutionFee in settle function method in gmxProxy contract calculates positionExecutionFee using tx.gasprice. However, Arbitrum and Avalanche use EIP-1559-style gas pricing, where tx.gasprice is not always accurate. On these chains, the gas price is dynamically determined as:

Effective Gas Price=block.basefee+tx.priorityFeePerGas

Since tx.gasprice may not reflect the correct execution cost, the contract may:

  1. Overpay gas fees – reducing protocol efficiency.

  2. Underpay execution costs – causing transactions to fail due to insufficient gas fees.

Instances \

Impact

Economic inefficiency: The contract overpay execution fees.

  • Execution failure risk: If the base fee fluctuates, the contract will fail to execute orders properly.

  • Not compatible with future gas optimizations in EIP-1559 chains.

Tools Used

manual review

Recommendations


Instead of using tx.gasprice use explicit base fee and priority fee calculations:

uint256 baseFee = block.basefee; // Base fee from the block
uint256 priorityFee = tx.priorityFeePerGas; // Tip to validator
uint256 gasPrice = baseFee + priorityFee; // Effective gas price
uint256 positionExecutionFee = getExecutionGasLimit(
Order.OrderType.MarketDecrease,
orderData.callbackGasLimit
) * gasPrice;
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

invalid_tx-gasprice_instable

The frontrunner won’t trigger "congestion" without a huge amount of transactions, and it will cost a lot. Moreover, the execution gas limit is overestimated to prevent such cases: ``` executionGasLimit = baseGasLimit + ((estimatedGasLimit + _callbackGasLimit) * multiplierFactor) / PRECISION; ``` The keeper won’t wait long to execute the order; otherwise, GMX would not be competitive.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.