Skip to content

Commit

Permalink
feat: add controller address in strategy data
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Dec 4, 2023
1 parent 9334c05 commit 58507ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions contracts/strategies/G3MStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -202,6 +203,7 @@ contract G3MStrategy is IG3MStrategy {
}

function getStrategyData(
address controller,
uint256 reserveX,
uint256 weightX,
uint256 price
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions contracts/strategies/IG3MStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ interface IG3MStrategy is IStrategy {

struct Config {
uint256 weightX;
address controller;
}
}
6 changes: 3 additions & 3 deletions test/TestG3MCreatePool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 58507ab

Please sign in to comment.