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.

depositAndClaim

function depositAndClaim(uint256 _amount) external

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

depositWithPermit

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

Deposit ERC20 tokens with permit, aka gasless approval.

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.

withdraw

function withdraw(uint256 _shares) external

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

withdrawAndClaim

function withdrawAndClaim(uint256 _shares) external

Withdraw collateral and claim rewards, if any.

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.

reportEarning

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

Strategy call this in regular interval. Only strategy function.

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.

sweepERC20

function sweepERC20(address _fromToken) external

Transfer given ERC20 token to governor

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

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

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

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

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.

_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.

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

updateMinimumDepositLimit

function updateMinimumDepositLimit(uint256 _newLimit) external

Only Governor:: Update minimum deposit limit

updateUniversalFee

function updateUniversalFee(uint256 _newUniversalFee) external

Update universal fee for this pool

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

updatePoolRewards

function updatePoolRewards(address _newPoolRewards) external

Update pool rewards address for this pool

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.

removeKeeper

function removeKeeper(address _keeperAddress) external

Remove given address from keepers list.

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.

removeMaintainer

function removeMaintainer(address _maintainerAddress) external

Remove given address from maintainers list.

Last updated