SIP-2013: Dynamic Gas Fee Module

ProposalLoading status...

Simple Summary

The sip proposes to put in place a dynamic gas fee module, which is able to adjust the minKeeperFee, within bounds set by governance. Note that the updateMinKeeperFee function is a publically callable function that doesn't require any endorsed address for execution.


The dynamic gas fee module is a standard Gnosis Safe Module that is able to alter the minKeeperFee in our PerpsV2MarketSettings within bounds specified in the contract and configurable via governance:

  • The calculation steps of the minKeeperFee is as follows (detailed example below):
  1. costOfExecutionGross := (gasPriceL2 * gasUnitsL2 + l1BaseFee * (gasUnitsL1+overhead) * feeScalarL1) * ETH/USD
  2. profitMargin := max(profitMarginUSD; costOfExecution * profitMarginPercent )
  3. costOfExecutionNet := costOfExecutionGross + profitMargin
  4. minKeeperFee := min( max(costOfExecutionNet, minKeeperFeeLowerBound) ; minKeeperFeeUpperBound)
  • The ETH/USD price is obtained with the on-chain chainlink ETH oracle
  • The profit margin is incorporated in order to absorb shocks to gas prices on the one hand and to incentivize a decentralised keeper network
  • The lower and upper bounds on the minKeeperFee are incoporated for safety purposes
  • The number of gas units required on L1 and L2 are configurable via SCCP
  • overhead, gasPriceL2, gasPriceL1 and feeScalarL1 can be all queried on-chain with the help of the gasPriceOracle


The main motivation is the recent surge and volatility in gas prices which has resulted in all the decentralized keepers to be outpriced and the need to update the minKeeperFee in order to bolster the network of decentralized keepers that ensure that orders are executed without delay.

Note that the spartan council can enable/disable the Dynamic Gas Fee module by simply instructing pdao to remove the module's ability to update the minKeeperFee and this can be triggered out of the box with the existing gnosis safe.



This is a getter public function that returns computed gas price given on-chain variables


This is a publically callable function that updates the minKeeperFee in PerpsV2MarketSettings


This is a getter public function that returns the current configurations specified under the Configurable Values section.


This can only be called by the owner (pdao on optimism), whereby the variables specified under the Configurable Values section, can be updated.

Test Cases

Gas Price Module Configurations:

  • profitMarginPercent: 20%
  • profitmarginUSD: 2 sUSD
  • minKeeperFeeUpperBound: 10 sUSD
  • minKeeperFeeLowerBound: 2 sUSD
  • gasUnitsL1 : 26,900 GAS
  • gasUnitsL2 : 1.2e6 GAS

On-chain Gas Price Values:

  • l1BaseFee : 92 GWEI/GAS (found under gasPriceOracle in wei)
  • l2GasPrice : 0.001 GWEI/GAS (found under gasPriceOracle in wei)
  • scalar: 1 (aka dynamic_overhead, found under gasPriceOracle after incorporating the decimal adjustment found in the same contract)
  • overhead: 2,100 GAS (found under gasPriceOracle)
  • ETH/USD: 1,869$

minKeeperFee Computations:

  • costOfExecutionGrossGwei = (0.001 * 1.2e6 + (26,900 + 2,100) * 92 * 1) = 2,669,200 GWEI
  • costOfExecutionGrossETH = 2,669,200 / 1e9 = 0.0026692 ETH
  • costOfExecutionGrossUSD = 0.0026692 ETH * 1,869 USD / ETH = 4.988 sUSD =~ 5 sUSD
  • profitMargin = max(2 ; 20% * 5) = 2 sUSD
  • costOfExecutionNet = 2+5 = 7 sUSD
  • minKeeperFee = max(min(7;10) ; 2) = 7 sUSD

Configurable Values (Via SCCP)

  • minKeeperFeeLowerBound being the lower bound on the minKeeperFee that can be updated
  • minKeeperFeeUpperBound being the upper bound on the minKeeperFee that can be updated
  • gasUnitsL1 and gasUnitsL2 being the number of gas units required to execute a pending offchain delayed order
  • profitMarginUSD being a profit margin in sUSD, applied on the cost of execution
  • profitMarginPercent being a keeper profit margin in percentage, applied on the cost of execution


Copyright and related rights waived via CC0.