Skip to content

Commit

Permalink
Bugfixes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wirew0lf committed Aug 7, 2024
1 parent 44a1023 commit 502ef75
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 146 deletions.
2 changes: 1 addition & 1 deletion AxelarHandler/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export PRIVATE_KEY=<key>
export RPC_URL=<url>
export RPC_MAINNET=<url>
2 changes: 2 additions & 0 deletions AxelarHandler/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
[rpc_endpoints]
mainnet = "${RPC_MAINNET}"
10 changes: 5 additions & 5 deletions AxelarHandler/src/AxelarHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ contract AxelarHandler is AxelarExecutableUpgradeable, Ownable2StepUpgradeable,
returns (address tokenOut, uint256 amountOut)
{
ISwapRouter02.ExactInputParams memory params;
(params.path) = abi.decode(data, (bytes));
params.path = data;

params.recipient = address(this);
params.amountIn = amount;
Expand Down Expand Up @@ -551,14 +551,14 @@ contract AxelarHandler is AxelarExecutableUpgradeable, Ownable2StepUpgradeable,
params.amountOut = amountOut;
params.amountInMaximum = amount;

(address tokenA,,) = params.path.decodeFirstPool();
(, address tokenB,) = params.path.decodeLastPool();

if (tokenA != token) {
if (tokenB != token) {
bytes memory tokenReplace = BytesLib.toBytes(token);
params.path = BytesLib.concat(tokenReplace, BytesLib.slice(params.path, 20, params.path.length - 20));
params.path = BytesLib.concat(BytesLib.slice(params.path, 0, params.path.length - 20), tokenReplace);
}

(, tokenOut,) = params.path.decodeLastPool();
(tokenOut,,) = params.path.decodeFirstPool();

IERC20Upgradeable tokenSwapIn = IERC20Upgradeable(token);
IERC20Upgradeable tokenSwapOut = IERC20Upgradeable(tokenOut);
Expand Down
Loading

0 comments on commit 502ef75

Please sign in to comment.