-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from skip-mev/axelar_execute_swap
Axelar execute swap
- Loading branch information
Showing
20 changed files
with
1,747 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
AxelarHandler/broadcast/SimulateExecuteWithToken.s.sol/1/dry-run/run-1723057712.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"transactions": [ | ||
{ | ||
"hash": null, | ||
"transactionType": "CREATE2", | ||
"contractName": "BytesLib", | ||
"contractAddress": "0xbfb201a128d08c99a6228938415b02d20b6ec4ad", | ||
"function": null, | ||
"arguments": null, | ||
"transaction": { | ||
"from": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", | ||
"to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", | ||
"gas": "0x27fab", | ||
"input": "0x000000000000000000000000000000000000000000000000000000000000000061012b61003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c8063593b79fe146038575b600080fd5b60676043366004607b565b604080516001600160a01b0392909216600560a21b18601483015260348201905290565b6040516072919060a9565b60405180910390f35b600060208284031215608c57600080fd5b81356001600160a01b038116811460a257600080fd5b9392505050565b600060208083528351808285015260005b8181101560d45785810183015185820160400152820160ba565b506000604082860101526040601f19601f830116850101925050509291505056fea26469706673582212202001b5e1dbec67ed81daef4e82e5dc66748bca332df0db2a80f4ac32bc7eda7664736f6c63430008120033", | ||
"nonce": "0x0", | ||
"chainId": "0x1" | ||
}, | ||
"additionalContracts": [], | ||
"isFixedGasLimit": false | ||
} | ||
], | ||
"receipts": [], | ||
"libraries": [ | ||
"src/libraries/Path.sol:BytesLib:0xBfB201a128D08C99a6228938415B02D20b6Ec4ad" | ||
], | ||
"pending": [], | ||
"returns": {}, | ||
"timestamp": 1723057712, | ||
"chain": 1, | ||
"commit": "502ef75" | ||
} |
31 changes: 31 additions & 0 deletions
31
AxelarHandler/broadcast/SimulateExecuteWithToken.s.sol/1/dry-run/run-1723057941.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"transactions": [ | ||
{ | ||
"hash": null, | ||
"transactionType": "CREATE2", | ||
"contractName": "BytesLib", | ||
"contractAddress": "0xbfb201a128d08c99a6228938415b02d20b6ec4ad", | ||
"function": null, | ||
"arguments": null, | ||
"transaction": { | ||
"from": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", | ||
"to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", | ||
"gas": "0x27fab", | ||
"input": "0x000000000000000000000000000000000000000000000000000000000000000061012b61003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c8063593b79fe146038575b600080fd5b60676043366004607b565b604080516001600160a01b0392909216600560a21b18601483015260348201905290565b6040516072919060a9565b60405180910390f35b600060208284031215608c57600080fd5b81356001600160a01b038116811460a257600080fd5b9392505050565b600060208083528351808285015260005b8181101560d45785810183015185820160400152820160ba565b506000604082860101526040601f19601f830116850101925050509291505056fea26469706673582212202001b5e1dbec67ed81daef4e82e5dc66748bca332df0db2a80f4ac32bc7eda7664736f6c63430008120033", | ||
"nonce": "0x0", | ||
"chainId": "0x1" | ||
}, | ||
"additionalContracts": [], | ||
"isFixedGasLimit": false | ||
} | ||
], | ||
"receipts": [], | ||
"libraries": [ | ||
"src/libraries/Path.sol:BytesLib:0xBfB201a128D08C99a6228938415B02D20b6Ec4ad" | ||
], | ||
"pending": [], | ||
"returns": {}, | ||
"timestamp": 1723057941, | ||
"chain": 1, | ||
"commit": "502ef75" | ||
} |
31 changes: 31 additions & 0 deletions
31
AxelarHandler/broadcast/SimulateExecuteWithToken.s.sol/1/dry-run/run-latest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"transactions": [ | ||
{ | ||
"hash": null, | ||
"transactionType": "CREATE2", | ||
"contractName": "BytesLib", | ||
"contractAddress": "0xbfb201a128d08c99a6228938415b02d20b6ec4ad", | ||
"function": null, | ||
"arguments": null, | ||
"transaction": { | ||
"from": "0x1804c8ab1f12e6bbf3894d4083f33e07309d1f38", | ||
"to": "0x4e59b44847b379578588920ca78fbf26c0b4956c", | ||
"gas": "0x27fab", | ||
"input": "0x000000000000000000000000000000000000000000000000000000000000000061012b61003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c8063593b79fe146038575b600080fd5b60676043366004607b565b604080516001600160a01b0392909216600560a21b18601483015260348201905290565b6040516072919060a9565b60405180910390f35b600060208284031215608c57600080fd5b81356001600160a01b038116811460a257600080fd5b9392505050565b600060208083528351808285015260005b8181101560d45785810183015185820160400152820160ba565b506000604082860101526040601f19601f830116850101925050509291505056fea26469706673582212202001b5e1dbec67ed81daef4e82e5dc66748bca332df0db2a80f4ac32bc7eda7664736f6c63430008120033", | ||
"nonce": "0x0", | ||
"chainId": "0x1" | ||
}, | ||
"additionalContracts": [], | ||
"isFixedGasLimit": false | ||
} | ||
], | ||
"receipts": [], | ||
"libraries": [ | ||
"src/libraries/Path.sol:BytesLib:0xBfB201a128D08C99a6228938415B02D20b6Ec4ad" | ||
], | ||
"pending": [], | ||
"returns": {}, | ||
"timestamp": 1723057941, | ||
"chain": 1, | ||
"commit": "502ef75" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import "forge-std/Script.sol"; | ||
import "forge-std/Test.sol"; | ||
import {Environment} from "test/Environment.sol"; | ||
import {MockGateway} from "test/mocks/MockGateway.sol"; | ||
import {IERC20} from "forge-std/interfaces/IERC20.sol"; | ||
|
||
import {ERC1967Proxy} from "lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import {AxelarHandler} from "src/AxelarHandler.sol"; | ||
|
||
contract SimulateExecuteWithToken is Script, Test { | ||
AxelarHandler public handler; | ||
Environment public env; | ||
MockGateway public mockGateway; | ||
|
||
function setUp() public { | ||
vm.createSelectFork(vm.rpcUrl("mainnet")); | ||
|
||
env = new Environment(); | ||
env.setEnv(block.chainid); | ||
|
||
mockGateway = new MockGateway(); | ||
|
||
address gateway = address(mockGateway); | ||
address gasService = env.gasService(); | ||
address swapRouter = env.swapRouter(); | ||
string memory wethSymbol = env.wethSymbol(); | ||
|
||
AxelarHandler handlerImpl = new AxelarHandler(); | ||
ERC1967Proxy handlerProxy = new ERC1967Proxy( | ||
address(handlerImpl), | ||
abi.encodeWithSignature("initialize(address,address,string)", gateway, gasService, wethSymbol) | ||
); | ||
handler = AxelarHandler(payable(address(handlerProxy))); | ||
|
||
handler.setSwapRouter(swapRouter); | ||
} | ||
|
||
function run() public { | ||
string memory tokenInputSymbol = "WETH"; | ||
address tokenIn = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; | ||
address tokenOut = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; //USDC | ||
address destination = 0x0000000000000000000000000000000000000048; | ||
uint256 amountIn = 1 ether; | ||
uint256 amountOutMin = 1_000 * 1e6; | ||
bool unwrap = false; | ||
|
||
mockGateway.saveTokenAddress(tokenInputSymbol, tokenIn); | ||
deal(address(tokenIn), address(handler), amountIn); | ||
|
||
bytes memory swapPayload = abi.encode(uint8(0), tokenOut, amountOutMin, abi.encode(uint24(3000), uint160(0))); | ||
bytes memory payload = abi.encode(uint8(2), abi.encode(destination, unwrap, swapPayload)); | ||
|
||
console2.logBytes(payload); | ||
|
||
console2.log("Token Out Destination Balance Before: %s", IERC20(tokenOut).balanceOf(destination)); | ||
|
||
handler.executeWithToken( | ||
keccak256(abi.encodePacked("COMMAND_ID")), "osmosis-7", "mock_address", payload, tokenInputSymbol, amountIn | ||
); | ||
|
||
console2.log("Token Out Destination Balance After: %s", IERC20(tokenOut).balanceOf(destination)); | ||
} | ||
|
||
function run( | ||
bytes memory payload, | ||
string memory tokenSymbol, | ||
address token, | ||
address tokenOut, | ||
address destination, | ||
uint256 amount | ||
) public { | ||
mockGateway.saveTokenAddress(tokenSymbol, token); | ||
deal(address(token), address(handler), amount); | ||
|
||
console2.log("Token Out Destination Balance Before: %s", IERC20(tokenOut).balanceOf(destination)); | ||
|
||
handler.executeWithToken( | ||
keccak256(abi.encodePacked("COMMAND_ID")), "osmosis-7", "mock_address", payload, tokenSymbol, amount | ||
); | ||
|
||
console2.log("Token Out Destination Balance After: %s", IERC20(tokenOut).balanceOf(destination)); | ||
} | ||
} |
Oops, something went wrong.