Skip to main content

Vault

The Vault is an ERC4626-compliant vault where lenders deposit the borrowed token (e.g., USDC, WETH) to earn yield from borrower interest. Each lending market has its own isolated vault instance deployed by the LendFactory.

The vault's pricePerShare increases over time as borrowers pay interest. It implements the full ERC20 and ERC4626 interfaces, with additional Curve-specific methods for APR reporting and supply limits.

The vault uses a dead shares mechanism (minting 1000 shares to the zero address on initialization) to protect against ERC4626 inflation attacks.

Vault.vy

The source code for the Vault.vy contract can be found on GitHub. The contract is written in Vyper version 0.4.3.

Deployment addresses will be added once contracts are finalized.


ERC4626 — Deposits and Withdrawals

deposit

Vault.deposit(_assets: uint256, _receiver: address) -> uint256

Deposits the specified amount of borrowed tokens into the vault and mints shares to the receiver.

InputTypeDescription
_assetsuint256Amount of borrowed tokens to deposit
_receiveraddressAddress to receive the minted vault shares

Returns: number of shares minted (uint256).

Emits: Deposit event.

<>Source code
Example

mint

Vault.mint(_shares: uint256, _receiver: address) -> uint256

Mints an exact number of vault shares by depositing the required amount of borrowed tokens.

InputTypeDescription
_sharesuint256Exact number of shares to mint
_receiveraddressAddress to receive the minted shares

Returns: amount of assets deposited (uint256).

Emits: Deposit event.

<>Source code
Example

withdraw

Vault.withdraw(_assets: uint256, _receiver: address, _owner: address) -> uint256

Withdraws an exact amount of borrowed tokens by burning the required vault shares.

InputTypeDescription
_assetsuint256Exact amount of borrowed tokens to withdraw
_receiveraddressAddress to receive the withdrawn tokens
_owneraddressAddress whose shares are burned

Returns: number of shares burned (uint256).

Emits: Withdraw event.

<>Source code
Example

redeem

Vault.redeem(_shares: uint256, _receiver: address, _owner: address) -> uint256

Burns an exact number of vault shares and returns the corresponding borrowed tokens.

InputTypeDescription
_sharesuint256Exact number of shares to burn
_receiveraddressAddress to receive the withdrawn tokens
_owneraddressAddress whose shares are burned

Returns: amount of assets withdrawn (uint256).

Emits: Withdraw event.

<>Source code
Example

ERC4626 — Preview and Limits

totalAssets

Vault.totalAssets() -> uint256: view

Returns the total amount of borrowed tokens managed by the vault, including tokens lent out to borrowers (tracked by the controller's debt accounting).

Returns: total assets (uint256).

<>Source code
Example

convertToShares

Vault.convertToShares(_assets: uint256) -> uint256: view

Returns the number of vault shares that would be minted for a given amount of assets.

InputTypeDescription
_assetsuint256Amount of assets

Returns: equivalent shares (uint256).

<>Source code
Example

convertToAssets

Vault.convertToAssets(_shares: uint256) -> uint256: view

Returns the amount of assets that a given number of shares is worth.

InputTypeDescription
_sharesuint256Amount of shares

Returns: equivalent assets (uint256).

<>Source code
Example

previewDeposit

Vault.previewDeposit(_assets: uint256) -> uint256: view

Simulates a deposit and returns the number of shares that would be minted. Rounds down.

InputTypeDescription
_assetsuint256Amount of assets to deposit

Returns: shares that would be minted (uint256).

<>Source code
Example

previewMint

Vault.previewMint(_shares: uint256) -> uint256: view

Simulates a mint and returns the amount of assets required. Rounds up.

InputTypeDescription
_sharesuint256Number of shares to mint

Returns: assets required (uint256).

<>Source code
Example

previewWithdraw

Vault.previewWithdraw(_assets: uint256) -> uint256: view

Simulates a withdrawal and returns the number of shares that would be burned. Rounds up.

InputTypeDescription
_assetsuint256Amount of assets to withdraw

Returns: shares that would be burned (uint256).

<>Source code
Example

previewRedeem

Vault.previewRedeem(_shares: uint256) -> uint256: view

Simulates a redemption and returns the amount of assets that would be returned. Rounds down.

InputTypeDescription
_sharesuint256Number of shares to redeem

Returns: assets that would be returned (uint256).

<>Source code
Example

maxDeposit

Vault.maxDeposit(_receiver: address) -> uint256: view

Returns the maximum amount of assets that can be deposited for a given receiver, considering the supply limit.

InputTypeDescription
_receiveraddressReceiver address

Returns: max depositable assets (uint256).

<>Source code
Example

maxMint

Vault.maxMint(_receiver: address) -> uint256: view

Returns the maximum number of shares that can be minted for a given receiver.

InputTypeDescription
_receiveraddressReceiver address

Returns: max mintable shares (uint256).

<>Source code
Example

maxWithdraw

Vault.maxWithdraw(_owner: address) -> uint256: view

Returns the maximum amount of assets that can be withdrawn by a given owner, limited by available liquidity.

InputTypeDescription
_owneraddressOwner of the shares

Returns: max withdrawable assets (uint256).

<>Source code
Example

maxRedeem

Vault.maxRedeem(_owner: address) -> uint256: view

Returns the maximum number of shares that can be redeemed by a given owner.

InputTypeDescription
_owneraddressOwner of the shares

Returns: max redeemable shares (uint256).

<>Source code
Example

pricePerShare

Vault.pricePerShare() -> uint256: view

Returns the current price per share, scaled to 1e18. Increases over time as interest accrues.

Returns: price per share (uint256).

<>Source code
Example

APR

borrow_apr

Vault.borrow_apr() -> uint256: view

Returns the current annualized borrow rate as reported by the monetary policy, scaled to 1e18.

Returns: borrow APR (uint256).

<>Source code
Example

lend_apr

Vault.lend_apr() -> uint256: view

Returns the current annualized lending rate — the effective yield lenders earn after accounting for utilization and admin fees, scaled to 1e18.

Returns: lend APR (uint256).

<>Source code
Example

Vault Info

asset

Vault.asset() -> address: view

Returns the address of the underlying borrowed token (the ERC4626 asset).

Returns: asset address (address).

<>Source code
Example

borrowed_token

Vault.borrowed_token() -> address: view

Returns the borrowed token address.

Returns: token address (address).

<>Source code
Example

collateral_token

Vault.collateral_token() -> address: view

Returns the collateral token address for this market.

Returns: token address (address).

<>Source code
Example

controller

Vault.controller() -> address: view

Returns the LendController address associated with this vault.

Returns: controller address (address).

<>Source code
Example

amm

Vault.amm() -> address: view

Returns the AMM (LLAMMA) address associated with this vault.

Returns: AMM address (address).

<>Source code
Example

factory

Vault.factory() -> address: view

Returns the factory that deployed this vault.

Returns: factory address (address).

<>Source code
Example

Admin

set_max_supply

Vault.set_max_supply(_max_supply: uint256)
Guarded Method

This function is only callable by the admin, which is the factory owner.

Sets the maximum supply cap for the vault. When set, deposits that would push totalSupply above this limit are rejected.

InputTypeDescription
_max_supplyuint256New maximum supply cap (0 = unlimited)

Emits: SetMaxSupply event.

<>Source code
Example

admin

Vault.admin() -> address: view

Returns the admin of the vault, which is the owner of the factory contract.

Returns: admin address (address).

<>Source code
Example

ERC20

The vault implements the full ERC20 interface for vault share tokens.

transfer

Vault.transfer(_to: address, _value: uint256) -> bool

Transfers vault shares to another address.

InputTypeDescription
_toaddressRecipient address
_valueuint256Amount of shares to transfer

Returns: success (bool).

Emits: Transfer event.

<>Source code
Example

transferFrom

Vault.transferFrom(_from: address, _to: address, _value: uint256) -> bool

Transfers vault shares from one address to another, using the caller's allowance.

InputTypeDescription
_fromaddressSender address
_toaddressRecipient address
_valueuint256Amount of shares to transfer

Returns: success (bool).

Emits: Transfer event.

<>Source code
Example

approve

Vault.approve(_spender: address, _value: uint256) -> bool

Approves an address to spend vault shares on behalf of the caller.

InputTypeDescription
_spenderaddressAddress to approve
_valueuint256Allowance amount

Returns: success (bool).

Emits: Approval event.

<>Source code
Example

increaseAllowance

Vault.increaseAllowance(_spender: address, _add_value: uint256) -> bool

Increases the allowance for a spender by a given amount.

InputTypeDescription
_spenderaddressAddress whose allowance to increase
_add_valueuint256Amount to add to the current allowance

Returns: success (bool).

Emits: Approval event.

<>Source code
Example

decreaseAllowance

Vault.decreaseAllowance(_spender: address, _sub_value: uint256) -> bool

Decreases the allowance for a spender by a given amount.

InputTypeDescription
_spenderaddressAddress whose allowance to decrease
_sub_valueuint256Amount to subtract from the current allowance

Returns: success (bool).

Emits: Approval event.

<>Source code
Example