All Vesper pools are implementations of VPOOL. This contract performs the core functions for all Vesper pools, including deposits, withdrawals, fee calculation
event UpdatedMaximumProfitAsFee(uint256 oldMaxProfitAsFee, uint256 newMaxProfitAsFee)
event UpdatedMinimumDepositLimit(uint256 oldDepositLimit, uint256 newDepositLimit)
event Deposit(address owner, uint256 shares, uint256 amount)
event Withdraw(address owner, uint256 shares, uint256 amount)
event UpdatedUniversalFee(uint256 oldUniversalFee, uint256 newUniversalFee)
event UpdatedPoolRewards(address previousPoolRewards, address newPoolRewards)
event UpdatedWithdrawFee(uint256 previousWithdrawFee, uint256 newWithdrawFee)
event UniversalFeePaid(uint256 strategyDebt, uint256 profit, uint256 fee)
constructor(string _name, string _symbol, address _token) public
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.
function deposit(uint256 _amount) external
Deposit ERC20 tokens and receive pool shares depending on the current share price.
function depositAndClaim(uint256 _amount) external
Deposit ERC20 tokens and claim rewards, if there are any.
function depositWithPermit(uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) external
Deposit ERC20 tokens with permit, aka gasless approval.
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.
function withdraw(uint256 _shares) external
Withdraw collateral based on given shares and the current share price. Burn remaining shares and return collateral.
function withdrawAndClaim(uint256 _shares) external
Withdraw collateral and claim rewards, if any.
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.
function reportEarning(uint256 _profit, uint256 _loss, uint256 _payback) external
Strategy call this in regular interval. Only strategy function.
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.
function sweepERC20(address _fromToken) external
Transfer given ERC20 token to governor
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
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.
function excessDebt(address _strategy) external view returns (uint256)
Debt above current debt limit
function getStrategies() external view returns (address)
function totalDebt() external view returns (uint256)
Get total debt of pool
function totalDebtOf(address _strategy) external view returns (uint256)
Get total debt of given strategy
function totalDebtRatio() external view returns (uint256)
Get total debt ratio. Total debt ratio helps us keep buffer in pool
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
function getWithdrawQueue() public view returns (address)
function pricePerShare() public view returns (uint256)
Get price per share
Return value will be in token defined decimals.
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)
function tokensHere() public view returns (uint256)
Returns the token stored in the pool. It will be in token defined decimals.
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.
function _beforeBurning(uint256 _share) private returns (uint256 _actualWithdrawn, bool _isPartial)
Before burning hook. withdraw amount from strategies
function _calculateShares(uint256 _amount) private view returns (uint256)
Calculate shares to mint/burn based on the current share price and given amount.
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.
function _calculateUniversalFee(uint256 _lastRebalance, uint256 _totalDebt, uint256 _profit) private view returns (uint256 _fee)
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.
function setup() external
OnlyGovernor:: Helper function for V5 upgrade
function updateMaximumProfitAsFee(uint256 _newMaxProfitAsFee) external
Only Governor:: Update maximum profit that can be used as universal fee
function updateMinimumDepositLimit(uint256 _newLimit) external
Only Governor:: Update minimum deposit limit
function updateUniversalFee(uint256 _newUniversalFee) external
Update universal fee for this pool
Format: 1500 = 15% fee, 100 = 1%
function updatePoolRewards(address _newPoolRewards) external
Update pool rewards address for this pool
function pause() external
function unpause() external
function shutdown() external
function open() external
function keepers() external view returns (address)
Return list of keepers
function isKeeper(address _address) external view returns (bool)
function addKeeper(address _keeperAddress) external
Add given address in keepers list.
function removeKeeper(address _keeperAddress) external
Remove given address from keepers list.
function maintainers() external view returns (address)
Return list of maintainers
function isMaintainer(address _address) external view returns (bool)
function addMaintainer(address _maintainerAddress) external
Add given address in maintainers list.
function removeMaintainer(address _maintainerAddress) external
Remove given address from maintainers list.