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 tokenErrors
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 recipientFunctions
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 vaultamount: Amount of tokens to depositrecipient: Address to receive sharesminSharesOut: 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 vaultamount: Amount of tokens to depositrecipient: Address to receive sharesdeadline: Permit deadlinev: Signature componentr: Signature components: Signature componentminSharesOut: 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 vaultrecipient: Address to receive sharesminSharesOut: 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 vaultshares: Amount of shares to redeemrecipient: Address to receive assetsminAmountOut: 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 vaultshares: Amount of shares to redeemrecipient: Address to receive native tokensminAmountOut: Minimum assets to receive
Returns:
Amount of native tokens received
Helper Functions
_approveMax
function _approveMax(address _vault, address _token) internalApproves maximum token spending limit if current allowance is zero.
Parameters:
_vault: Vault address to approve_token: Token to approve spending for
Last updated