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
DENOMINATOR represents the precision for the following system variables: - MAX_WITHDRAW_FEE - INVESTOR_RATIO
Returns
MAX_WITHDRAW_FEE
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L41
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
MIN_INITIAL_ASSETS
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L47
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
configuration
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L49
Returns
View Methods
currentRoundId
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L97
Returns the current round ID.
Returns
isProcessingDeposits
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L104
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
processedDeposits
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L111
Returns the amount of processed deposits entering the next round.
Returns
queuedDeposits
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L313
Outputs addresses in the deposit queue
Returns
controller
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L325
Returns the vault controller
Returns
idleAssetsOf
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L284
Outputs the amount of asset tokens of an owner
is idle, waiting for the next round.
Parameters
Returns
getWithdrawFeeRatio
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L275
Returns the fee charged on withdraws.
Returns
depositQueueSize
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L306
Outputs current size of the deposit queue.
Returns
maxDeposit
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L226
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
Returns
maxMint
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L242
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
Returns
maxRedeem
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L264
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
Returns
maxWithdraw
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L253
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
Returns
totalAssets
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L292
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
totalIdleAssets
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L299
Outputs the amount of asset tokens is idle, waiting for the next round.
Returns
previewRedeem
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L218
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
Returns
previewWithdraw
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L211
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
Returns
Write Methods
deposit
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L118
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
Returns
depositWithPermit
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L131
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
Returns
endRound
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L347
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
Handle migrated assets.
Parameters
Returns
migrate
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L378
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
Distribute shares to depositors queued in the deposit queue, effectively including their assets in the next round.
Parameters
redeem
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L175
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
Returns
refund
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L362
Withdraw all user assets in unprocessed deposits.
Returns
startRound
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L332
Starts the next round, sending the idle funds to the strategy where it should start accruing yield.
Returns
withdraw
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L194
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
Returns
mint
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L146
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
Returns
mintWithPermit
https://github.dev/pods-finance/yield-contracts/blob/main/contracts/vaults/BaseVault.sol#L159
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
Returns
Last updated