Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
snreynolds committed Jul 11, 2024
1 parent 40d0329 commit 5151496
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions test/position-managers/IncreaseLiquidity.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ contract IncreaseLiquidityTest is Test, Deployers, GasSnapshot, Fuzzers, Liquidi
range = LiquidityRange({poolKey: key, tickLower: -300, tickUpper: 300});
}

function test_increaseLiquidity_withExactFees1() public {
function test_increaseLiquidity_withExactFees() public {
// Alice and Bob provide liquidity on the range
// Alice uses her exact fees to increase liquidity (compounding)

Expand Down Expand Up @@ -324,7 +324,7 @@ contract IncreaseLiquidityTest is Test, Deployers, GasSnapshot, Fuzzers, Liquidi
}
}

function test_increaseLiquidity_withExactFees_withExactCachedFees1() public {
function test_increaseLiquidity_withExactFees_withExactCachedFees() public {
// Alice and Bob provide liquidity on the range
// Alice uses her fees to increase liquidity. Both unclaimed fees and cached fees are used to exactly increase the liquidity
uint256 liquidityAlice = 3_000e18;
Expand Down Expand Up @@ -353,42 +353,42 @@ contract IncreaseLiquidityTest is Test, Deployers, GasSnapshot, Fuzzers, Liquidi
vm.startPrank(bob);
_collect(tokenIdBob, bob, ZERO_BYTES, false);
vm.stopPrank();
//swap to create more fees
// swap(key, true, -int256(swapAmount), ZERO_BYTES);
// swap(key, false, -int256(swapAmount), ZERO_BYTES); // move the price back

// (uint256 newToken0Owed, uint256 newToken1Owed) = lpm.feesOwed(tokenIdAlice);
// // alice's fees should be doubled
// assertApproxEqAbs(newToken0Owed, token0Owed * 2, 2 wei);
// assertApproxEqAbs(newToken1Owed, token1Owed * 2, 2 wei);

// uint256 balance0AliceBefore = currency0.balanceOf(alice);
// uint256 balance1AliceBefore = currency1.balanceOf(alice);

// // alice will use ALL of her fees to increase liquidity
// {
// (uint160 sqrtPriceX96,,,) = StateLibrary.getSlot0(manager, range.poolKey.toId());
// uint256 liquidityDelta = LiquidityAmounts.getLiquidityForAmounts(
// sqrtPriceX96,
// TickMath.getSqrtPriceAtTick(range.tickLower),
// TickMath.getSqrtPriceAtTick(range.tickUpper),
// newToken0Owed,
// newToken1Owed
// );

// vm.startPrank(alice);
// _increaseLiquidity(tokenIdAlice, liquidityDelta, ZERO_BYTES, false);
// vm.stopPrank();
// }

// // alice did not spend any tokens
// assertEq(balance0AliceBefore, currency0.balanceOf(alice));
// assertEq(balance1AliceBefore, currency1.balanceOf(alice));

// // some dust was credited to alice's tokensOwed
// (token0Owed, token1Owed) = lpm.feesOwed(tokenIdAlice);
// assertApproxEqAbs(token0Owed, 0, 80 wei);
// assertApproxEqAbs(token1Owed, 0, 80 wei);
// swap to create more fees
swap(key, true, -int256(swapAmount), ZERO_BYTES);
swap(key, false, -int256(swapAmount), ZERO_BYTES); // move the price back

(uint256 newToken0Owed, uint256 newToken1Owed) = lpm.feesOwed(tokenIdAlice);
// alice's fees should be doubled
assertApproxEqAbs(newToken0Owed, token0Owed * 2, 2 wei);
assertApproxEqAbs(newToken1Owed, token1Owed * 2, 2 wei);

uint256 balance0AliceBefore = currency0.balanceOf(alice);
uint256 balance1AliceBefore = currency1.balanceOf(alice);

// alice will use ALL of her fees to increase liquidity
{
(uint160 sqrtPriceX96,,,) = StateLibrary.getSlot0(manager, range.poolKey.toId());
uint256 liquidityDelta = LiquidityAmounts.getLiquidityForAmounts(
sqrtPriceX96,
TickMath.getSqrtPriceAtTick(range.tickLower),
TickMath.getSqrtPriceAtTick(range.tickUpper),
newToken0Owed,
newToken1Owed
);

vm.startPrank(alice);
_increaseLiquidity(tokenIdAlice, liquidityDelta, ZERO_BYTES, false);
vm.stopPrank();
}

// alice did not spend any tokens
assertEq(balance0AliceBefore, currency0.balanceOf(alice));
assertEq(balance1AliceBefore, currency1.balanceOf(alice));

// some dust was credited to alice's tokensOwed
(token0Owed, token1Owed) = lpm.feesOwed(tokenIdAlice);
assertApproxEqAbs(token0Owed, 0, 80 wei);
assertApproxEqAbs(token1Owed, 0, 80 wei);
}

// uses donate to simulate fee revenue
Expand Down

0 comments on commit 5151496

Please sign in to comment.