SIP-2057: Dynamic Gas Fee Module - Fjord

Author
StatusImplemented
TypeGovernance
NetworkOptimism
ImplementorTBD
ReleaseTBD
ProposalLoading status...

Simple Summary

The sip proposes to put in place a new dynamic gas fee module which replaces the one currently implemented under SIP-2055. The new module would incorporate the necessary changes in transaction costs associated with optimism's fjord upgrade. Depending on governance, optimism is expected to update their gas pricing mechanism on July 10th at 16:00:01 UTC. Therefore, this sip would be implemented immediately following that update.

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):
  1. costOfExecutionGross := (l2GasCost + l1GasCost) * ETH/USD
  2. profitMargin := max(profitMarginUSD; costOfExecutionGross * profitMarginPercent )
  3. costOfExecutionNet := costOfExecutionGross + profitMargin
  4. minKeeperFee := min(costOfExecutionNet ; 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 decentralized keeper network
  • The upper bound on the minKeeperFee is incorporated for safety purposes
  • Computation of l2GasCostand l1GasCost are detailed below.

Motivation

The main motivation is to continue to incentivize the decentralized community keepers to execute perps v2 settlement & liquidation transactions by covering the cost of execution.

Specification

The following functions would be incorporated into the new contract:

getMinKeeperFee:

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

setMinKeeperFee:

This is a publicly 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

setParameters:

This can only be called by the owner, whereby the variables specified under the Configurable Values section, can be updated

setPaused:

Allows to pause and unpause the gnosis module

Owner

Returns the owner of the module that can pause the module

L1 Gas Cost:

As per the fjord specification, the L1 gas cost can be estimated with the helper function,getL1FeeUpperBound , which facilitates the on-chain computation. Hence that function would be used, feeding it with an SCCP configurable value unsignedTxSize.

Hence, the following would be used to infer the l1 gas costs: l1GasCost = getL1FeeUpperBound(unsignedTxSize)

L2 Gas Cost:

The L2 Gas cost calculation remains unchanged and is obtained by fetching the relevant l2GasPrice (block.baseFee) and multiplying it by a configurable value l2GasUnits.

Test Cases

Gas Price Module Configurations:

  • profitMarginPercent: 20%
  • profitMarginUSD: 1 sUSD
  • minKeeperFeeUpperBound: 30 sUSD
  • unsignedTxSize : 3500
  • l2GasUnits : 1.35e6 GAS

On-chain Gas Price Values:

  • l2GasPrice: 0.005 GWEI/GAS
  • ETH/USD: 2500$

Min Keeper Fee Calculation:

  • l1GasCost = getL1FeeUpperBound(3500) = 3500 GWEI
  • l2GasCost = 0.005 * 1.35e6 = 6750 GWEI
  • costOfExecutionGrossGwei = 3500 GWEI + 6750 GWEI = 10250 GWEI
  • costOfExecutionGrossUSD = (10250/1e9) ETH * 2500 USD/ETH ~= 0.025 sUSD
  • profitMargin = max(1 ; 20% * 0.025) = 1 sUSD
  • costOfExecutionNet = 1+0.025 = 1.025 sUSD
  • minKeeperFee = min(1.025;30) = 1.025 sUSD

Configurable Values (Via SCCP)

  • minKeeperFeeUpperBound being the upper bound on the minKeeperFee that can be updated, (set to 30 sUSD)
  • unsignedTxSize size of the unsigned fully RLP-encoded transaction for settling an offchain delayed order.
  • gasUnitsL2 being the number of gas units required to settle an offchain delayed order
  • profitMarginUSD being a profit margin in sUSD, applied on the cost of execution, (set to 1 sUSD)
  • profitMarginPercent being a keeper profit margin in percentage, applied on the cost of execution, (set to 20%)

Initial Configuration

Parameter Configuration
profitMarginUSD 1
profitMarginPercent 30%
minKeeperFeeUpperBound 30
unsignedTxSize 3,500
gasUnitsL2 1,300,000

References:

Copyright and related rights waived via CC0.