Skip to content

etherfi-protocol/Native-Minting-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

L2 Native Minting Bot

Our native minting system requires a set of transactions to be executed on each chain to sync with the L1 liquidity pool. All of these calls are permissionless; hence, this bot has an EOA it uses to submit these transactions.

L2 -> L1 Sync Overview

For all weETH minting on L2s, there is corresponding weETH minted and deposited into the EtherFiOFTAdapter contract. The wETH from L2s must also be bridged back to mainnet for deposit into the Liquidity Pool.

fast-sync

If an L2 SyncPool contract—Blast Example SyncPool—has more than 1000 ETH, the bot will initiate a sync call on said contract. Subsequantly, the ETH in the SyncPool is sent to be bridged to mainnet via canonical bridge, and a LayerZero message is sent to be executed on mainnet by the Layer Zero: Executor. The LayerZero message causes the following actions on Mainnet:

slow-sync

After fast-sync sends ETH to the L2 canonical bridge and the sequencer submits the transaction's state root to mainnet, the bot performs these steps to withdraw the ETH:

  • Submit a proof of withdrawal transaction.
  • Wait 7 to 14 days (variable for each L2) for the challenge period to pass.
  • Submit a relay transaction.

For an optimisitic rollup like an OP stack chain the transaction lifecycle consists these 5 states:
Waiting for state root -> Ready to prove -> In challenge period -> Ready for relay -> Relayed

Repo Structure

project-root/
│
├── src/                   # Source files
│   ├── index.ts           # Entry point for the bot logic and contains the `fastsync` logic
│   │
│   ├── chains/            # Chain-specific logic
│   │   ├── index.ts       # Entry point for slowsync for all chains
│   │   ├── chainConfig.ts # Configurations for each chain
|   |   ├── helpers.ts     # stores the OP stack helper functions for `slowsync`
│   │   └── slowsync/      # holds a file with the `slowsync` logic for each chain 
│   │       ├── Blast.ts   
│   │       ├── Mode.ts      
│   │       └── ...
│   └── abis/              # All contract ABIS
│       ├── Contract1.json
│       ├── Contract2.json
│       └── ...
└── dist/                  # Compiled JavaScript files

Running the Project

  1. Install Dependencies: Install the project dependencies using:

    pnpm install
  2. Set Environment Variables: add the PRIVATE_KEY for the EOA assiocated with the bot and the ALCHEMY_KEY to an .env file. The values are stored in GitHub Secrets for GitHub Actions to access.

  3. Compile and Run: Compile the TypeScript code and run the bot using:

    pnpm start

GitHub Actions

The project is configured to run a daily job at at 7:00 AM, 1:00 PM, and 7:00 PM UTC using GitHub Actions. The GitHub Actions workflow is defined in main.yml.

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published