Skip to content

Commit

Permalink
feat: fix all existing test cases with min share burned
Browse files Browse the repository at this point in the history
  • Loading branch information
ChefMist committed Nov 12, 2024
1 parent 0c924e1 commit a12fab0
Show file tree
Hide file tree
Showing 8 changed files with 479 additions and 442 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
142478
142466
2 changes: 1 addition & 1 deletion .forge-snapshots/BinPoolManagerTest#testGasGetBin.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3978
4061
2 changes: 2 additions & 0 deletions src/pool-bin/libraries/BinPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ library BinPool {
}

/// @notice Add share to user's position and update total share supply of bin
/// @dev if bin is empty, deduct MINIMUM_SHARE from shares
/// @return userShareAdded The amount of share added to user's position
function _addShare(State storage self, address owner, uint24 binId, bytes32 salt, uint256 shares)
internal
returns (uint256 userShareAdded)
Expand Down
2 changes: 1 addition & 1 deletion test/pool-bin/BinHookReturnsDelta.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ contract BinHookReturnsDelta is Test, GasSnapshot, BinTestHelper {
binLiquidityHelper.burn(key, burnParams, "");

(uint128 reserveXAfter, uint128 reserveYAfter,,) = poolManager.getBin(key.toId(), activeId);
// reserve non zero due to min liquidity locked up in the bin
// reserve non zero due to min liquidity (1e3) locked up in the bin
assertEq(reserveXAfter, 1);
assertEq(reserveYAfter, 1);
assertEq(token0.balanceOf(address(binReturnsDeltaHook)), 0.1 ether - 1);
Expand Down
8 changes: 5 additions & 3 deletions test/pool-bin/BinMintBurnFeeHook.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,16 @@ contract BinMintBurnFeeHookTest is Test, GasSnapshot, BinTestHelper {
binLiquidityHelper.burn(key, burnParams, "");
snapEnd();

// the +3/-4 is just from min_liquidity amount
// +1 from remove liqudiity, -4 from hook fee
// +1 eth from remove liqudiity, -4 eth from hook fee
// +3 from min_liquidity amount as -1 (min_liquidity) + 1 * 4 (fee)
assertEq(token0.balanceOf(address(this)), 7 ether + 1 ether - 4 ether + 3);
assertEq(token1.balanceOf(address(this)), 7 ether + 1 ether - 4 ether + 3);

// -1 from remove liquidity, +4 from hook calling vault.mint
// -1 eth from remove liquidity, +4 eth from hook calling vault.mint
assertEq(token0.balanceOf(address(vault)), 3 ether - 1 ether + 4 ether - 3);
assertEq(token1.balanceOf(address(vault)), 3 ether - 1 ether + 4 ether - 3);

// -4 as due to min_liquidity = 1, hook took 4 token less fee
assertEq(vault.balanceOf(address(binMintBurnFeeHook), key.currency0), 2 ether + 4 ether - 4);
assertEq(vault.balanceOf(address(binMintBurnFeeHook), key.currency1), 2 ether + 4 ether - 4);
}
Expand Down
405 changes: 210 additions & 195 deletions test/pool-bin/BinPoolManager.t.sol

Large diffs are not rendered by default.

Loading

0 comments on commit a12fab0

Please sign in to comment.