SIP-2057: Dynamic Gas Fee Module - Fjord

Author
StatusDraft
TypeGovernance
Networkoptimism
ImplementorTBD
ReleaseTBD

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 Pending:

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 is obtained with the below calculation:

l1FeeScaled = baseFeeScalar*l1BaseFee*16 + blobFeeScalar*l1BlobBaseFee
estimatedSizeScaled = max(minTransactionSize * 1e6, intercept + fastlzCoef*fastlzSize)
l1Cost = estimatedSizeScaled * l1FeeScaled / 1e12

However, the optimism implemented a helper function,getL1FeeUpperBound , which facilitates the on-chain computation and requires only 1 parameter, unsignedTxSize. Hence this function would be used, along with the parameter being the size of the unsigned fully RLP-encoded transaction, an SCCP configurable value.

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 : 3,300
  • l2GasUnits : 1.35e6 GAS

On-chain Gas Price Values:

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

Min Keeper Fee Calculation:

  • l1GasCost = getL1FeeUpperBound(3300) = 1669 GWEI
  • l2GasCost = 0.005 * 1.35e6 = 6750 GWEI
  • costOfExecutionGrossGwei = 1669 GWEI + 6750 GWEI
  • costOfExecutionGrossUSD = (8419/1e9) ETH * 2500 USD/ETH ~= 0.021 sUSD
  • profitMargin = max(1 ; 20% * 0.021) = 1 sUSD
  • costOfExecutionNet = 1+0.021 = 1.021 sUSD
  • minKeeperFee = min(1.021;30) = 1.021 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%)

References:

Copyright and related rights waived via CC0.