diff --git a/test/SYCoveredCall/unit/SetUp.sol b/test/SYCoveredCall/unit/SetUp.sol index 3a4411e8..7a6c8116 100644 --- a/test/SYCoveredCall/unit/SetUp.sol +++ b/test/SYCoveredCall/unit/SetUp.sol @@ -27,7 +27,7 @@ contract SYCoveredCallSetUp is SetUp { uint256 defaultReserveXMil = 1_000_000 ether; uint256 defaultReserveXDeep = ONE * 10_000_000; - uint256 defaultPrice = ONE; + uint256 defaultPrice; uint256 defaultPricePoint9Rate = 0.84167999326 ether; address public constant wstETH = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0; //real wsteth @@ -105,6 +105,8 @@ contract SYCoveredCallSetUp is SetUp { YT: YT }); + defaultPrice = uint256(pendleRateAnchor); + bytes memory initialPoolData = solver.getInitialPoolDataGivenX( defaultReserveX, defaultPrice, defaultParams ); @@ -118,7 +120,6 @@ contract SYCoveredCallSetUp is SetUp { feeCollector: address(0), controllerFee: 0 }); - console2.log("timestamp", block.timestamp); (POOL_ID,,) = dfmm.init(defaultInitParams); diff --git a/test/SYCoveredCall/unit/Swap.t.sol b/test/SYCoveredCall/unit/Swap.t.sol index 019d374d..5ac5f643 100644 --- a/test/SYCoveredCall/unit/Swap.t.sol +++ b/test/SYCoveredCall/unit/Swap.t.sol @@ -64,6 +64,37 @@ contract SYCoveredCallSwapTest is SYCoveredCallSetUp { ); } + function test_SYCoveredCall_swap_SwapsXforY_Warp2DaysUpdatesK() + public + init + { + vm.warp(block.timestamp + 2 days); + + (uint256[] memory reserves, uint256 L) = + solver.getReservesAndLiquidity(POOL_ID); + SYCoveredCallParams memory params = solver.getPoolParams(POOL_ID); + uint256 initialK = computeKGivenLastPrice(reserves[0], L, params); + uint256 amountIn = 0.1 ether; + bool swapXForY = true; + console2.log("initialK", initialK); + + (bool valid, uint256 amountOut,, bytes memory payload) = + solver.simulateSwap(POOL_ID, swapXForY, amountIn, block.timestamp); + assertEq(valid, true); + + console2.log("out", amountOut); + + (,, uint256 inputAmount, uint256 outputAmount) = + dfmm.swap(POOL_ID, address(this), payload, ""); + + (uint256[] memory nextReserves, uint256 nextL) = + solver.getReservesAndLiquidity(POOL_ID); + SYCoveredCallParams memory nextParams = solver.getPoolParams(POOL_ID); + + uint256 k = computeKGivenLastPrice(nextReserves[0], nextL, nextParams); + console2.log("k", k); + } + function test_SYCoveredCall_swap_SwapsYforX() public init { uint256 preDfmmBalanceX = tokenX.balanceOf(address(dfmm)); uint256 preDfmmBalanceY = tokenY.balanceOf(address(dfmm));