Foundry tooling to help assess costs when using LayerZero V2. Quote enumeration is performed entirely offchain.
Report Bug
·
Request Feature
Table of Contents
This is primarily a set of foundry scripts that are designed to make it very easy to get quotes for a particular payload using a variety of routes, completely offchain. It supports performing quotes from a specific source chain to N destination chains, or performing full mesh enumeration for a set of chains so you can identify the cheapest routes.
LayerZeroQuoter was designed using Foundry, so I recommend familiarizing yourself with that if required.
- Install Foundry
curl -L https://foundry.paradigm.xyz | bash foundryup
- Clone this repo:
git clone https://github.com/Zodomo/LayerZeroQuoter cd LayerZeroQuoter
- Install LayerZeroQuoter:
forge install
- Install LayerZero-v2 dependencies
cd lib/LayerZero-v2 yarn yarn build cd ../..
- Copy .env.example into .env:
cp ./.env.example ./.env
- Populate the RPC URLs for the chains you want to test in .env, save it, and then run:
source .env
- Pick any of the scripts in
./scripts/
and modify the variables near the top of the script you want to run.
MeshQuote.s.sol:OutboundQuote.s.sol:uint128 internal gas = 50_000; // Must be in units of gas, not in gwei uint128 internal msgValue = 0.01 ether; bytes internal message = abi.encode("Zodomo"); bool internal payInLzToken = false;
InboundQuote.s.sol:uint32 internal srcEid = EID_MAINNET; // Source this in src/LZConfig.sol uint128 internal gas = 50_000; // Must be in units of gas, not in gwei uint128 internal msgValue = 0.01 ether; bytes internal message = abi.encode("Zodomo"); bool internal payInLzToken = false;
uint32 internal dstEid = EID_MAINNET; // Source this in src/LZConfig.sol uint128 internal gas = 50_000; // Must be in units of gas, not in gwei uint128 internal msgValue = 0.01 ether; bytes internal message = abi.encode("Zodomo"); bool internal payInLzToken = false;
- Comment and/or uncomment each _deploy() call in the specified script's setUp() function to configure which chains you are testing.
Example:_deploy("Ethereum", vm.envString("ETHEREUM_RPC_URL"), EID_ETHEREUM); //_deploy("BNB Chain", vm.envString("BNB_RPC_URL"), EID_BNB); //_deploy("Avalanche", vm.envString("AVALANCHE_RPC_URL"), EID_AVALANCHE); _deploy("Polygon", vm.envString("POLYGON_RPC_URL"), EID_POLYGON); _deploy("Arbitrum", vm.envString("ARBITRUM_RPC_URL"), EID_ARBITRUM); _deploy("Optimism", vm.envString("OPTIMISM_RPC_URL"), EID_OPTIMISM);
- Lastly, execute your preferred script using one of the following commands (be careful not to broadcast, as that is not necessary).
forge script script/InboundQuote.s.sol --sig "run()" -vvv
forge script script/OutboundQuote.s.sol --sig "run()" -vvv
forge script script/MeshQuote.s.sol --sig "run()" -vvv
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the CC0-1.0 License.
Zodomo: Farcaster - Twitter - Email - Zodomo.eth - zodomo/
Project Link: https://github.com/Zodomo/LayerZeroQuoter