BaseVault

Base contract responsible for the main logic of our vault. It inherits ERC4626 and ERC20 contracts, so, some functions are not shown below. We only document the functions that we did any modification or overridden on it. You can check ERC4626 specification here, and ERC20 here.

src: https://github.com/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol

Public State Variables

DENOMINATOR

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L35

function DENOMINATOR() external view returns (uint256)

DENOMINATOR represents the precision for the following system variables: - MAX_WITHDRAW_FEE - INVESTOR_RATIO

Returns

NameTypeDescription

_0

uint256

Precision number used when calculating the fee

MAX_WITHDRAW_FEE

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L41

function MAX_WITHDRAW_FEE() external view returns (uint256)

MAX_WITHDRAW_FEE is a safe check in case the ConfigurationManager sets a fee high enough that can be used as a way to drain funds. The precision of this number is set by constant DENOMINATOR.

Returns

NameTypeDescription

_0

uint256

Max Fee boundary

MIN_INITIAL_ASSETS

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L47

function MIN_INITIAL_ASSETS() external view returns (uint256)

Minimum asset amount for the first deposit

This amount prevents the first depositor to steal funds from subsequent depositors. See https://code4rena.com/reports/2022-01-sherlock/#h-01-first-user-can-steal-everyone-elses-tokens

Returns

NameTypeDescription

_0

uint256

Initial deposit amount

configuration

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L49

function configuration() external view returns (contract IConfigurationManager)

Returns

NameTypeDescription

_0

address

ConfigurationManager address

View Methods

currentRoundId

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L97

function currentRoundId() external view returns (uint32)

Returns the current round ID.

Returns

NameTypeDescription

_0

uint32

current round Id

isProcessingDeposits

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L104

function isProcessingDeposits() external view returns (bool)

Determines whether the Vault is in the processing deposits state.

While it's processing deposits, processDeposits can be called and new shares can be created. During this period deposits, mints, withdraws and redeems are blocked.

Returns

NameTypeDescription

_0

bool

Is processing deposits boolean

processedDeposits

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L111

function processedDeposits() external view returns (uint256)

Returns the amount of processed deposits entering the next round.

Returns

NameTypeDescription

_0

uint256

Amount of processed deposits entering the next round.

queuedDeposits

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L313

function queuedDeposits() external view returns (address[])

Outputs addresses in the deposit queue

Returns

NameTypeDescription

_0

address[]

addresses in deposit queue

controller

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L325

function controller() external view returns (address)

Returns the vault controller

Returns

NameTypeDescription

_0

address

Controller address

idleAssetsOf

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L284

function idleAssetsOf(address owner) external view returns (uint256)

Outputs the amount of asset tokens of an owner is idle, waiting for the next round.

Parameters

NameTypeDescription

owner

address

Owner address

Returns

NameTypeDescription

_0

uint256

Amount of Idle Assets

getWithdrawFeeRatio

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L275

function getWithdrawFeeRatio() external view returns (uint256)

Returns the fee charged on withdraws.

Returns

NameTypeDescription

_0

uint256

Withdraw Fee Ratio

depositQueueSize

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L306

function depositQueueSize() external view returns (uint256)

Outputs current size of the deposit queue.

Returns

NameTypeDescription

_0

uint256

Queue Size

maxDeposit

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L226

function maxDeposit(address) external view returns (uint256)

Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call. - MUST return a limited value if receiver is subject to some deposit limit. - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. - MUST NOT revert.

Parameters

NameTypeDescription

_0

address

Owner address

Returns

NameTypeDescription

_0

uint256

Max amount of underlying to deposit

maxMint

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L242

function maxMint(address) external view returns (uint256)

Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. - MUST return a limited value if receiver is subject to some mint limit. - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. - MUST NOT revert.

Parameters

NameTypeDescription

_0

address

Owner Address

Returns

NameTypeDescription

_0

uint256

Max amount of shares that can be minted

maxRedeem

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L264

function maxRedeem(address owner) external view returns (uint256)

Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call. - MUST return a limited value if owner is subject to some withdrawal limit or timelock. - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. - MUST NOT revert.

Parameters

NameTypeDescription

owner

address

Owner Address

Returns

NameTypeDescription

_0

uint256

Max amount of shares that can be redeemed

maxWithdraw

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L253

function maxWithdraw(address owner) external view returns (uint256)

Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call. - MUST return a limited value if owner is subject to some withdrawal limit or timelock. - MUST NOT revert.

Parameters

NameTypeDescription

owner

address

Owner Address

Returns

NameTypeDescription

_0

uint256

Max amount of underlying asset that can be withdrawn

totalAssets

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L292

function totalAssets() external view returns (uint256)

Returns the total amount of the underlying asset that is “managed” by Vault. - SHOULD include any compounding that occurs from yield. - MUST be inclusive of any fees that are charged against assets in the Vault. - MUST NOT revert.

Returns

NameTypeDescription

_0

uint256

undefined

totalIdleAssets

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L299

function totalIdleAssets() external view returns (uint256)

Outputs the amount of asset tokens is idle, waiting for the next round.

Returns

NameTypeDescription

_0

uint256

undefined

previewRedeem

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L218

function previewRedeem(uint256 shares) external view returns (uint256)

Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions. - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction. - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc. - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. - MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.

Parameters

NameTypeDescription

shares

uint256

Shares amount

Returns

NameTypeDescription

_0

uint256

Assets amount

previewWithdraw

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L211

function previewWithdraw(uint256 assets) external view returns (uint256)

Because of rounding issues, we did not find a way to return exact shares when including the fees. This is not 100% compliant to ERC4626 specification. You can follow the discussion here: https://ethereum-magicians.org/t/eip-4626-yield-bearing-vault-standard/7900/104 This function will return the number of shares necessary to withdraw assets not including fees. This means that you will need to redeem MORE shares to achieve the net assets.

Parameters

NameTypeDescription

assets

uint256

Assets amount

Returns

NameTypeDescription

_0

uint256

Shares Amount

Write Methods

deposit

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L118

function deposit(uint256 assets, address receiver) external nonpayable returns (uint256)

Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. - MUST emit the Deposit event. - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit. - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.

Parameters

NameTypeDescription

assets

uint256

assets

receiver

address

receiver

Returns

NameTypeDescription

_0

uint256

shares

depositWithPermit

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L131

function depositWithPermit(uint256 assets, address receiver, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable returns (uint256)

Deposit ERC20 tokens with permit, a gasless token approval.

Mints shares to receiver by depositing exactly amount of underlying tokens. For more information on the signature format, see the EIP2612 specification: https://eips.ethereum.org/EIPS/eip-2612#specification

Parameters

NameTypeDescription

assets

uint256

assets

receiver

address

receiver address

deadline

uint256

timestamp deadline

v

uint8

signature parameter v

r

bytes32

signature parameter r

s

bytes32

signature parameter s

Returns

NameTypeDescription

_0

uint256

shares amount

endRound

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L347

function endRound() external nonpayable

Closes the round, allowing deposits to the next round be processed. and opens the window for withdraws.

handleMigration

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L399

function handleMigration(uint256 assets, address receiver) external nonpayable returns (uint256)

Handle migrated assets.

Parameters

NameTypeDescription

assets

uint256

undefined

receiver

address

undefined

Returns

NameTypeDescription

_0

uint256

Estimation of shares created.

migrate

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L378

function migrate() external nonpayable

Migrate assets from this vault to the next vault.

The newVault will be assigned by the ConfigurationManager

processQueuedDeposits

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L412

function processQueuedDeposits(address[] depositors) external nonpayable

Distribute shares to depositors queued in the deposit queue, effectively including their assets in the next round.

Parameters

NameTypeDescription

depositors

address[]

Array of owner addresses to process

redeem

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L175

function redeem(uint256 shares, address receiver, address owner) external nonpayable returns (uint256 assets)

Burns exactly shares from owner and sends assets of underlying tokens to receiver. - MUST emit the Withdraw event. - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem. - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.

Parameters

NameTypeDescription

shares

uint256

shares amount

receiver

address

receiver address

owner

address

owner address

Returns

NameTypeDescription

assets

uint256

assets amount

refund

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L362

function refund() external nonpayable returns (uint256 assets)

Withdraw all user assets in unprocessed deposits.

Returns

NameTypeDescription

assets

uint256

assets amount

startRound

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L332

function startRound() external nonpayable returns (uint32)

Starts the next round, sending the idle funds to the strategy where it should start accruing yield.

Returns

NameTypeDescription

_0

uint32

The new round id

withdraw

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L194

function withdraw(uint256 assets, address receiver, address owner) external nonpayable returns (uint256 shares)

Because of rounding issues, we did not find a way to return assets including the fees. This is not 100% compliant to ERC4626 specification. You can follow the discussion here: https://ethereum-magicians.org/t/eip-4626-yield-bearing-vault-standard/7900/104 This function will withdraw the number of assets asked, minus the fee. Example: If the fee is 10% and 100 assets was the input, this function will withdraw 90 assets.

Parameters

NameTypeDescription

assets

uint256

assets amount

receiver

address

receiver address

owner

address

owner address

Returns

NameTypeDescription

shares

uint256

shares amount

mint

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L146

function mint(uint256 shares, address receiver) external nonpayable returns (uint256)

Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. - MUST emit the Deposit event. - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint. - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.

Parameters

NameTypeDescription

shares

uint256

undefined

receiver

address

undefined

Returns

NameTypeDescription

_0

uint256

undefined

mintWithPermit

https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L159

function mintWithPermit(uint256 shares, address receiver, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable returns (uint256)

Mint shares with permit, a gasless token approval.

Mints exactly shares to receiver by depositing amount of underlying tokens. For more information on the signature format, see the EIP2612 specification: https://eips.ethereum.org/EIPS/eip-2612#specification

Parameters

NameTypeDescription

shares

uint256

undefined

receiver

address

undefined

deadline

uint256

undefined

v

uint8

undefined

r

bytes32

undefined

s

bytes32

undefined

Returns

NameTypeDescription

_0

uint256

undefined

Last updated