Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed Jun 25, 2024
1 parent 7e49d96 commit dd25730
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeAddInitialLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
311181
354477
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeAddLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
122990
161786
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeFirstSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
80220
146400
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeInitialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1016976
1039616
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeRemoveLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
110566
146394
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeRemoveLiquidityAndRebalance.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
240044
281672
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeSecondSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
45930
116110
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
79351
145819
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleGrow10Slots.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
232960
254164
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleGrow10SlotsCardinalityGreater.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
223649
249653
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleGrow1Slot.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
32845
54049
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleGrow1SlotCardinalityGreater.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23545
49549
2 changes: 1 addition & 1 deletion .forge-snapshots/OracleInitialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
51310
72794
2 changes: 1 addition & 1 deletion .forge-snapshots/TWAMMSubmitOrder.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
122336
156828
2 changes: 1 addition & 1 deletion .forge-snapshots/decreaseLiquidity_erc20.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
119430
190044
2 changes: 1 addition & 1 deletion .forge-snapshots/decreaseLiquidity_erc6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
117181
168894
2 changes: 1 addition & 1 deletion .forge-snapshots/increaseLiquidity_erc20.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60600
173212
2 changes: 1 addition & 1 deletion .forge-snapshots/increaseLiquidity_erc6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
64370
148794
2 changes: 1 addition & 1 deletion .forge-snapshots/mintWithLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
444617
468501
6 changes: 6 additions & 0 deletions contracts/base/BaseLiquidityManagement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ contract BaseLiquidityManagement is IBaseLiquidityManagement, SafeCallback {
position.liquidity
);

console2.log(callerFeesAccrued.amount0());
console2.log(callerFeesAccrued.amount1());
console2.log("totalFees");
console2.log(totalFeesAccrued.amount0());
console2.log(totalFeesAccrued.amount1());

// Calculate the accurate tokens owed to the caller.
// If the totalFeesAccrued equals the callerFeesAccrued then the total owed to the caller is just the liquidityDelta.
// If the totalFeesAccrued is greater than the callerFeesAccrued, we must account for the difference.
Expand Down
15 changes: 12 additions & 3 deletions test/position-managers/IncreaseLiquidity.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ contract IncreaseLiquidityTest is Test, Deployers, GasSnapshot, Fuzzers {
(uint256 tokenIdBob,) = lpm.mint(range, liquidityBob, block.timestamp + 1, bob, ZERO_BYTES);

// donate to create fees
donateRouter.donate(key, 0.2e18, 0.2e18, ZERO_BYTES);
donateRouter.donate(key, 20e18, 20e18, ZERO_BYTES);

(uint256 token0Owed, uint256 token1Owed) = lpm.feesOwed(tokenIdAlice);

Expand All @@ -400,7 +400,7 @@ contract IncreaseLiquidityTest is Test, Deployers, GasSnapshot, Fuzzers {
lpm.collect(tokenIdBob, bob, ZERO_BYTES, false);

// donate to create more fees
donateRouter.donate(key, 0.2e18, 0.2e18, ZERO_BYTES);
donateRouter.donate(key, 20e18, 20e18, ZERO_BYTES);

(uint256 newToken0Owed, uint256 newToken1Owed) = lpm.feesOwed(tokenIdAlice);
// alice's fees should be doubled
Expand All @@ -425,12 +425,21 @@ contract IncreaseLiquidityTest is Test, Deployers, GasSnapshot, Fuzzers {
lpm.increaseLiquidity(tokenIdAlice, liquidityDelta, ZERO_BYTES, false);
}

// alice did not spend any tokens, approximately
// alice did not spend any tokens
assertEq(balance0AliceBefore, currency0.balanceOf(alice), "alice spent token0");
assertEq(balance1AliceBefore, currency1.balanceOf(alice), "alice spent token1");

// passes: but WRONG!!!
// assertEq(balance0AliceBefore - currency0.balanceOf(alice), 10e18);
// assertEq(balance1AliceBefore - currency1.balanceOf(alice), 10e18);

(token0Owed, token1Owed) = lpm.feesOwed(tokenIdAlice);
assertEq(token0Owed, 0);
assertEq(token1Owed, 0);

// bob still collects 5
(token0Owed, token1Owed) = lpm.feesOwed(tokenIdBob);
assertApproxEqAbs(token0Owed, 5e18, 1 wei);
assertApproxEqAbs(token1Owed, 5e18, 1 wei);
}
}

0 comments on commit dd25730

Please sign in to comment.