From eba30a571bf27d9a1e99487ae06b09367fd8e050 Mon Sep 17 00:00:00 2001 From: Junion <69495294+Jun1on@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:27:52 -0400 Subject: [PATCH 1/4] use snapLastCall --- test/FullRange.t.sol | 24 ++++++++---------------- test/Oracle.t.sol | 3 +-- test/TWAMM.t.sol | 3 +-- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/test/FullRange.t.sol b/test/FullRange.t.sol index 5edec106..ffa36afb 100644 --- a/test/FullRange.t.sol +++ b/test/FullRange.t.sol @@ -128,9 +128,8 @@ contract TestFullRange is Test, Deployers, GasSnapshot { vm.expectEmit(true, true, true, true); emit Initialize(id, testKey.currency0, testKey.currency1, testKey.fee, testKey.tickSpacing, testKey.hooks); - snapStart("FullRangeInitialize"); manager.initialize(testKey, SQRT_PRICE_1_1, ZERO_BYTES); - snapEnd(); + snapLastCall("FullRangeInitialize"); (, address liquidityToken) = fullRange.poolInfo(id); @@ -154,9 +153,8 @@ contract TestFullRange is Test, Deployers, GasSnapshot { key.currency0, key.currency1, 3000, 10 ether, 10 ether, 9 ether, 9 ether, address(this), MAX_DEADLINE ); - snapStart("FullRangeAddInitialLiquidity"); fullRange.addLiquidity(addLiquidityParams); - snapEnd(); + snapLastCall("FullRangeAddInitialLiquidity"); (bool hasAccruedFees, address liquidityToken) = fullRange.poolInfo(id); uint256 liquidityTokenBal = UniswapV4ERC20(liquidityToken).balanceOf(address(this)); @@ -220,9 +218,8 @@ contract TestFullRange is Test, Deployers, GasSnapshot { MAX_DEADLINE ); - snapStart("FullRangeAddLiquidity"); fullRange.addLiquidity(addLiquidityParams); - snapEnd(); + snapLastCall("FullRangeAddLiquidity"); (bool hasAccruedFees,) = fullRange.poolInfo(idWithLiq); uint256 liquidityTokenBal = UniswapV4ERC20(liquidityToken).balanceOf(address(this)); @@ -275,9 +272,8 @@ contract TestFullRange is Test, Deployers, GasSnapshot { HookEnabledSwapRouter.TestSettings memory settings = HookEnabledSwapRouter.TestSettings({takeClaims: false, settleUsingBurn: false}); - snapStart("FullRangeSwap"); router.swap(key, params, settings, ZERO_BYTES); - snapEnd(); + snapLastCall("FullRangeSwap"); (bool hasAccruedFees,) = fullRange.poolInfo(id); @@ -338,16 +334,14 @@ contract TestFullRange is Test, Deployers, GasSnapshot { HookEnabledSwapRouter.TestSettings memory settings = HookEnabledSwapRouter.TestSettings({takeClaims: false, settleUsingBurn: false}); - snapStart("FullRangeFirstSwap"); router.swap(testKey, params, settings, ZERO_BYTES); - snapEnd(); + snapLastCall("FullRangeFirstSwap"); (bool hasAccruedFees,) = fullRange.poolInfo(id); assertEq(hasAccruedFees, true); - snapStart("FullRangeSecondSwap"); router.swap(testKey, params, settings, ZERO_BYTES); - snapEnd(); + snapLastCall("FullRangeSecondSwap"); (hasAccruedFees,) = fullRange.poolInfo(id); assertEq(hasAccruedFees, true); @@ -395,9 +389,8 @@ contract TestFullRange is Test, Deployers, GasSnapshot { FullRange.RemoveLiquidityParams memory removeLiquidityParams = FullRange.RemoveLiquidityParams(keyWithLiq.currency0, keyWithLiq.currency1, 3000, 1 ether, MAX_DEADLINE); - snapStart("FullRangeRemoveLiquidity"); fullRange.removeLiquidity(removeLiquidityParams); - snapEnd(); + snapLastCall("FullRangeRemoveLiquidity"); (bool hasAccruedFees,) = fullRange.poolInfo(idWithLiq); uint256 liquidityTokenBal = UniswapV4ERC20(liquidityToken).balanceOf(address(this)); @@ -564,9 +557,8 @@ contract TestFullRange is Test, Deployers, GasSnapshot { FullRange.RemoveLiquidityParams memory removeLiquidityParams = FullRange.RemoveLiquidityParams(keyWithLiq.currency0, keyWithLiq.currency1, 3000, 5 ether, MAX_DEADLINE); - snapStart("FullRangeRemoveLiquidityAndRebalance"); fullRange.removeLiquidity(removeLiquidityParams); - snapEnd(); + snapLastCall("FullRangeRemoveLiquidityAndRebalance"); (bool hasAccruedFees,) = fullRange.poolInfo(idWithLiq); assertEq(hasAccruedFees, false); diff --git a/test/Oracle.t.sol b/test/Oracle.t.sol index 04157e16..cc465a02 100644 --- a/test/Oracle.t.sol +++ b/test/Oracle.t.sol @@ -17,9 +17,8 @@ contract TestOracle is Test, GasSnapshot { } function testInitialize() public { - snapStart("OracleInitialize"); oracle.initialize(OracleImplementation.InitializeParams({time: 1, tick: 1, liquidity: 1})); - snapEnd(); + snapLastCall("OracleInitialize"); assertEq(oracle.index(), 0); assertEq(oracle.cardinality(), 1); diff --git a/test/TWAMM.t.sol b/test/TWAMM.t.sol index 0f2f82e0..9525025c 100644 --- a/test/TWAMM.t.sol +++ b/test/TWAMM.t.sol @@ -110,9 +110,8 @@ contract TWAMMTest is Test, Deployers, GasSnapshot { vm.warp(10000); token0.approve(address(twamm), 100 ether); - snapStart("TWAMMSubmitOrder"); twamm.submitOrder(poolKey, orderKey, 1 ether); - snapEnd(); + snapLastCall("TWAMMSubmitOrder"); ITWAMM.Order memory submittedOrder = twamm.getOrder(poolKey, orderKey); (uint256 sellRateCurrent0For1, uint256 earningsFactorCurrent0For1) = twamm.getOrderPool(poolKey, true); From 9143f18466819e9479b5e3e8b76edeea9ff995db Mon Sep 17 00:00:00 2001 From: Junion <69495294+Jun1on@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:32:42 -0400 Subject: [PATCH 2/4] forge test --isolate --- .forge-snapshots/FullRangeAddInitialLiquidity.snap | 2 +- .forge-snapshots/FullRangeAddLiquidity.snap | 2 +- .forge-snapshots/FullRangeFirstSwap.snap | 2 +- .forge-snapshots/FullRangeInitialize.snap | 2 +- .forge-snapshots/FullRangeRemoveLiquidity.snap | 2 +- .forge-snapshots/FullRangeRemoveLiquidityAndRebalance.snap | 2 +- .forge-snapshots/FullRangeSecondSwap.snap | 2 +- .forge-snapshots/FullRangeSwap.snap | 2 +- .forge-snapshots/OracleGrow10Slots.snap | 2 +- .forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap | 2 +- .forge-snapshots/OracleGrow1Slot.snap | 2 +- .forge-snapshots/OracleGrow1SlotCardinalityGreater.snap | 2 +- .forge-snapshots/OracleInitialize.snap | 2 +- .forge-snapshots/TWAMMSubmitOrder.snap | 2 +- lib/forge-gas-snapshot | 2 +- lib/forge-std | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.forge-snapshots/FullRangeAddInitialLiquidity.snap b/.forge-snapshots/FullRangeAddInitialLiquidity.snap index 404cf12a..11b50b48 100644 --- a/.forge-snapshots/FullRangeAddInitialLiquidity.snap +++ b/.forge-snapshots/FullRangeAddInitialLiquidity.snap @@ -1 +1 @@ -311181 \ No newline at end of file +351599 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeAddLiquidity.snap b/.forge-snapshots/FullRangeAddLiquidity.snap index a4a14676..57bb2528 100644 --- a/.forge-snapshots/FullRangeAddLiquidity.snap +++ b/.forge-snapshots/FullRangeAddLiquidity.snap @@ -1 +1 @@ -122990 \ No newline at end of file +160908 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeFirstSwap.snap b/.forge-snapshots/FullRangeFirstSwap.snap index da120795..adbd3641 100644 --- a/.forge-snapshots/FullRangeFirstSwap.snap +++ b/.forge-snapshots/FullRangeFirstSwap.snap @@ -1 +1 @@ -80220 \ No newline at end of file +140744 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeInitialize.snap b/.forge-snapshots/FullRangeInitialize.snap index 7a0170eb..0cc24bab 100644 --- a/.forge-snapshots/FullRangeInitialize.snap +++ b/.forge-snapshots/FullRangeInitialize.snap @@ -1 +1 @@ -1015181 \ No newline at end of file +1032313 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeRemoveLiquidity.snap b/.forge-snapshots/FullRangeRemoveLiquidity.snap index feea4936..f8dbe13d 100644 --- a/.forge-snapshots/FullRangeRemoveLiquidity.snap +++ b/.forge-snapshots/FullRangeRemoveLiquidity.snap @@ -1 +1 @@ -110566 \ No newline at end of file +145773 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeRemoveLiquidityAndRebalance.snap b/.forge-snapshots/FullRangeRemoveLiquidityAndRebalance.snap index e0df7eb7..7c72c23e 100644 --- a/.forge-snapshots/FullRangeRemoveLiquidityAndRebalance.snap +++ b/.forge-snapshots/FullRangeRemoveLiquidityAndRebalance.snap @@ -1 +1 @@ -240044 \ No newline at end of file +281063 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeSecondSwap.snap b/.forge-snapshots/FullRangeSecondSwap.snap index e68df8d3..57992011 100644 --- a/.forge-snapshots/FullRangeSecondSwap.snap +++ b/.forge-snapshots/FullRangeSecondSwap.snap @@ -1 +1 @@ -45930 \ No newline at end of file +114959 \ No newline at end of file diff --git a/.forge-snapshots/FullRangeSwap.snap b/.forge-snapshots/FullRangeSwap.snap index b50d0ea2..f2e4301d 100644 --- a/.forge-snapshots/FullRangeSwap.snap +++ b/.forge-snapshots/FullRangeSwap.snap @@ -1 +1 @@ -79351 \ No newline at end of file +141889 \ No newline at end of file diff --git a/.forge-snapshots/OracleGrow10Slots.snap b/.forge-snapshots/OracleGrow10Slots.snap index 3dada479..96c9f369 100644 --- a/.forge-snapshots/OracleGrow10Slots.snap +++ b/.forge-snapshots/OracleGrow10Slots.snap @@ -1 +1 @@ -232960 \ No newline at end of file +254164 \ No newline at end of file diff --git a/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap b/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap index f623cfa5..9fc5bce2 100644 --- a/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap +++ b/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap @@ -1 +1 @@ -223649 \ No newline at end of file +249653 \ No newline at end of file diff --git a/.forge-snapshots/OracleGrow1Slot.snap b/.forge-snapshots/OracleGrow1Slot.snap index 137baa16..ced15d76 100644 --- a/.forge-snapshots/OracleGrow1Slot.snap +++ b/.forge-snapshots/OracleGrow1Slot.snap @@ -1 +1 @@ -32845 \ No newline at end of file +54049 \ No newline at end of file diff --git a/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap b/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap index e6dc42ce..8ad5646e 100644 --- a/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap +++ b/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap @@ -1 +1 @@ -23545 \ No newline at end of file +49549 \ No newline at end of file diff --git a/.forge-snapshots/OracleInitialize.snap b/.forge-snapshots/OracleInitialize.snap index e4e9e6b2..df407db4 100644 --- a/.forge-snapshots/OracleInitialize.snap +++ b/.forge-snapshots/OracleInitialize.snap @@ -1 +1 @@ -51310 \ No newline at end of file +67610 \ No newline at end of file diff --git a/.forge-snapshots/TWAMMSubmitOrder.snap b/.forge-snapshots/TWAMMSubmitOrder.snap index eb3b0f6b..2437153b 100644 --- a/.forge-snapshots/TWAMMSubmitOrder.snap +++ b/.forge-snapshots/TWAMMSubmitOrder.snap @@ -1 +1 @@ -122336 \ No newline at end of file +155811 \ No newline at end of file diff --git a/lib/forge-gas-snapshot b/lib/forge-gas-snapshot index 2f884282..9161f7c0 160000 --- a/lib/forge-gas-snapshot +++ b/lib/forge-gas-snapshot @@ -1 +1 @@ -Subproject commit 2f884282b4cd067298e798974f5b534288b13bc2 +Subproject commit 9161f7c0b6c6788a89081e2b3b9c67592b71e689 diff --git a/lib/forge-std b/lib/forge-std index 2b58ecbc..75b3fcf0 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 2b58ecbcf3dfde7a75959dc7b4eb3d0670278de6 +Subproject commit 75b3fcf052cc7886327e4c2eac3d1a1f36942b41 From 261688ebc110e6ac5c4e0a459bbc0ff56d9ebf83 Mon Sep 17 00:00:00 2001 From: Junion <69495294+Jun1on@users.noreply.github.com> Date: Sun, 30 Jun 2024 22:46:47 -0400 Subject: [PATCH 3/4] snapLastCall to all --- .forge-snapshots/OracleGrow10Slots.snap | 2 +- .../OracleGrow10SlotsCardinalityGreater.snap | 2 +- .forge-snapshots/OracleGrow1Slot.snap | 2 +- .../OracleGrow1SlotCardinalityGreater.snap | 2 +- test/Oracle.t.sol | 12 ++++-------- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.forge-snapshots/OracleGrow10Slots.snap b/.forge-snapshots/OracleGrow10Slots.snap index 96c9f369..2964e534 100644 --- a/.forge-snapshots/OracleGrow10Slots.snap +++ b/.forge-snapshots/OracleGrow10Slots.snap @@ -1 +1 @@ -254164 \ No newline at end of file +249167 \ No newline at end of file diff --git a/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap b/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap index 9fc5bce2..2964e534 100644 --- a/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap +++ b/.forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap @@ -1 +1 @@ -249653 \ No newline at end of file +249167 \ No newline at end of file diff --git a/.forge-snapshots/OracleGrow1Slot.snap b/.forge-snapshots/OracleGrow1Slot.snap index ced15d76..aa66d075 100644 --- a/.forge-snapshots/OracleGrow1Slot.snap +++ b/.forge-snapshots/OracleGrow1Slot.snap @@ -1 +1 @@ -54049 \ No newline at end of file +49052 \ No newline at end of file diff --git a/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap b/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap index 8ad5646e..aa66d075 100644 --- a/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap +++ b/.forge-snapshots/OracleGrow1SlotCardinalityGreater.snap @@ -1 +1 @@ -49549 \ No newline at end of file +49052 \ No newline at end of file diff --git a/test/Oracle.t.sol b/test/Oracle.t.sol index cc465a02..4b8f714c 100644 --- a/test/Oracle.t.sol +++ b/test/Oracle.t.sol @@ -89,29 +89,25 @@ contract TestOracle is Test, GasSnapshot { } function testGas1Slot() public { - snapStart("OracleGrow1Slot"); initializedOracle.grow(2); - snapEnd(); + snapLastCall("OracleGrow1Slot"); } function testGas10Slots() public { - snapStart("OracleGrow10Slots"); initializedOracle.grow(11); - snapEnd(); + snapLastCall("OracleGrow10Slots"); } function testGas1SlotCardinalityGreater() public { initializedOracle.grow(2); - snapStart("OracleGrow1SlotCardinalityGreater"); initializedOracle.grow(3); - snapEnd(); + snapLastCall("OracleGrow1SlotCardinalityGreater"); } function testGas10SlotCardinalityGreater() public { initializedOracle.grow(2); - snapStart("OracleGrow10SlotsCardinalityGreater"); initializedOracle.grow(12); - snapEnd(); + snapLastCall("OracleGrow10SlotsCardinalityGreater"); } function testWrite() public { From 5ade0655aab9fd5834fcb2963c1a5f8a03d1ec2c Mon Sep 17 00:00:00 2001 From: Junion <69495294+Jun1on@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:52:01 -0400 Subject: [PATCH 4/4] update foundry.toml --- foundry.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/foundry.toml b/foundry.toml index 4e95a213..b7851680 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,13 +1,14 @@ [profile.default] -src = 'contracts' out = 'foundry-out' -solc_version = '0.8.24' +solc_version = '0.8.26' optimizer_runs = 1000000 ffi = true fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}] evm_version = "cancun" +gas_limit = "3000000000" +fuzz_runs = 10000 [profile.ci] fuzz_runs = 100000 -# See more config options https://github.com/foundry-rs/foundry/tree/master/config +# See more config options https://github.com/foundry-rs/foundry/tree/master/config \ No newline at end of file