diff --git a/.forge-snapshots/Quoter_exactInputSingle_oneForZero_multiplePositions.snap b/.forge-snapshots/Quoter_exactInputSingle_oneForZero_multiplePositions.snap new file mode 100644 index 00000000..9d62d41d --- /dev/null +++ b/.forge-snapshots/Quoter_exactInputSingle_oneForZero_multiplePositions.snap @@ -0,0 +1 @@ +149027 \ 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..31001264 --- /dev/null +++ b/.forge-snapshots/Quoter_exactInputSingle_zeroForOne_multiplePositions.snap @@ -0,0 +1 @@ +154511 \ 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..5a1e35c6 --- /dev/null +++ b/.forge-snapshots/Quoter_exactOutputSingle_oneForZero.snap @@ -0,0 +1 @@ +83641 \ 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..b9c835ee --- /dev/null +++ b/.forge-snapshots/Quoter_exactOutputSingle_zeroForOne.snap @@ -0,0 +1 @@ +88449 \ 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..39da693d --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactInput_oneHop_1TickLoaded.snap @@ -0,0 +1 @@ +128559 \ 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..efb45ba3 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactInput_oneHop_initializedAfter.snap @@ -0,0 +1 @@ +153480 \ 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..5281d2e2 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactInput_oneHop_startingInitialized.snap @@ -0,0 +1 @@ +87503 \ 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..d8a20ee9 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactInput_twoHops.snap @@ -0,0 +1 @@ +212546 \ 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..43a31e7c --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_1TickLoaded.snap @@ -0,0 +1 @@ +148306 \ 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..8ba91a98 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_2TicksLoaded.snap @@ -0,0 +1 @@ +178443 \ 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..31ecb056 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_initializedAfter.snap @@ -0,0 +1 @@ +148374 \ 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..d8993e48 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_oneHop_startingInitialized.snap @@ -0,0 +1 @@ +125073 \ 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..238bcf31 --- /dev/null +++ b/.forge-snapshots/Quoter_quoteExactOutput_twoHops.snap @@ -0,0 +1 @@ +252910 \ No newline at end of file diff --git a/test/Quoter.t.sol b/test/Quoter.t.sol index 074ea99d..86b57181 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; @@ -93,6 +94,7 @@ contract QuoterTest is Test, Deployers { hookData: ZERO_BYTES }) ); + snapLastCall("Quoter_exactInputSingle_zeroForOne_multiplePositions"); assertEq(uint128(-deltaAmounts[1]), expectedAmountOut); assertEq(sqrtPriceX96After, expectedSqrtPriceX96After); @@ -112,6 +114,7 @@ contract QuoterTest is Test, Deployers { hookData: ZERO_BYTES }) ); + snapLastCall("Quoter_exactInputSingle_oneForZero_multiplePositions"); assertEq(uint128(-deltaAmounts[0]), expectedAmountOut); assertEq(sqrtPriceX96After, expectedSqrtPriceX96After); @@ -135,7 +138,7 @@ contract QuoterTest is Test, Deployers { assertEq(sqrtPriceX96AfterList[0], 78461846509168490764501028180); } - function testQuoter_quoteExactInput_0to2_2TicksLoaded_initialiedAfter() public { + function testQuoter_quoteExactInput_0to2_2TicksLoaded_initializedAfter() public { tokenPath.push(token0); tokenPath.push(token2); @@ -159,6 +162,8 @@ contract QuoterTest is Test, Deployers { (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactInput(params); + snapLastCall("Quoter_quoteExactInput_oneHop_1TickLoaded"); + assertEq(uint128(-deltaAmounts[1]), 3971); assertEq(sqrtPriceX96AfterList[0], 78926452400586371254602774705); } @@ -197,7 +202,7 @@ contract QuoterTest is Test, Deployers { assertEq(sqrtPriceX96AfterList[0], 80001962924147897865541384515); } - function testQuoter_quoteExactInput_2to0_2TicksLoaded_initialiedAfter() public { + function testQuoter_quoteExactInput_2to0_2TicksLoaded_initializedAfter() public { tokenPath.push(token2); tokenPath.push(token0); @@ -207,6 +212,8 @@ contract QuoterTest is Test, Deployers { (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactInput(params); + snapLastCall("Quoter_quoteExactInput_oneHop_initializedAfter"); + assertEq(-deltaAmounts[1], 6190); assertEq(sqrtPriceX96AfterList[0], 79705728824507063507279123685); } @@ -220,6 +227,8 @@ contract QuoterTest is Test, Deployers { // Tick 0 initialized. Tick after = 1 (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactInput(params); + snapLastCall("Quoter_quoteExactInput_oneHop_startingInitialized"); + assertEq(-deltaAmounts[1], 198); assertEq(sqrtPriceX96AfterList[0], 79235729830182478001034429156); } @@ -254,6 +263,8 @@ contract QuoterTest is Test, Deployers { (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactInput(params); + snapLastCall("Quoter_quoteExactInput_twoHops"); + assertEq(-deltaAmounts[2], 9745); assertEq(sqrtPriceX96AfterList[0], 78461846509168490764501028180); assertEq(sqrtPriceX96AfterList[1], 80007846861567212939802016351); @@ -269,6 +280,7 @@ contract QuoterTest is Test, Deployers { hookData: ZERO_BYTES }) ); + snapLastCall("Quoter_exactOutputSingle_zeroForOne"); assertEq(deltaAmounts[0], 9981); assertEq(sqrtPriceX96After, SQRT_PRICE_100_102); @@ -284,6 +296,7 @@ contract QuoterTest is Test, Deployers { hookData: ZERO_BYTES }) ); + snapLastCall("Quoter_exactOutputSingle_oneForZero"); assertEq(deltaAmounts[1], 9981); assertEq(sqrtPriceX96After, SQRT_PRICE_102_100); @@ -296,17 +309,20 @@ contract QuoterTest is Test, Deployers { (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_oneHop_2TicksLoaded"); + assertEq(deltaAmounts[0], 15273); assertEq(sqrtPriceX96AfterList[0], 78055527257643669242286029831); } - function testQuoter_quoteExactOutput_0to2_1TickLoaded_initialiedAfter() public { + function testQuoter_quoteExactOutput_0to2_1TickLoaded_initializedAfter() public { tokenPath.push(token0); tokenPath.push(token2); IQuoter.QuoteExactParams memory params = getExactOutputParams(tokenPath, 6143); (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_oneHop_initializedAfter"); assertEq(deltaAmounts[0], 6200); assertEq(sqrtPriceX96AfterList[0], 78757225449310403327341205211); @@ -319,6 +335,7 @@ contract QuoterTest is Test, Deployers { IQuoter.QuoteExactParams memory params = getExactOutputParams(tokenPath, 4000); (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_oneHop_1TickLoaded"); assertEq(deltaAmounts[0], 4029); assertEq(sqrtPriceX96AfterList[0], 78924219757724709840818372098); @@ -333,6 +350,7 @@ contract QuoterTest is Test, Deployers { // Tick 0 initialized. Tick after = 1 (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_oneHop_startingInitialized"); assertEq(deltaAmounts[0], 102); assertEq(sqrtPriceX96AfterList[0], 79224329176051641448521403903); @@ -361,7 +379,7 @@ contract QuoterTest is Test, Deployers { assertEq(sqrtPriceX96AfterList[0], 80418414376567919517220409857); } - function testQuoter_quoteExactOutput_2to0_2TicksLoaded_initialiedAfter() public { + function testQuoter_quoteExactOutput_2to0_2TicksLoaded_initializedAfter() public { tokenPath.push(token2); tokenPath.push(token0); @@ -405,6 +423,8 @@ contract QuoterTest is Test, Deployers { (int128[] memory deltaAmounts, uint160[] memory sqrtPriceX96AfterList) = quoter.quoteExactOutput(params); + snapLastCall("Quoter_quoteExactOutput_twoHops"); + assertEq(deltaAmounts[0], 10000); assertEq(deltaAmounts[1], 0); assertEq(deltaAmounts[2], -9745);