Skip to content

Commit

Permalink
feat: use bytes for getStrategyData params
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Dec 5, 2023
1 parent 1585ef2 commit 183d108
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions contracts/strategies/G3MStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,14 @@ contract G3MStrategy is IG3MStrategy {
);
}

function getStrategyData(
address controller,
uint256 reserveX,
uint256 weightX,
uint256 price
)
function getStrategyData(bytes memory data)
external
pure
returns (bytes memory strategyData, uint256 initialX, uint256 initialY)
{
(address controller, uint256 reserveX, uint256 weightX, uint256 price) =
abi.decode(data, (address, uint256, uint256, uint256));

strategyData = abi.encode(controller, weightX);
initialX = reserveX;
initialY = G3MStrategyLib.computeReserveInGivenPrice(
Expand Down
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(
address(this), reserveX, weightX, initialPrice
abi.encode(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(
address(this), reserveX, weightX, initialPrice
abi.encode(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(
address(this), reserveX, weightX, initialPrice
abi.encode(address(this), reserveX, weightX, initialPrice)
);

uint64 poolId = subject().createPool(
Expand Down

0 comments on commit 183d108

Please sign in to comment.