LogoLogo
  • Discover
    • 🌜About Moonwell
    • 👥Contributors
    • 🌐Networks
    • 🔗Quick Links
  • Moonwell Overview
    • 🌙Getting Started
      • Wallet Connection
    • 🤝Lend
      • Supply
      • Withdraw
      • Claiming Rewards
      • Lend FAQ
    • 🤝Borrow
      • How to Borrow
      • Loan Repayment
      • Credit and Liquidations
      • Borrow FAQ
    • 🏦Vaults
      • Interacting with Morpho Vaults
      • Fund Wallet and Deposit
    • 🌐Virtual Accounts
      • Create Virtual Account
      • Accessing Virtual Account
      • FAQ
    • 🦋Isolated Markets
      • Interacting with Isolated Markets
    • 💲USDC Anywhere
      • Supply USDC
      • Borrow USDC
    • 💳Moonwell Card
      • Get Started
      • Load and Spend
      • Auto Load
      • FAQ
    • 💡Smart Wallet
      • Create
      • Connect
      • Getting Started
    • 🌙Tokens
      • WELL Transparency Report
      • WELL Transfer
      • WELL Migration (Base)
      • MFAM Transparency Report
    • 🫂Stake
      • How to Stake
      • How to Unstake
      • Claim Staking Rewards
  • Governance
    • 🗳️Moonwell Governance
      • 🪙Delegate
      • 📜Proposals
      • 🗳️Voting
      • 🔢Parameters
      • ❔FAQ
      • 📜DAO Constitutions
        • Moonwell DAO Constitution
        • Moonwell Apollo DAO Constitution
      • 🗣️Forum
    • 🏛️Moonwell Foundation
      • 🏦Treasury
      • 🔒Security Council
      • 📃Governing Documents
        • Foundation Bylaws
        • Foundation M&A
  • Protocol Information
    • ‼️Protocol Information
    • 📊Asset Risk Parameters
    • 📈Interest Rate Curves
    • ⚖️Reserve Auctions
    • 🛡️Security
    • 🔎Audits
    • 📜Contracts
    • 🖊️Terms of Service
  • Developers
    • 🪙mTokens
      • 📝Contract Interactions
    • 👮‍♀️Comptroller
      • 📝Contract Interactions
      • 🚦Risk Parameters
      • 🛡️Guardian Roles
    • 🏦4626 Vaults
      • 👷‍♂️ERC20 Vault Deployment
        • 🗒️4626 ERC20 Vault Interface
      • 👷‍♀️ETH Vault Deployment
        • 🗒️4626 ETH Vault Interface
        • 📍4626 ETH Router
    • 💻Moonwell SDK
    • 🔨Contribution Guidelines
Powered by GitBook
On this page
  1. Developers
  2. 4626 Vaults
  3. ETH Vault Deployment

4626 ETH Router

In order to allow raw Eth to be deposited and withdrawn from the system using the vault contract, a router has been created to allow this. The router accepts ETH, converts it to WETH, and then deposits the WETH into the 4626 vault.

This router is generic and is designed to be used by multiple projects without the need to deploy new instances even for different 4626 ETH Vaults.

The router interface has support for both mint and deposit functionality on the 4626 vault.

    /// @param vault The ERC4626 vault to mint shares from.
    /// @param to The address to mint shares to.
    /// @param shares The number of shares to mint.
    /// @param maxAmountIn The maximum amount of underlying
    /// assets required for the mint to succeed.
    function mint(
        MoonwellERC4626Eth vault,
        address to,
        uint256 shares,
        uint256 maxAmountIn
    ) public payable returns (uint256 amountIn);
    
    /// @param vault The ERC4626 vault to deposit assets into.
    /// @param to The address to mint shares to.
    /// @param amount The amount of assets to deposit.
    /// @param minSharesOut The minimum number of shares required for the deposit to succeed.
    function deposit(
        MoonwellERC4626Eth vault,
        address to,
        uint256 amount,
        uint256 minSharesOut
    ) public payable returns (uint256 sharesOut);

Both of these functions work by depositing all ETH sent to them into WETH, calling either deposit or mint on the specified 4626 vault, and then refunding all excess WETH leftover in the contract to the sender. Please note: refunds are denominated in WETH, not ETH. When calling the deposit function, the msg.value should match up with the parameter amount. When calling the mint, maxAmountIn should equal msg.value.

The router can only deposit on behalf of users. Withdrawals must take place by calling the underlying 4626 vault itself.

Previous4626 ETH Vault InterfaceNextMoonwell SDK

Last updated 10 months ago

🏦
👷‍♀️
📍