Skip to content

Foundry tooling to help assess costs when using LayerZero V2

Notifications You must be signed in to change notification settings

Zodomo/LayerZeroQuoter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues


LayerZeroQuoter

Foundry tooling to help assess costs when using LayerZero V2. Quote enumeration is performed entirely offchain.

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

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.

(back to top)

Built With

  • Ethereum
  • Solidity

(back to top)

Getting Started

LayerZeroQuoter was designed using Foundry, so I recommend familiarizing yourself with that if required.

Prerequisites

  • Install Foundry
    curl -L https://foundry.paradigm.xyz | bash
    foundryup

Installation

  1. Clone this repo:
    git clone https://github.com/Zodomo/LayerZeroQuoter
    cd LayerZeroQuoter
    
  2. Install LayerZeroQuoter:
    forge install
    
  3. Install LayerZero-v2 dependencies
    cd lib/LayerZero-v2
    yarn
    yarn build
    cd ../..
    
  4. Copy .env.example into .env:
    cp ./.env.example ./.env
    
  5. Populate the RPC URLs for the chains you want to test in .env, save it, and then run:
    source .env
    

(back to top)

Usage

  1. Pick any of the scripts in ./scripts/ and modify the variables near the top of the script you want to run.
    MeshQuote.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;
    OutboundQuote.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;
    InboundQuote.s.sol:
    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;

  1. 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);

  1. 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

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the CC0-1.0 License.

(back to top)

Contact

Zodomo: Farcaster - Twitter - Email - Zodomo.eth - zodomo/

Project Link: https://github.com/Zodomo/LayerZeroQuoter

(back to top)

Acknowledgments

(back to top)

About

Foundry tooling to help assess costs when using LayerZero V2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published