Deposit Pipe

The DepositPipe handles deposits and implements ERC4626 compatibility. Each DepositPipe handles a specific asset, meaning that for a given xToken there can be multiple DepositPipe (1 per accepted deposit asset).

Key Functions

deposit(uint256 assets, address receiver, address controller, uint256 minShares)

Deposit assets and receive shares with slippage protection.

/**
 * @param assets Amount of deposit asset (in asset's native decimals)
 * @param receiver Address to receive minted shares
 * @param controller Address that owns the assets being deposited
 * @param minShares Minimum shares to receive (slippage protection, 18 decimals)
 * @return shares Amount of shares minted (18 decimals)
 */
function deposit(
    uint256 assets,
    address receiver,
    address controller,
    uint256 minShares
) external returns (uint256 shares);

Overloads:

  • deposit(uint256 assets, address receiver) - Uses msg.sender as controller, no slippage protection

  • deposit(uint256 assets, address receiver, address controller) - No slippage protection

  • deposit(uint256 assets, address receiver, uint256 minShares) - Uses msg.sender as controller


mint(uint256 shares, address receiver, address controller, uint256 maxAssets)

Mint specific amount of shares by depositing assets.

/**
 * @param shares Exact amount of shares to mint (18 decimals)
 * @param receiver Address to receive shares
 * @param controller Address that owns the assets
 * @param maxAssets Maximum assets willing to spend (slippage protection, native decimals)
 * @return assets Amount of assets deposited (native decimals)
 */
function mint(
    uint256 shares,
    address receiver,
    address controller,
    uint256 maxAssets
) external returns (uint256 assets);

Overloads:

  • mint(uint256 shares, address receiver) - Uses msg.sender, no slippage limit

  • mint(uint256 shares, address receiver, address controller) - No slippage limit

  • mint(uint256 shares, address receiver, uint256 maxAssets) - Uses msg.sender


Preview Functions

// Preview how many shares you'll receive for assets
function previewDeposit(uint256 assets) external view returns (uint256 shares);

// Preview how many assets required for shares
function previewMint(uint256 shares) external view returns (uint256 assets);

// Convert between assets and shares
function convertToShares(uint256 assets) external view returns (uint256);
function convertToAssets(uint256 shares) external view returns (uint256);

View Functions

// Get the deposit asset address
function asset() external view returns (address);

Last updated