🐸
maxAPY for Devs
  • maxAPY ERC7540
    • MetaVault
      • Introduction
      • Architecture
      • Core Operations
      • State Management & Operations
      • Asset Management
      • Settlement Mechanics
      • Withdrawal Queue Mechanics
      • Deployed Addresses
  • Periphery
    • Hurdle Rate Oracle
    • SharePriceOracle
    • Deployed Addresses
  • maxAPY ERC4626
    • Introduction
    • Architecture
    • Vault
      • MaxApyFactory
      • MaxApyRouter
      • MaxApyVault
    • Periphery
      • MaxApyHarvester
    • Base Strategies
      • BaseStrategy
      • BaseSommelierStrategy
      • BaseYearnV3Strategy
      • BaseYearnV2Strategy
      • BaseConvexStrategy
      • BaseConvexStrategyPolygon
      • BaseBeefyStrategy
      • BaseHopStrategy
      • BaseBeefyCurveStrategy
    • Strategies
      • Ethereum - WETH
        • Convex
          • ConvexdETHFrxETHStrategy
        • Sommelier
          • SommelierMorphoEthMaximizerStrategy
          • SommelierStEthDepositTurboStEthStrategy
          • SommelierTurboDivEthStrategy
          • SommelierTurboEEthV2Strategy
          • SommelierTurboEthXStrategy
          • SommelierTurboEzEthStrategy
          • SommelierTurboRsEthStrategy
          • SommelierTurboStEthStrategy
          • SommelierTurboSwEthStrategy
        • Yearn
          • YearnAaveV3WETHLenderStrategy
          • YearnAjnaWETHStakingStrategy
          • YearnCompoundV3WETHLenderStrategy
          • YearnV3WETH2Strategy
          • YearnV3WETHStrategy
          • YearnWETHStrategy
      • Ethereum - USDC
        • Convex
          • ConvexCrvUSDWethCollateralStrategy
        • Sommelier
          • SommelierTurboGHOStrategy
        • Yearn
          • YearnAjnaDAIStakingStrategy
          • YearnDAIStrategy
          • YearnLUSDStrategy
          • YearnUSDCStrategy
          • YearnUSDTStrategy
      • Polygon - WETH
        • Hop
          • HopETHStrategy
      • Polygon - USDC.e
        • Convex
          • ConvexUSDCCrvUSDStrategy
          • ConvexUSDTCrvUSDStrategy
        • Beefy
          • BeefyCrvUSDUSDCeStrategy
          • BeefyMaiUSDCeStrategy
          • BeefyUSDCeDAIStrategy
        • Yearn
          • YearnAaveV3USDTLenderStrategy
          • YearnAjnaUSDCStrategy
          • YearnCompoundUSDCeLenderStrategy
          • YearnDAILenderStrategy
          • YearnDAIStrategy
          • YearnMaticUSDCStakingStrategy
          • YearnUSDCeLenderStrategy
          • YearnUSDCeStrategy
          • YearnUSDTStrategy
    • Subgraph
      • Overview
      • Schema
      • Query Guide
Powered by GitBook
On this page
  • Overview
  • Constants
  • Errors
  • Functions
  • Deposit Functions
  • deposit
  • depositWithPermit
  • depositNative
  • Withdrawal Functions
  • redeem
  • redeemNative
  • Helper Functions
  • _approveMax
  1. maxAPY ERC4626
  2. Vault

MaxApyRouter

Overview

The MaxApyRouter is a helper contract that provides safe and convenient ways to interact with MaxApy vaults. It supports standard ERC20 deposits, permit-style deposits, and native token operations.

Constants

IWrappedToken public immutable wrappedToken;    // Chain's wrapped native token

Errors

error FailedNativeTransfer();          // Native token transfer failed
error InsufficientShares();            // Not enough shares received
error InsufficientAssets();            // Not enough assets received
error ReceiveNotAllowed();             // Unauthorized receive call
error InvalidRecipient();              // Zero address recipient

Functions

Deposit Functions

deposit

function deposit(
    IMaxApyVault vault,
    uint256 amount,
    address recipient,
    uint256 minSharesOut
) external returns (uint256 sharesOut)

Deposits tokens into a vault using standard ERC20 transfers.

Parameters:

  • vault: Target MaxApy vault

  • amount: Amount of tokens to deposit

  • recipient: Address to receive shares

  • minSharesOut: Minimum shares to receive

Returns:

  • Amount of shares minted

depositWithPermit

function depositWithPermit(
    IMaxApyVault vault,
    uint256 amount,
    address recipient,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s,
    uint256 minSharesOut
) external returns (uint256 sharesOut)

Deposits tokens using EIP-2612 permit for approval-free deposits.

Parameters:

  • vault: Target MaxApy vault

  • amount: Amount of tokens to deposit

  • recipient: Address to receive shares

  • deadline: Permit deadline

  • v: Signature component

  • r: Signature component

  • s: Signature component

  • minSharesOut: Minimum shares to receive

Returns:

  • Amount of shares minted

depositNative

function depositNative(
    IMaxApyVault vault,
    address recipient,
    uint256 minSharesOut
) external payable returns (uint256 sharesOut)

Deposits native token by wrapping it first.

Parameters:

  • vault: Target MaxApy vault

  • recipient: Address to receive shares

  • minSharesOut: Minimum shares to receive

Returns:

  • Amount of shares minted

Withdrawal Functions

redeem

function redeem(
    IMaxApyVault vault,
    uint256 shares,
    address recipient,
    uint256 minAmountOut
) external returns (uint256 amountOut)

Redeems shares for underlying tokens.

Parameters:

  • vault: Target MaxApy vault

  • shares: Amount of shares to redeem

  • recipient: Address to receive assets

  • minAmountOut: Minimum assets to receive

Returns:

  • Amount of assets received

redeemNative

function redeemNative(
    IMaxApyVault vault,
    uint256 shares,
    address recipient,
    uint256 minAmountOut
) external returns (uint256 amountOut)

Redeems shares for native tokens.

Parameters:

  • vault: Target MaxApy vault

  • shares: Amount of shares to redeem

  • recipient: Address to receive native tokens

  • minAmountOut: Minimum assets to receive

Returns:

  • Amount of native tokens received

Helper Functions

_approveMax

function _approveMax(address _vault, address _token) internal

Approves maximum token spending limit if current allowance is zero.

Parameters:

  • _vault: Vault address to approve

  • _token: Token to approve spending for

PreviousMaxApyFactoryNextMaxApyVault

Last updated 6 months ago