Arbitrum Gas

There is a special case when computing gas costs for the Arbitrum network. In Solidity, the normal mechanisms for computing the amount of gas usage do not yet accurately reflect an amount that accounts for the L1 batch gas fees. Future network upgrades are supposed to fix this, but as of writing, the gas usage cannot be estimated using only the gasleft solidity function.

To work around this issue, Dexible deployed an Arbitrum gas price oracle smart contract. This oracle uses the arbOs precompiles and a multiplier to determine the actual gas cost for a transaction. The math is pretty simple:

  • u is the current L2 gas usage estimate (using gasleft() function)

  • p1 is the current L1 gas price from the arbOs precompiles

  • p2 is the L2 gas price for the transaction

  • m is the multiplier, expressed in 18 decimals

  • s is the size of the transaction's calldata

The multiplier can and likely will be adjusted according to historical gas estimations and especially if the network nodes start accurately reporting gas usage using gasleft() function. As of this writing, the multiplier is 2e17.

This whole thing is a stopgap to protect relays when submitting transactions for traders until nodes accurately report gas usage.

Last updated