From 905f9e67929485d827e6933f22f733a613c9720a Mon Sep 17 00:00:00 2001 From: clemlak Date: Mon, 11 Dec 2023 16:04:31 +0400 Subject: [PATCH] test: add weightX increase / decrease tests --- test/strategies/G3M/TestG3MCreatePool.t.sol | 39 ++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/test/strategies/G3M/TestG3MCreatePool.t.sol b/test/strategies/G3M/TestG3MCreatePool.t.sol index dbba9222..8572a6b9 100644 --- a/test/strategies/G3M/TestG3MCreatePool.t.sol +++ b/test/strategies/G3M/TestG3MCreatePool.t.sol @@ -75,7 +75,7 @@ contract TestG3MCreatePool is Setup { assertEq(configEndUpdate, endUpdate); } - function test_G3M_createPool_UpdatesWeights() public { + function test_G3M_createPool_IncreasesWeightX() public { deployTokens(subject(), true); (bytes memory strategyData, uint256 initialX, uint256 initialY) = @@ -111,4 +111,41 @@ contract TestG3MCreatePool is Setup { assertEq(weightX, 0.9 ether); assertEq(weightY, 0.1 ether); } + + function test_G3M_createPool_DecreasesWeightX() public { + deployTokens(subject(), true); + + (bytes memory strategyData, uint256 initialX, uint256 initialY) = + G3MStrategy(g3mStrategy()).getStrategyData( + abi.encode( + controller, + reserveX, + 0.9 ether, + 0.1 ether, + startUpdate, + endUpdate + 10 days, + initialPrice + ) + ); + + uint64 poolId = subject().createPool( + 0, + initialX, + initialY, + 100, + 0, + address(0), + g3mStrategy(), + strategyData + ); + + (uint256 weightX, uint256 weightY) = + G3MStrategy(g3mStrategy()).computeWeights(poolId); + assertEq(weightX, 0.9 ether); + assertEq(weightY, 0.1 ether); + vm.warp(block.timestamp + 10 days); + (weightX, weightY) = G3MStrategy(g3mStrategy()).computeWeights(poolId); + assertEq(weightX, 0.1 ether); + assertEq(weightY, 0.9 ether); + } }