Skip to content

Commit

Permalink
test: update deallocate LogNormal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Feb 23, 2024
1 parent 29b0aa8 commit e64e222
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/test/unit/strategies/LogNormal/Deallocate.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,54 @@ import "./SetUp.sol";

contract LogNormalDeallocateTest is LogNormalSetUp {
function test_LogNormal_deallocate_GivenX() public init {
uint256 amountX = 0.1 ether;
uint256 minDeltaX = 0.1 ether;

(uint256 reserveX, uint256 reserveY, uint256 deltaLiquidity) =
solver.deallocateGivenX(POOL_ID, amountX);
(uint256 reserveX, uint256 reserveY, uint256 liquidity) =
dfmm.getReservesAndLiquidity(POOL_ID);
uint256 deltaLiquidity =
computeDeltaLGivenDeltaX(minDeltaX, liquidity, reserveX);
uint256 minDeltaY =
computeDeltaYGivenDeltaX(minDeltaX, reserveX, reserveY);

uint256 preLiquidityBalance = dfmm.liquidityOf(address(this), POOL_ID);
(,, uint256 preTotalLiquidity) = dfmm.getReservesAndLiquidity(POOL_ID);
// uint256 preLiquidityBalance = dfmm.liquidityOf(address(this), POOL_ID);
// (,, uint256 preTotalLiquidity) = dfmm.getReservesAndLiquidity(POOL_ID);

bytes memory data = abi.encode(reserveX, reserveY, deltaLiquidity);
bytes memory data = abi.encode(minDeltaX, minDeltaY, deltaLiquidity);
dfmm.deallocate(POOL_ID, data);

/*
(,, uint256 postTotalLiquidity) = dfmm.getReservesAndLiquidity(POOL_ID);
uint256 deltaTotalLiquidity = preTotalLiquidity - postTotalLiquidity;
assertEq(
preLiquidityBalance - deltaTotalLiquidity,
dfmm.liquidityOf(address(this), POOL_ID)
);
*/
}

function test_LogNormal_deallocate_GivenY() public init {
uint256 amountX = 0.1 ether;
uint256 minDeltaY = 0.1 ether;

(uint256 reserveX, uint256 reserveY, uint256 deltaLiquidity) =
solver.deallocateGivenY(POOL_ID, amountX);
(uint256 reserveX, uint256 reserveY, uint256 liquidity) =
dfmm.getReservesAndLiquidity(POOL_ID);
uint256 deltaLiquidity =
computeDeltaLGivenDeltaY(minDeltaY, liquidity, reserveY);
uint256 minDeltaX =
computeDeltaXGivenDeltaL(deltaLiquidity, liquidity, reserveX);

uint256 preLiquidityBalance = dfmm.liquidityOf(address(this), POOL_ID);
(,, uint256 preTotalLiquidity) = dfmm.getReservesAndLiquidity(POOL_ID);
// uint256 preLiquidityBalance = dfmm.liquidityOf(address(this), POOL_ID);
// (,, uint256 preTotalLiquidity) = dfmm.getReservesAndLiquidity(POOL_ID);

bytes memory data = abi.encode(reserveX, reserveY, deltaLiquidity);
bytes memory data = abi.encode(minDeltaX, minDeltaY, deltaLiquidity);
dfmm.deallocate(POOL_ID, data);

/*
(,, uint256 postTotalLiquidity) = dfmm.getReservesAndLiquidity(POOL_ID);
uint256 deltaTotalLiquidity = preTotalLiquidity - postTotalLiquidity;
assertEq(
preLiquidityBalance - deltaTotalLiquidity,
dfmm.liquidityOf(address(this), POOL_ID)
);
*/
}
}

0 comments on commit e64e222

Please sign in to comment.