Uniswap / v4-core

🦄 🦄 🦄 🦄 Core smart contracts of Uniswap v4
https://blog.uniswap.org/uniswap-v4
2.04k stars 987 forks source link

Spearbit gas 03: `liquidityGrossBefore` #824

Closed hensha256 closed 3 months ago

hensha256 commented 3 months ago

Doesnt actually improve gas, but I do think its more readable

github-actions[bot] commented 3 months ago
Forge code coverage: File % Lines % Statements % Branches % Funcs
src/ERC6909.sol 91.30% (21/23) 85.71% (24/28) 100.00% (2/2) 85.71% (6/7)
src/ERC6909Claims.sol 100.00% (6/6) 100.00% (8/8) 100.00% (2/2) 100.00% (1/1)
src/Extsload.sol 100.00% (28/28) 93.33% (28/30) 0.00% (0/2) 100.00% (3/3)
src/Exttload.sol 13.33% (2/15) 12.50% (2/16) 0.00% (0/1) 50.00% (1/2)
src/NoDelegateCall.sol 100.00% (3/3) 100.00% (4/4) 100.00% (1/1) 100.00% (3/3)
src/PoolManager.sol 100.00% (94/94) 98.46% (128/130) 89.47% (17/19) 100.00% (20/20)
src/ProtocolFees.sol 100.00% (27/27) 96.97% (32/33) 83.33% (5/6) 100.00% (6/6)
src/libraries/BitMath.sol 100.00% (11/11) 100.00% (11/11) 100.00% (4/4) 100.00% (2/2)
src/libraries/CurrencyDelta.sol 100.00% (9/9) 100.00% (11/11) 100.00% (0/0) 100.00% (3/3)
src/libraries/CurrencyReserves.sol 85.71% (6/7) 85.71% (6/7) 0.00% (0/1) 100.00% (5/5)
src/libraries/CustomRevert.sol 100.00% (34/34) 100.00% (34/34) 100.00% (0/0) 100.00% (8/8)
src/libraries/FullMath.sol 100.00% (29/29) 100.00% (33/33) 100.00% (6/6) 100.00% (2/2)
src/libraries/Hooks.sol 100.00% (85/85) 98.57% (138/140) 88.00% (22/25) 100.00% (14/14)
src/libraries/LPFeeLibrary.sol 100.00% (10/10) 100.00% (16/16) 100.00% (1/1) 100.00% (7/7)
src/libraries/LiquidityMath.sol 100.00% (4/4) 100.00% (4/4) 100.00% (1/1) 100.00% (1/1)
src/libraries/Lock.sol 100.00% (3/3) 100.00% (3/3) 100.00% (0/0) 100.00% (3/3)
src/libraries/NonZeroDeltaCount.sol 100.00% (7/7) 100.00% (7/7) 100.00% (0/0) 100.00% (3/3)
src/libraries/ParseBytes.sol 100.00% (3/3) 100.00% (3/3) 100.00% (0/0) 100.00% (3/3)
src/libraries/Pool.sol 99.38% (159/160) 99.44% (176/177) 98.04% (50/51) 100.00% (13/13)
src/libraries/Position.sol 100.00% (19/19) 100.00% (21/21) 100.00% (3/3) 100.00% (3/3)
src/libraries/ProtocolFeeLibrary.sol 100.00% (10/10) 100.00% (10/10) 100.00% (0/0) 100.00% (4/4)
src/libraries/SafeCast.sol 100.00% (10/10) 100.00% (16/16) 100.00% (5/5) 100.00% (5/5)
src/libraries/SqrtPriceMath.sol 100.00% (49/49) 100.00% (64/64) 100.00% (12/12) 100.00% (9/9)
src/libraries/StateLibrary.sol 100.00% (63/63) 100.00% (87/87) 100.00% (4/4) 100.00% (14/14)
src/libraries/SwapMath.sol 100.00% (26/26) 100.00% (27/27) 100.00% (6/6) 100.00% (2/2)
src/libraries/TickBitmap.sol 100.00% (30/30) 100.00% (36/36) 100.00% (3/3) 100.00% (4/4)
src/libraries/TickMath.sol 100.00% (120/120) 100.00% (166/166) 100.00% (24/24) 100.00% (4/4)
src/libraries/TransientStateLibrary.sol 100.00% (10/10) 100.00% (13/13) 100.00% (0/0) 100.00% (5/5)
src/libraries/UnsafeMath.sol 100.00% (1/1) 100.00% (1/1) 100.00% (0/0) 100.00% (1/1)
src/types/BalanceDelta.sol 100.00% (2/2) 100.00% (2/2) 100.00% (0/0) 100.00% (2/2)
src/types/BeforeSwapDelta.sol 100.00% (2/2) 100.00% (2/2) 100.00% (0/0) 100.00% (2/2)
src/types/Currency.sol 100.00% (23/23) 96.88% (31/32) 100.00% (8/8) 100.00% (7/7)
src/types/PoolId.sol 100.00% (1/1) 100.00% (1/1) 100.00% (0/0) 100.00% (1/1)
src/types/Slot0.sol 100.00% (8/8) 100.00% (8/8) 100.00% (0/0) 100.00% (8/8)
Total 84.37% (1673/1983) 83.53% (2130/2550) 51.95% (333/641) 78.86% (373/473)
wjmelements commented 3 months ago

tested it with liquidityGrossBefore := and(0xffffffffffffffffffffffffffffffff, liquidity) and it was still the same gas

same. thanks for checking!

wjmelements commented 3 months ago

I think this PR is redundant after #827