From 58507ab9ecf70cc22d79f632bfb8bcf8f466f1a0 Mon Sep 17 00:00:00 2001 From: clemlak Date: Mon, 4 Dec 2023 19:59:36 +0400 Subject: [PATCH] feat: add controller address in strategy data --- contracts/strategies/G3MStrategy.sol | 8 +++++--- contracts/strategies/IG3MStrategy.sol | 1 + test/TestG3MCreatePool.t.sol | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/contracts/strategies/G3MStrategy.sol b/contracts/strategies/G3MStrategy.sol index ab3e8d45..b86e5b76 100644 --- a/contracts/strategies/G3MStrategy.sol +++ b/contracts/strategies/G3MStrategy.sol @@ -29,8 +29,9 @@ contract G3MStrategy is IG3MStrategy { uint64 poolId, bytes calldata strategyArgs ) external returns (bool success) { - (uint256 weightX) = abi.decode(strategyArgs, (uint256)); - configs[poolId] = Config(weightX); + (address controller, uint256 weightX) = + abi.decode(strategyArgs, (address, uint256)); + configs[poolId] = Config({ weightX: weightX, controller: controller }); return true; } @@ -202,6 +203,7 @@ contract G3MStrategy is IG3MStrategy { } function getStrategyData( + address controller, uint256 reserveX, uint256 weightX, uint256 price @@ -210,7 +212,7 @@ contract G3MStrategy is IG3MStrategy { pure returns (bytes memory strategyData, uint256 initialX, uint256 initialY) { - strategyData = abi.encode(weightX); + strategyData = abi.encode(controller, weightX); initialX = reserveX; initialY = G3MStrategyLib.computeReserveInGivenPrice( price, reserveX, FixedPointMathLib.WAD - weightX, weightX diff --git a/contracts/strategies/IG3MStrategy.sol b/contracts/strategies/IG3MStrategy.sol index 62a0832c..17a1bac4 100644 --- a/contracts/strategies/IG3MStrategy.sol +++ b/contracts/strategies/IG3MStrategy.sol @@ -8,5 +8,6 @@ interface IG3MStrategy is IStrategy { struct Config { uint256 weightX; + address controller; } } diff --git a/test/TestG3MCreatePool.t.sol b/test/TestG3MCreatePool.t.sol index 12018188..a7306d2b 100644 --- a/test/TestG3MCreatePool.t.sol +++ b/test/TestG3MCreatePool.t.sol @@ -29,7 +29,7 @@ contract TestG3MCreatePool is Setup { (bytes memory strategyData, uint256 initialX, uint256 initialY) = G3MStrategy(g3mStrategy()).getStrategyData( - reserveX, weightX, initialPrice + address(this), reserveX, weightX, initialPrice ); uint64 poolId = subject().createPool( @@ -56,7 +56,7 @@ contract TestG3MCreatePool is Setup { (bytes memory strategyData, uint256 initialX, uint256 initialY) = G3MStrategy(g3mStrategy()).getStrategyData( - reserveX, weightX, initialPrice + address(this), reserveX, weightX, initialPrice ); uint64 poolId = subject().createPool( @@ -89,7 +89,7 @@ contract TestG3MCreatePool is Setup { (bytes memory strategyData, uint256 initialX, uint256 initialY) = G3MStrategy(g3mStrategy()).getStrategyData( - reserveX, weightX, initialPrice + address(this), reserveX, weightX, initialPrice ); uint64 poolId = subject().createPool(