diff --git a/.forge-snapshots/Quoter_exactInputSingle_oneForZero_multiplePositions.snap b/.forge-snapshots/Quoter_exactInputSingle_oneForZero_multiplePositions.snap new file mode 100644 index 00000000..0c97c362 --- /dev/null +++ b/.forge-snapshots/Quoter_exactInputSingle_oneForZero_multiplePositions.snap @@ -0,0 +1 @@ +159043 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_exactInputSingle_zeroForOne_multiplePositions.snap b/.forge-snapshots/Quoter_exactInputSingle_zeroForOne_multiplePositions.snap new file mode 100644 index 00000000..af5fa0fa --- /dev/null +++ b/.forge-snapshots/Quoter_exactInputSingle_zeroForOne_multiplePositions.snap @@ -0,0 +1 @@ +166396 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_exactOutputSingle_oneForZero.snap b/.forge-snapshots/Quoter_exactOutputSingle_oneForZero.snap new file mode 100644 index 00000000..f43e9458 --- /dev/null +++ b/.forge-snapshots/Quoter_exactOutputSingle_oneForZero.snap @@ -0,0 +1 @@ +93637 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_exactOutputSingle_zeroForOne.snap b/.forge-snapshots/Quoter_exactOutputSingle_zeroForOne.snap new file mode 100644 index 00000000..66a68794 --- /dev/null +++ b/.forge-snapshots/Quoter_exactOutputSingle_zeroForOne.snap @@ -0,0 +1 @@ +100303 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactInput_oneHop_1TickLoaded.snap b/.forge-snapshots/Quoter_quoteExactInput_oneHop_1TickLoaded.snap new file mode 100644 index 00000000..87d96db1 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactInput_oneHop_1TickLoaded.snap @@ -0,0 +1 @@ +141321 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactInput_oneHop_initializedAfter.snap b/.forge-snapshots/Quoter_quoteExactInput_oneHop_initializedAfter.snap new file mode 100644 index 00000000..3315258e --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactInput_oneHop_initializedAfter.snap @@ -0,0 +1 @@ +164528 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactInput_oneHop_startingInitialized.snap b/.forge-snapshots/Quoter_quoteExactInput_oneHop_startingInitialized.snap new file mode 100644 index 00000000..954792b6 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactInput_oneHop_startingInitialized.snap @@ -0,0 +1 @@ +98641 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactInput_twoHops.snap b/.forge-snapshots/Quoter_quoteExactInput_twoHops.snap new file mode 100644 index 00000000..b8ed8de2 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactInput_twoHops.snap @@ -0,0 +1 @@ +234806 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactOutput_oneHop_1TickLoaded.snap b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_1TickLoaded.snap new file mode 100644 index 00000000..8a6db3df --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_1TickLoaded.snap @@ -0,0 +1 @@ +161346 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactOutput_oneHop_2TicksLoaded.snap b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_2TicksLoaded.snap new file mode 100644 index 00000000..7391d6be --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_2TicksLoaded.snap @@ -0,0 +1 @@ +191453 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactOutput_oneHop_initializedAfter.snap b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_initializedAfter.snap new file mode 100644 index 00000000..cc4af5c5 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_initializedAfter.snap @@ -0,0 +1 @@ +161661 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactOutput_oneHop_startingInitialized.snap b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_startingInitialized.snap new file mode 100644 index 00000000..5aed9cf8 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_startingInitialized.snap @@ -0,0 +1 @@ +136430 \ No newline at end of file diff --git a/.forge-snapshots/Quoter_quoteExactOutput_twoHops.snap b/.forge-snapshots/Quoter_quoteExactOutput_twoHops.snap new file mode 100644 index 00000000..da4bedcf --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_twoHops.snap @@ -0,0 +1 @@ +275720 \ No newline at end of file diff --git a/test/Quoter.t.sol b/test/Quoter.t.sol index b01d9c88..dbe7eeb0 100644 --- a/test/Quoter.t.sol +++ b/test/Quoter.t.sol @@ -6,6 +6,7 @@ import {Test} from "forge-std/Test.sol"; import {PathKey} from "../src/libraries/PathKey.sol"; import {IQuoter} from "../src/interfaces/IQuoter.sol"; import {Quoter} from "../src/lens/Quoter.sol"; +import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol"; // v4-core import {LiquidityAmounts} from "@uniswap/v4-core/test/utils/LiquidityAmounts.sol"; @@ -23,7 +24,7 @@ import {StateLibrary} from "@uniswap/v4-core/src/libraries/StateLibrary.sol"; // solmate import {MockERC20} from "solmate/src/test/utils/mocks/MockERC20.sol"; -contract QuoterTest is Test, Deployers { +contract QuoterTest is Test, Deployers, GasSnapshot { using SafeCast for *; using PoolIdLibrary for PoolKey; using StateLibrary for IPoolManager; @@ -94,6 +95,7 @@ contract QuoterTest is Test, Deployers { hookData: ZERO_BYTES }) ); + snapLastCall("Quoter_exactInputSingle_zeroForOne_multiplePositions"); assertEq(uint128(-deltaAmounts[1]), expectedAmountOut); assertEq(sqrtPriceX96After, expectedSqrtPriceX96After); @@ -115,6 +117,7 @@ contract QuoterTest is Test, Deployers { hookData: ZERO_BYTES }) ); + snapLastCall("Quoter_exactInputSingle_oneForZero_multiplePositions"); assertEq(uint128(-deltaAmounts[0]), expectedAmountOut); assertEq(sqrtPriceX96After, expectedSqrtPriceX96After); @@ -144,7 +147,7 @@ contract QuoterTest is Test, Deployers { assertEq(initializedTicksLoadedList[0], 2); } - function testQuoter_quoteExactInput_0to2_2TicksLoaded_initialiedAfter() public { + function testQuoter_quoteExactInput_0to2_2TicksLoaded_initializedAfter() public { tokenPath.push(token0); tokenPath.push(token2); @@ -177,6 +180,8 @@ contract QuoterTest is Test, Deployers { uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactInput(params); + snapLastCall("Quoter_quoteExactInput_oneHop_1TickLoaded"); + assertEq(uint128(-deltaAmounts[1]), 3971); assertEq(sqrtPriceX96AfterList[0], 78926452400586371254602774705); assertEq(initializedTicksLoadedList[0], 1); @@ -231,7 +236,7 @@ contract QuoterTest is Test, Deployers { assertEq(initializedTicksLoadedList[0], 2); } - function testQuoter_quoteExactInput_2to0_2TicksLoaded_initialiedAfter() public { + function testQuoter_quoteExactInput_2to0_2TicksLoaded_initializedAfter() public { tokenPath.push(token2); tokenPath.push(token0); @@ -245,6 +250,8 @@ contract QuoterTest is Test, Deployers { uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactInput(params); + snapLastCall("Quoter_quoteExactInput_oneHop_initializedAfter"); + assertEq(-deltaAmounts[1], 6190); assertEq(sqrtPriceX96AfterList[0], 79705728824507063507279123685); assertEq(initializedTicksLoadedList[0], 2); @@ -263,6 +270,8 @@ contract QuoterTest is Test, Deployers { uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactInput(params); + snapLastCall("Quoter_quoteExactInput_oneHop_startingInitialized"); + assertEq(-deltaAmounts[1], 198); assertEq(sqrtPriceX96AfterList[0], 79235729830182478001034429156); assertEq(initializedTicksLoadedList[0], 0); @@ -312,6 +321,8 @@ contract QuoterTest is Test, Deployers { uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactInput(params); + snapLastCall("Quoter_quoteExactInput_twoHops"); + assertEq(-deltaAmounts[2], 9745); assertEq(sqrtPriceX96AfterList[0], 78461846509168490764501028180); assertEq(sqrtPriceX96AfterList[1], 80007846861567212939802016351); @@ -330,6 +341,7 @@ contract QuoterTest is Test, Deployers { hookData: ZERO_BYTES }) ); + snapLastCall("Quoter_exactOutputSingle_zeroForOne"); assertEq(deltaAmounts[0], 9981); assertEq(sqrtPriceX96After, SQRT_PRICE_100_102); @@ -347,6 +359,7 @@ contract QuoterTest is Test, Deployers { hookData: ZERO_BYTES }) ); + snapLastCall("Quoter_exactOutputSingle_oneForZero"); assertEq(deltaAmounts[1], 9981); assertEq(sqrtPriceX96After, SQRT_PRICE_102_100); @@ -364,12 +377,14 @@ contract QuoterTest is Test, Deployers { uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_oneHop_2TicksLoaded"); + assertEq(deltaAmounts[0], 15273); assertEq(sqrtPriceX96AfterList[0], 78055527257643669242286029831); assertEq(initializedTicksLoadedList[0], 2); } - function testQuoter_quoteExactOutput_0to2_1TickLoaded_initialiedAfter() public { + function testQuoter_quoteExactOutput_0to2_1TickLoaded_initializedAfter() public { tokenPath.push(token0); tokenPath.push(token2); @@ -380,6 +395,7 @@ contract QuoterTest is Test, Deployers { uint160[] memory sqrtPriceX96AfterList, uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_oneHop_initializedAfter"); assertEq(deltaAmounts[0], 6200); assertEq(sqrtPriceX96AfterList[0], 78757225449310403327341205211); @@ -397,6 +413,7 @@ contract QuoterTest is Test, Deployers { uint160[] memory sqrtPriceX96AfterList, uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_oneHop_1TickLoaded"); assertEq(deltaAmounts[0], 4029); assertEq(sqrtPriceX96AfterList[0], 78924219757724709840818372098); @@ -416,6 +433,7 @@ contract QuoterTest is Test, Deployers { uint160[] memory sqrtPriceX96AfterList, uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_oneHop_startingInitialized"); assertEq(deltaAmounts[0], 102); assertEq(sqrtPriceX96AfterList[0], 79224329176051641448521403903); @@ -456,7 +474,7 @@ contract QuoterTest is Test, Deployers { assertEq(initializedTicksLoadedList[0], 2); } - function testQuoter_quoteExactOutput_2to0_2TicksLoaded_initialiedAfter() public { + function testQuoter_quoteExactOutput_2to0_2TicksLoaded_initializedAfter() public { tokenPath.push(token2); tokenPath.push(token0); @@ -522,6 +540,8 @@ contract QuoterTest is Test, Deployers { uint32[] memory initializedTicksLoadedList ) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_twoHops"); + assertEq(deltaAmounts[0], 10000); assertEq(deltaAmounts[1], 0); assertEq(deltaAmounts[2], -9745);