Skip to content

Commit

Permalink
feat: add token index check in G3M prepareSwap
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Apr 26, 2024
1 parent a504c53 commit df0e589
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/GeometricMean/GeometricMeanSolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,15 @@ contract GeometricMeanSolver is ISolver {
uint256 tokenOutIndex,
uint256 amountIn
) public view returns (bool, uint256, bytes memory) {
if (
tokenInIndex > 1 || tokenOutIndex > 1
|| tokenInIndex == tokenOutIndex
) {
revert InvalidTokenIndex();
}

GeometricMeanParams memory params = getPoolParams(poolId);
Pool memory pool = IDFMM(IStrategy(strategy).dfmm()).pools(poolId);
Pool memory pool = IDFMM(strategy.dfmm()).pools(poolId);

SimulateSwapState memory state;

Expand Down Expand Up @@ -161,9 +168,8 @@ contract GeometricMeanSolver is ISolver {
bytes memory swapData =
abi.encode(tokenInIndex, tokenOutIndex, amountIn, state.amountOut);

(bool valid,,,,,,) = IStrategy(strategy).validateSwap(
address(this), poolId, pool, swapData
);
(bool valid,,,,,,) =
strategy.validateSwap(address(this), poolId, pool, swapData);

return (valid, state.amountOut, swapData);
}
Expand Down

0 comments on commit df0e589

Please sign in to comment.