SIP-2013: Dynamic Gas Fee Module
| Author | kaleb, Fifa |
|---|---|
| Status | Implemented |
| Type | Governance |
| Network | Optimism |
| Implementor | TBD |
| Release | TBD |
| Proposal | Loading 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.
Abstract
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):
costOfExecutionGross := (gasPriceL2 * gasUnitsL2 + l1BaseFee * (gasUnitsL1+overhead) * feeScalarL1) * ETH/USDprofitMargin := max(profitMarginUSD; costOfExecution * profitMarginPercent )costOfExecutionNet := costOfExecutionGross + profitMarginminKeeperFee := min( max(costOfExecutionNet, minKeeperFeeLowerBound) ; minKeeperFeeUpperBound)
- The
ETH/USDprice 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
minKeeperFeeare incoporated for safety purposes - The number of gas units required on L1 and L2 are configurable via SCCP
overhead,gasPriceL2,gasPriceL1andfeeScalarL1can be all queried on-chain with the help of the gasPriceOracle
Motivation
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.
Specification
getMinKeeperFee:
This is a getter public function that returns computed gas price given on-chain variables
setMinKeeperFee:
This is a publically callable function that updates the minKeeperFee in PerpsV2MarketSettings
getParameters:
This is a getter public function that returns the current configurations specified under the Configurable Values section.
setParmeters:
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 sUSDminKeeperFeeUpperBound: 10 sUSDminKeeperFeeLowerBound: 2 sUSDgasUnitsL1: 26,900 GASgasUnitsL2: 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 GWEIcostOfExecutionGrossETH= 2,669,200 / 1e9 = 0.0026692 ETHcostOfExecutionGrossUSD= 0.0026692 ETH * 1,869 USD / ETH = 4.988 sUSD =~ 5 sUSDprofitMargin= max(2 ; 20% * 5) = 2 sUSDcostOfExecutionNet= 2+5 = 7 sUSDminKeeperFee= max(min(7;10) ; 2) = 7 sUSD
Configurable Values (Via SCCP)
minKeeperFeeLowerBoundbeing the lower bound on the minKeeperFee that can be updatedminKeeperFeeUpperBoundbeing the upper bound on the minKeeperFee that can be updatedgasUnitsL1andgasUnitsL2being the number of gas units required to execute a pending offchain delayed orderprofitMarginUSDbeing a profit margin in sUSD, applied on the cost of executionprofitMarginPercentbeing a keeper profit margin in percentage, applied on the cost of execution
References:
Copyright
Copyright and related rights waived via CC0.