Skip to content

Commit

Permalink
test: fix LogNormal allocate test
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Feb 23, 2024
1 parent 103208f commit d0c6544
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/test/unit/strategies/LogNormal/Allocate.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ contract LogNormalAllocateTest is LogNormalSetUp {
uint256 maxDeltaY =
computeDeltaYGivenDeltaX(maxDeltaX, reserveX, reserveY);

console.log("maxDeltaX:", maxDeltaX);
console.log("maxDeltaY:", maxDeltaY);
console.log("deltaLiquidity:", deltaLiquidity);

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

Expand All @@ -35,22 +31,28 @@ contract LogNormalAllocateTest is LogNormalSetUp {
}

function test_LogNormal_allocate_GivenY() public init {
uint256 amountX = 0.1 ether;
uint256 maxDeltaY = 0.1 ether;

(uint256 reserveX, uint256 reserveY, uint256 deltaLiquidity) =
solver.allocateGivenY(POOL_ID, amountX);
(uint256 reserveX, uint256 reserveY, uint256 liquidity) =
dfmm.getReservesAndLiquidity(POOL_ID);
uint256 deltaLiquidity =
computeDeltaLGivenDeltaY(maxDeltaY, liquidity, reserveY);
uint256 maxDeltaX =
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(maxDeltaX, maxDeltaY, deltaLiquidity);
dfmm.allocate(POOL_ID, data);

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

0 comments on commit d0c6544

Please sign in to comment.