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

Name
Type
Description

_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

Name
Type
Description

_0

uint256

Max Fee boundary

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

Name
Type
Description

_0

uint256

Initial deposit amount

configuration

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

Returns

Name
Type
Description

_0

address

ConfigurationManager address

View Methods

currentRoundId

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

Returns the current round ID.

Returns

Name
Type
Description

_0

uint32

current round Id

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

Name
Type
Description

_0

bool

Is processing deposits boolean

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

Name
Type
Description

_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

Outputs addresses in the deposit queue

Returns

Name
Type
Description

_0

address[]

addresses in deposit queue

controller

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

Returns the vault controller

Returns

Name
Type
Description

_0

address

Controller address

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

Name
Type
Description

owner

address

Owner address

Returns

Name
Type
Description

_0

uint256

Amount of Idle Assets

getWithdrawFeeRatio

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

Returns the fee charged on withdraws.

Returns

Name
Type
Description

_0

uint256

Withdraw Fee Ratio

depositQueueSize

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

Outputs current size of the deposit queue.

Returns

Name
Type
Description

_0

uint256

Queue Size

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

Name
Type
Description

_0

address

Owner address

Returns

Name
Type
Description

_0

uint256

Max amount of underlying to deposit

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

Name
Type
Description

_0

address

Owner Address

Returns

Name
Type
Description

_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

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

Name
Type
Description

owner

address

Owner Address

Returns

Name
Type
Description

_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

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

Name
Type
Description

owner

address

Owner Address

Returns

Name
Type
Description

_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

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

Name
Type
Description

_0

uint256

undefined

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

Name
Type
Description

_0

uint256

undefined

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

Name
Type
Description

shares

uint256

Shares amount

Returns

Name
Type
Description

_0

uint256

Assets amount

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

Name
Type
Description

assets

uint256

Assets amount

Returns

Name
Type
Description

_0

uint256

Shares Amount

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

Name
Type
Description

assets

uint256

assets

receiver

address

receiver

Returns

Name
Type
Description

_0

uint256

shares

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

Name
Type
Description

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

Name
Type
Description

_0

uint256

shares amount

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

Name
Type
Description

assets

uint256

undefined

receiver

address

undefined

Returns

Name
Type
Description

_0

uint256

Estimation of shares created.

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

Name
Type
Description

depositors

address[]

Array of owner addresses to process

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

Name
Type
Description

shares

uint256

shares amount

receiver

address

receiver address

owner

address

owner address

Returns

Name
Type
Description

assets

uint256

assets amount

refund

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

Withdraw all user assets in unprocessed deposits.

Returns

Name
Type
Description

assets

uint256

assets amount

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

Name
Type
Description

_0

uint32

The new round id

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

Name
Type
Description

assets

uint256

assets amount

receiver

address

receiver address

owner

address

owner address

Returns

Name
Type
Description

shares

uint256

shares amount

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

Name
Type
Description

shares

uint256

undefined

receiver

address

undefined

Returns

Name
Type
Description

_0

uint256

undefined

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

Name
Type
Description

shares

uint256

undefined

receiver

address

undefined

deadline

uint256

undefined

v

uint8

undefined

r

bytes32

undefined

s

bytes32

undefined

Returns

Name
Type
Description

_0

uint256

undefined

Last updated