Skip to content

Commit

Permalink
use snapLastCall
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun1on committed Jun 26, 2024
1 parent 8611713 commit eba30a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
24 changes: 8 additions & 16 deletions test/FullRange.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions test/Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions test/TWAMM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit eba30a5

Please sign in to comment.