v4-core icon indicating copy to clipboard operation
v4-core copied to clipboard

Optimise `_checkProtocolFee`

Open malik672 opened this issue 2 years ago • 4 comments
trafficstars

Related Issue

Gas Optimisation

Description of changes

1.Introduced unchecked block for the _checkProtocolFee() function , this potentially saves 100+ in gas 2.Performed modulo operation using bit operation this saves 25+ in gas, for more information check http://graphics.stanford.edu/~seander/bithacks.html#ModulusDivisionEasy 3.used uint256 as param type instead of uint8

malik672 avatar Jun 20 '23 16:06 malik672

will do that

malik672 avatar Jun 22 '23 15:06 malik672

@hensha256 done

malik672 avatar Jun 22 '23 19:06 malik672

Hi @malik672 the snapshots are showing that there arent any gas improvements from your code changes? Only the bytecode size has changed

hensha256 avatar Jun 22 '23 20:06 hensha256

Hi @malik672 the snapshots are showing that there arent any gas improvements from your code changes? Only the bytecode size has changed

this is weird, there should be gas decrease

malik672 avatar Jun 22 '23 21:06 malik672

We have now made a number of changes for how protocol fees work so this PR is out of date. We are closing this PR in favor of #283

hensha256 avatar Apr 03 '24 18:04 hensha256