{"componentChunkName":"component---src-pages-sips-sip-markdown-remark-frontmatter-sip-tsx","path":"/sips/sip-2013/","result":{"data":{"markdownRemark":{"fileAbsolutePath":"/vercel/path0/content/sips/sip-2013.md","frontmatter":{"sip":2013,"sccp":null,"title":"Dynamic Gas Fee Module","network":"Optimism","author":"kaleb (@kaleb-keny), Fifa","type":"Governance","proposal":"https://snapshot.org/#/snxgov.eth/proposal/0xcd43f357c951e422b78671a7c23a89b5e63c2bd6a4eb8b39c76a9bc4f419e0bc","implementor":null,"release":null,"created":null,"updated":null,"status":"Implemented"},"html":"<h2 id=\"simple-summary\" style=\"position:relative;\"><a href=\"#simple-summary\" aria-label=\"simple summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Simple Summary</h2>\n<p>The sip proposes to put in place a dynamic gas fee module, which is able to adjust the <code>minKeeperFee</code>, within bounds set by governance. Note that the <code>updateMinKeeperFee</code> function is a publically callable function that doesn't require any endorsed address for execution.</p>\n<h2 id=\"abstract\" style=\"position:relative;\"><a href=\"#abstract\" aria-label=\"abstract permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Abstract</h2>\n<!--A short (~200 word) description of the proposed change, the abstract should clearly describe the proposed change. This is what *will* be done if the SIP is implemented, not *why* it should be done or *how* it will be done. If the SIP proposes deploying a new contract, write, \"we propose to deploy a new contract that will do x\".-->\n<p>The dynamic gas fee module is a standard <a href=\"https://help.safe.global/en/articles/4934378-what-is-a-module\">Gnosis Safe Module</a> that is able to alter the <code>minKeeperFee</code> in our <a href=\"https://optimistic.etherscan.io/address/0x649F44CAC3276557D03223Dbf6395Af65b11c11c\"><code>PerpsV2MarketSettings</code></a> within bounds specified in the contract and configurable via governance:</p>\n<ul>\n<li>The calculation steps of the minKeeperFee is as follows (detailed example below):</li>\n</ul>\n<ol>\n<li><code>costOfExecutionGross := (gasPriceL2 * gasUnitsL2 + l1BaseFee * (gasUnitsL1+overhead) * feeScalarL1) * ETH/USD</code></li>\n<li><code>profitMargin := max(profitMarginUSD; costOfExecution * profitMarginPercent )</code></li>\n<li><code>costOfExecutionNet := costOfExecutionGross + profitMargin</code></li>\n<li><code>minKeeperFee := min( max(costOfExecutionNet, minKeeperFeeLowerBound) ; minKeeperFeeUpperBound)</code></li>\n</ol>\n<ul>\n<li>The <code>ETH/USD</code> price is obtained with the on-chain chainlink ETH oracle</li>\n<li>The profit margin is incorporated in order to absorb shocks to gas prices on the one hand and to incentivize a decentralised keeper network</li>\n<li>The lower and upper bounds on the <code>minKeeperFee</code> are incoporated for safety purposes</li>\n<li>The number of gas units required on L1 and L2 are configurable via SCCP</li>\n<li><code>overhead</code>, <code>gasPriceL2</code>, <code>gasPriceL1</code> and <code>feeScalarL1</code> can be all queried on-chain with the help of the <a href=\"https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000F#readContract\">gasPriceOracle</a></li>\n</ul>\n<h2 id=\"motivation\" style=\"position:relative;\"><a href=\"#motivation\" aria-label=\"motivation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Motivation</h2>\n<p>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 <code>minKeeperFee</code> in order to bolster the network of decentralized keepers that ensure that orders are executed without delay.</p>\n<p>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 <code>minKeeperFee</code> and this can be triggered out of the box with the existing gnosis safe.</p>\n<h2 id=\"specification\" style=\"position:relative;\"><a href=\"#specification\" aria-label=\"specification permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Specification</h2>\n<h3 id=\"getminkeeperfee\" style=\"position:relative;\"><a href=\"#getminkeeperfee\" aria-label=\"getminkeeperfee permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>getMinKeeperFee:</h3>\n<p>This is a getter public function that returns computed gas price given on-chain variables</p>\n<h3 id=\"setminkeeperfee\" style=\"position:relative;\"><a href=\"#setminkeeperfee\" aria-label=\"setminkeeperfee permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>setMinKeeperFee:</h3>\n<p>This is a publically callable function that updates the <code>minKeeperFee</code> in PerpsV2MarketSettings</p>\n<h3 id=\"getparameters\" style=\"position:relative;\"><a href=\"#getparameters\" aria-label=\"getparameters permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>getParameters:</h3>\n<p>This is a getter public function that returns the current configurations specified under the  Configurable Values section.</p>\n<h3 id=\"setparmeters\" style=\"position:relative;\"><a href=\"#setparmeters\" aria-label=\"setparmeters permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>setParmeters:</h3>\n<p>This can only be called by the owner (pdao on optimism), whereby the variables specified under the Configurable Values section, can be updated.</p>\n<h3 id=\"test-cases\" style=\"position:relative;\"><a href=\"#test-cases\" aria-label=\"test cases permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Test Cases</h3>\n<h4 id=\"gas-price-module-configurations\" style=\"position:relative;\"><a href=\"#gas-price-module-configurations\" aria-label=\"gas price module configurations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Gas Price Module Configurations:</h4>\n<ul>\n<li><code>profitMarginPercent</code>: 20%</li>\n<li><code>profitmarginUSD</code>: 2 sUSD</li>\n<li><code>minKeeperFeeUpperBound</code>: 10 sUSD</li>\n<li><code>minKeeperFeeLowerBound</code>: 2 sUSD</li>\n<li><code>gasUnitsL1</code> : 26,900 GAS</li>\n<li><code>gasUnitsL2</code> : 1.2e6 GAS</li>\n</ul>\n<h4 id=\"on-chain-gas-price-values\" style=\"position:relative;\"><a href=\"#on-chain-gas-price-values\" aria-label=\"on chain gas price values permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>On-chain Gas Price Values:</h4>\n<ul>\n<li><code>l1BaseFee</code> : 92 GWEI/GAS (found under <a href=\"https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000F#readContract\">gasPriceOracle</a> in wei)</li>\n<li><code>l2GasPrice</code> : 0.001 GWEI/GAS (found under <a href=\"https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000F#readContract\">gasPriceOracle</a> in wei)</li>\n<li><code>scalar</code>: 1 (aka dynamic_overhead, found under <a href=\"https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000F#readContract\">gasPriceOracle</a> after incorporating the decimal adjustment found in the same contract)</li>\n<li><code>overhead</code>: 2,100 GAS (found under <a href=\"https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000F#readContract\">gasPriceOracle</a>)</li>\n<li><code>ETH/USD</code>: 1,869$</li>\n</ul>\n<h4 id=\"minkeeperfee-computations\" style=\"position:relative;\"><a href=\"#minkeeperfee-computations\" aria-label=\"minkeeperfee computations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code>minKeeperFee</code> Computations:</h4>\n<ul>\n<li><code>costOfExecutionGrossGwei</code> = (0.001 * 1.2e6 + (26,900 + 2,100) * 92 * 1) = 2,669,200 GWEI</li>\n<li><code>costOfExecutionGrossETH</code> = 2,669,200 / 1e9 = 0.0026692 ETH</li>\n<li><code>costOfExecutionGrossUSD</code> = 0.0026692 ETH * 1,869 USD / ETH = 4.988 sUSD =~ 5 sUSD</li>\n<li><code>profitMargin</code> = max(2 ; 20% * 5) = 2 sUSD</li>\n<li><code>costOfExecutionNet</code> = 2+5 = 7 sUSD</li>\n<li><code>minKeeperFee</code> = max(min(7;10) ; 2) = 7 sUSD</li>\n</ul>\n<h3 id=\"configurable-values-via-sccp\" style=\"position:relative;\"><a href=\"#configurable-values-via-sccp\" aria-label=\"configurable values via sccp permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configurable Values (Via SCCP)</h3>\n<ul>\n<li><code>minKeeperFeeLowerBound</code> being the lower bound on the minKeeperFee that can be updated</li>\n<li><code>minKeeperFeeUpperBound</code> being the upper bound on the minKeeperFee that can be updated</li>\n<li><code>gasUnitsL1</code> and <code>gasUnitsL2</code> being the number of gas units required to execute a pending offchain delayed order</li>\n<li><code>profitMarginUSD</code> being a profit margin in sUSD, applied on the cost of execution</li>\n<li><code>profitMarginPercent</code> being a keeper profit margin in percentage, applied on the cost of execution</li>\n</ul>\n<h3 id=\"references\" style=\"position:relative;\"><a href=\"#references\" aria-label=\"references permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>References:</h3>\n<ul>\n<li><a href=\"https://community.optimism.io/docs/developers/build/transaction-fees/#the-l1-data-fee\">Optimism Gas Price Docs</a></li>\n<li><a href=\"https://github.com/ethereum-optimism/optimism-tutorial/tree/main/sdk-estimate-gas\">Optimism Gas Price SDK</a></li>\n</ul>\n<h2 id=\"copyright\" style=\"position:relative;\"><a href=\"#copyright\" aria-label=\"copyright permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Copyright</h2>\n<p>Copyright and related rights waived via <a href=\"https://creativecommons.org/publicdomain/zero/1.0/\">CC0</a>.</p>"}},"pageContext":{"id":"e5e845b2-0581-5502-9b46-6aa6cecec408","frontmatter__sip":2013,"__params":{"frontmatter__sip":"2013"}}},"staticQueryHashes":[]}