{"componentChunkName":"component---src-pages-sips-sip-markdown-remark-frontmatter-sip-tsx","path":"/sips/sip-20/","result":{"data":{"markdownRemark":{"fileAbsolutePath":"/vercel/path0/content/sips/sip-20.md","frontmatter":{"sip":20,"sccp":null,"title":"Gas Optimisations","network":"Ethereum","author":"Clinton Ennis (@hav-noms)","type":"Governance","proposal":null,"implementor":null,"release":null,"created":"2019-10-15T00:00:00.000Z","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<!--\"If you can't explain it simply, you don't understand it well enough.\" Provide a simplified and layman-accessible explanation of the SIP.-->\n<p>Optimize the gas on critical, high use functions that are used almost weekly by users that currently cost a lot in gas usage.</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 technical issue being addressed.-->\n<p>To make transactions cost less gas usage for Synthetix users, a <a href=\"https://gitcoin.co/issue/Synthetixio/synthetix/196/3430\">gitcoin bounty</a> was created to R&#x26;D gas optimisations on the upgradable contracts across these high use functions;</p>\n<ul>\n<li>Synthetix.issueSynths (&#x26; issueMaxSynths)</li>\n<li>Synthetix.burnSynths</li>\n<li>Synthetix.exchange</li>\n<li>Synthetix.transfer (&#x26; transferFrom)</li>\n<li>FeePool.claimFees</li>\n<li>ExchangeRates.updateRates (onlyOracle function)</li>\n</ul>\n<h4 id=\"excludes\" style=\"position:relative;\"><a href=\"#excludes\" aria-label=\"excludes 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>Excludes</h4>\n<ul>\n<li>using solidity compilers optimize runs</li>\n<li>ownerOnly functions</li>\n</ul>\n<p>The bounty resulted in several PRs for the team to validate and integrate into the system with some high value gas savings achieved.</p>\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<!--The motivation is critical for SIPs that want to change Synthetix. It should clearly explain why the existing protocol specification is inadequate to address the problem that the SIP solves. SIP submissions without sufficient motivation may be rejected outright.-->\n<h3 id=\"public-functions\" style=\"position:relative;\"><a href=\"#public-functions\" aria-label=\"public functions 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>Public functions</h3>\n<p>For SNX holders/<a href=\"https://mintr.synthetix.io\">mintr</a> users, reducing the cost of maintaining SNX collateralisation ratio via mint &#x26; burn, claiming fees and rewards and token transfers and <a href=\"https://synthetix.exchange\">Synthetix.exchange</a> trades.</p>\n<h3 id=\"onlyoracle-functions\" style=\"position:relative;\"><a href=\"#onlyoracle-functions\" aria-label=\"onlyoracle functions 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>onlyOracle functions</h3>\n<p>Reduce the cost of the ExchangeRates.updateRates function in storing pricing data onching will save the foundation in ETH running costs for the oracle.</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<!--The technical specification should describe the syntax and semantics of any new feature.-->\n<p>(@k06a) Gas Opt results</p>\n<p><code>alpha</code> (2eaef0dddf95d6c0e3a1acd4a96482aab8143d30):</p>\n<pre><code>·--------------------------------------------------------|---------------------------|-------------|----------------------------·\n|          Solc version: 0.4.25+commit.59dbf8f1          ·  Optimizer enabled: true  ·  Runs: 200  ·  Block limit: 8000000 gas  │\n·························································|···························|·············|·····························\n|  Methods                                               ·               4 gwei/gas                ·       180.56 usd/eth       │\n························|································|·············|·············|·············|··············|··············\n|  Contract             ·  Method                        ·  Min        ·  Max        ·  Avg        ·  # calls     ·  usd (avg)  │\n························|································|·············|·············|·············|··············|··············\n|  Synthetix            ·  issueSynths                   ·     306850  ·     582310  ·     423915  ·         284  ·       0.31  │\n························|································|·············|·············|·············|··············|··············\n|  Synthetix            ·  burnSynths                    ·     476976  ·     664025  ·     561884  ·          99  ·       0.41  │\n························|································|·············|·············|·············|··············|··············\n|  ExchangeRates        ·  updateRates                   ·      56015  ·    6535679  ·     117042  ·         486  ·       0.08  │\n························|································|·············|·············|·············|··············|··············\n|  FeePool              ·  claimFees                     ·     390436  ·     514240  ·     441358  ·          41  ·       0.32  │\n························|································|·············|·············|·············|··············|··············\n|  Synthetix            ·  exchange                      ·      59871  ·     249564  ·     224765  ·          45  ·       0.16  │\n························|································|·············|·············|·············|··············|··············\n</code></pre>\n<p><code>optimize/rates-storage</code> (1e2196d59bbd921bce144195e00d198548c64c28):</p>\n<pre><code>·--------------------------------------------------------|---------------------------|-------------|----------------------------·\n|          Solc version: 0.4.25+commit.59dbf8f1          ·  Optimizer enabled: true  ·  Runs: 200  ·  Block limit: 8000000 gas  │\n·························································|···························|·············|·····························\n|  Methods                                               ·               4 gwei/gas                ·       180.56 usd/eth       │\n························|································|·············|·············|·············|··············|··············\n|  Contract             ·  Method                        ·  Min        ·  Max        ·  Avg        ·  # calls     ·  usd (avg)  │\n························|································|·············|·············|·············|··············|··············\n|  Synthetix            ·  issueSynths                   ·     307688  ·     584059  ·     426344  ·         284  ·       0.31  │\n························|································|·············|·············|·············|··············|··············\n|  Synthetix            ·  burnSynths                    ·     479100  ·     666231  ·     564608  ·          99  ·       0.41  │\n························|································|·············|·············|·············|··············|··············\n|  ExchangeRates        ·  updateRates                   ·      46830  ·    3566459  ·      84580  ·         486  ·       0.06  │\n························|································|·············|·············|·············|··············|··············\n|  FeePool              ·  claimFees                     ·     391534  ·     515471  ·     442495  ·          41  ·       0.32  │\n························|································|·············|·············|·············|··············|··············\n|  Synthetix            ·  exchange                      ·      59871  ·     249871  ·     225068  ·          45  ·       0.16  │\n························|································|·············|·············|·············|··············|··············\n</code></pre>\n<h2 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</h2>\n<!--Test cases for an implementation are mandatory for SIPs but can be included with the implementation..-->\n<h2 id=\"implementation\" style=\"position:relative;\"><a href=\"#implementation\" aria-label=\"implementation 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>Implementation</h2>\n<!--The implementations must be completed before any SIP is given status \"Implemented\", but it need not be completed before the SIP is \"Approved\". While there is merit to the approach of reaching consensus on the specification and rationale before writing code, the principle of \"rough consensus and running code\" is still useful when it comes to resolving many discussions of API details.-->\n<p><a href=\"https://github.com/Synthetixio/synthetix/commit/05c42daefb282a49f791e7e626e10cf1f8352f36\">https://github.com/Synthetixio/synthetix/commit/05c42daefb282a49f791e7e626e10cf1f8352f36</a></p>\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":"7cda4416-4fad-5847-ba7d-e39a30b21eaa","frontmatter__sip":20,"__params":{"frontmatter__sip":"20"}}},"staticQueryHashes":[]}