VPOOL

VPool

All Vesper pools are implementations of VPOOL. This contract performs the core functions for all Vesper pools, including deposits, withdrawals, fee calculation

VERSION

string VERSION

MAX_BPS

uint256 MAX_BPS

ONE_YEAR

uint256 ONE_YEAR

UpdatedMaximumProfitAsFee

event UpdatedMaximumProfitAsFee(uint256 oldMaxProfitAsFee, uint256 newMaxProfitAsFee)

UpdatedMinimumDepositLimit

event UpdatedMinimumDepositLimit(uint256 oldDepositLimit, uint256 newDepositLimit)

Deposit

event Deposit(address owner, uint256 shares, uint256 amount)

Withdraw

event Withdraw(address owner, uint256 shares, uint256 amount)

UpdatedUniversalFee

event UpdatedUniversalFee(uint256 oldUniversalFee, uint256 newUniversalFee)

UpdatedPoolRewards

event UpdatedPoolRewards(address previousPoolRewards, address newPoolRewards)

UpdatedWithdrawFee

event UpdatedWithdrawFee(uint256 previousWithdrawFee, uint256 newWithdrawFee)

UniversalFeePaid

event UniversalFeePaid(uint256 strategyDebt, uint256 profit, uint256 fee)

constructor

constructor(string _name, string _symbol, address _token) public

initialize

function initialize(string _name, string _symbol, address _token, address _poolAccountant) public

Equivalent to a constructor for the proxy. It can be called only once per proxy.

deposit

function deposit(uint256 _amount) external

Deposit ERC20 tokens and receive pool shares depending on the current share price.

Name
Type
Description

_amount

uint256

ERC20 token amount.

depositAndClaim

function depositAndClaim(uint256 _amount) external

Deposit ERC20 tokens and claim rewards, if there are any.

Name
Type
Description

_amount

uint256

ERC20 token amount.

depositWithPermit

function depositWithPermit(uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) external

Deposit ERC20 tokens with permit, aka gasless approval.

Name
Type
Description

_amount

uint256

ERC20 token amount.

_deadline

uint256

The time at which signature will expire

_v

uint8

The recovery byte of the signature

_r

bytes32

Half of the ECDSA signature pair

_s

bytes32

Half of the ECDSA signature pair

whitelistedWithdraw

function whitelistedWithdraw(uint256 _shares) external

Withdraw collateral based on given shares and the current share price. Burn remaining shares and return collateral. Claim rewards if there are any

Deprecated method. Keeping this method here for backward compatibility.

Name
Type
Description

_shares

uint256

Pool shares. It will be in 18 decimals.

withdraw

function withdraw(uint256 _shares) external

Withdraw collateral based on given shares and the current share price. Burn remaining shares and return collateral.

Name
Type
Description

_shares

uint256

Pool shares. It will be in 18 decimals.

withdrawAndClaim

function withdrawAndClaim(uint256 _shares) external

Withdraw collateral and claim rewards, if any.

Name
Type
Description

_shares

uint256

Pool shares. It will be in 18 decimals.

multiTransfer

function multiTransfer(address[] _recipients, uint256[] _amounts) external returns (bool)

Transfer tokens to multiple recipients

Address array and amount array are 1:1 and are in order.

Name
Type
Description

_recipients

address[]

array of recipient addresses

_amounts

uint256[]

array of token amounts

Name
Type
Description

[0]

bool

true/false

reportEarning

function reportEarning(uint256 _profit, uint256 _loss, uint256 _payback) external

Strategy call this in regular interval. Only strategy function.

Name
Type
Description

_profit

uint256

yield generated by strategy. Strategy get performance fee on this amount

_loss

uint256

Reduce debt ,also reduce debtRatio, increase loss in record.

_payback

uint256

strategy willing to payback outstanding above debtLimit. no performance fee on this amount. when governance has reduced debtRatio of strategy, strategy will report profit and payback amount separately.

reportLoss

function reportLoss(uint256 _loss) external

Report loss outside of rebalance activity.

Some strategies pay deposit fee thus realizing loss at deposit. For example: Curve's 3pool has some slippage due to deposit of one asset in 3pool. Strategy may want report this loss instead of waiting for next rebalance.

Name
Type
Description

_loss

uint256

Loss that strategy want to report

sweepERC20

function sweepERC20(address _fromToken) external

Transfer given ERC20 token to governor

Name
Type
Description

_fromToken

address

Token address to sweep

availableCreditLimit

function availableCreditLimit(address _strategy) external view returns (uint256)

Get available credit limit of strategy. This is the amount strategy can borrow from pool

Available credit limit is calculated based on current debt of pool and strategy, current debt limit of pool and strategy. credit available = min(pool's debt limit, strategy's debt limit, max debt per rebalance) when some strategy do not pay back outstanding debt, this impact credit line of other strategy if totalDebt of pool >= debtLimit of pool

Name
Type
Description

_strategy

address

Strategy address

calculateUniversalFee

function calculateUniversalFee(uint256 _profit) external view returns (uint256 _fee)

Calculate universal fee for calling strategy. This is only strategy function.

Earn strategies will call this during rebalance.

excessDebt

function excessDebt(address _strategy) external view returns (uint256)

Debt above current debt limit

Name
Type
Description

_strategy

address

Address of strategy

getStrategies

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

totalDebt

function totalDebt() external view returns (uint256)

Get total debt of pool

totalDebtOf

function totalDebtOf(address _strategy) external view returns (uint256)

Get total debt of given strategy

Name
Type
Description

_strategy

address

Strategy address

totalDebtRatio

function totalDebtRatio() external view returns (uint256)

Get total debt ratio. Total debt ratio helps us keep buffer in pool

calculateMintage

function calculateMintage(uint256 _amount) public view returns (uint256 _shares)

Calculate how much shares user will get for given amount. Also return externalDepositFee if any.

Amount should be >= minimum deposit limit which default to 1

Name
Type
Description

_amount

uint256

Collateral amount

Name
Type
Description

_shares

uint256

Amount of share that user will get

getWithdrawQueue

function getWithdrawQueue() public view returns (address[])

pricePerShare

function pricePerShare() public view returns (uint256)

Get price per share

Return value will be in token defined decimals.

strategy

function strategy(address _strategy) public view returns (bool _active, uint256 _interestFee, uint256 _debtRate, uint256 _lastRebalance, uint256 _totalDebt, uint256 _totalLoss, uint256 _totalProfit, uint256 _debtRatio, uint256 _externalDepositFee)

tokensHere

function tokensHere() public view returns (uint256)

Returns the token stored in the pool. It will be in token defined decimals.

totalValue

function totalValue() public view returns (uint256)

Returns sum of token locked in other contracts and token stored in the pool. It will be in token defined decimals.

_beforeBurning

function _beforeBurning(uint256 _share) private returns (uint256 _actualWithdrawn, bool _isPartial)

Before burning hook. withdraw amount from strategies

_calculateShares

function _calculateShares(uint256 _amount) private view returns (uint256)

Calculate shares to mint/burn based on the current share price and given amount.

Name
Type
Description

_amount

uint256

Collateral amount in collateral token defined decimals.

Name
Type
Description

[0]

uint256

share amount in 18 decimal

_calculateUniversalFee

function _calculateUniversalFee(address _strategy, uint256 _profit) private view returns (uint256 _fee)

Calculate universal fee based on strategy's TVL, profit earned and duration between rebalance and now.

_calculateUniversalFee

function _calculateUniversalFee(uint256 _lastRebalance, uint256 _totalDebt, uint256 _profit) private view returns (uint256 _fee)

migrateStrategy

function migrateStrategy(address _old, address _new) external

Migrate existing strategy to new strategy.

Migrating strategy aka old and new strategy should be of same type.

Name
Type
Description

_old

address

Address of strategy being migrated

_new

address

Address of new strategy

setup

function setup() external

OnlyGovernor:: Helper function for V5 upgrade

updateMaximumProfitAsFee

function updateMaximumProfitAsFee(uint256 _newMaxProfitAsFee) external

Only Governor:: Update maximum profit that can be used as universal fee

Name
Type
Description

_newMaxProfitAsFee

uint256

New max profit as fee

updateMinimumDepositLimit

function updateMinimumDepositLimit(uint256 _newLimit) external

Only Governor:: Update minimum deposit limit

Name
Type
Description

_newLimit

uint256

New minimum deposit limit

updateUniversalFee

function updateUniversalFee(uint256 _newUniversalFee) external

Update universal fee for this pool

Format: 1500 = 15% fee, 100 = 1%

Name
Type
Description

_newUniversalFee

uint256

new universal fee

updatePoolRewards

function updatePoolRewards(address _newPoolRewards) external

Update pool rewards address for this pool

Name
Type
Description

_newPoolRewards

address

new pool rewards address

pause

function pause() external

unpause

function unpause() external

shutdown

function shutdown() external

open

function open() external

keepers

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

Return list of keepers

isKeeper

function isKeeper(address _address) external view returns (bool)

addKeeper

function addKeeper(address _keeperAddress) external

Add given address in keepers list.

Name
Type
Description

_keeperAddress

address

keeper address to add.

removeKeeper

function removeKeeper(address _keeperAddress) external

Remove given address from keepers list.

Name
Type
Description

_keeperAddress

address

keeper address to remove.

maintainers

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

Return list of maintainers

isMaintainer

function isMaintainer(address _address) external view returns (bool)

addMaintainer

function addMaintainer(address _maintainerAddress) external

Add given address in maintainers list.

Name
Type
Description

_maintainerAddress

address

maintainer address to add.

removeMaintainer

function removeMaintainer(address _maintainerAddress) external

Remove given address from maintainers list.

Name
Type
Description

_maintainerAddress

address

maintainer address to remove.

Last updated