VPOOL
All Vesper pools are implementations of VPOOL. This contract performs the core functions for all Vesper pools, including deposits, withdrawals, fee calculation
string VERSION
uint256 MAX_BPS
uint256 ONE_YEAR
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.
Name | Type | Description |
---|---|---|
_amount | uint256 | ERC20 token amount. |
function depositAndClaim(uint256 _amount) external
Deposit ERC20 tokens and claim rewards, if there are any.
Name | Type | Description |
---|---|---|
_amount | uint256 | ERC20 token amount. |
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 |
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. |
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. |
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. |
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 |
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. |
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 |
function sweepERC20(address _fromToken) external
Transfer given ERC20 token to governor
Name | Type | Description |
---|---|---|
_fromToken | address | Token address to sweep |
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 |
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
Name | Type | Description |
---|---|---|
_strategy | address | Address of strategy |
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
Name | Type | Description |
---|---|---|
_strategy | address | Strategy address |
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
Name | Type | Description |
---|---|---|
_amount | uint256 | Collateral amount |
Name | Type | Description |
---|---|---|
_shares | uint256 | Amount of share that user will get |
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.
Name | Type | Description |
---|---|---|
_amount | uint256 | Collateral amount in collateral token defined decimals. |
Name | Type | Description |
---|---|---|
[0] | uint256 | share amount in 18 decimal |
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.
Name | Type | Description |
---|---|---|
_old | address | Address of strategy being migrated |
_new | address | Address of new strategy |
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
Name | Type | Description |
---|---|---|
_newMaxProfitAsFee | uint256 | New max profit as fee |
function updateMinimumDepositLimit(uint256 _newLimit) external
Only Governor:: Update minimum deposit limit
Name | Type | Description |
---|---|---|
_newLimit | uint256 | New minimum deposit limit |
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 |
function updatePoolRewards(address _newPoolRewards) external
Update pool rewards address for this pool
Name | Type | Description |
---|---|---|
_newPoolRewards | address | new pool rewards address |
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.
Name | Type | Description |
---|---|---|
_keeperAddress | address | keeper address to add. |
function removeKeeper(address _keeperAddress) external
Remove given address from keepers list.
Name | Type | Description |
---|---|---|
_keeperAddress | address | keeper address to remove. |
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.
Name | Type | Description |
---|---|---|
_maintainerAddress | address | maintainer address to add. |
function removeMaintainer(address _maintainerAddress) external
Remove given address from maintainers list.
Name | Type | Description |
---|---|---|
_maintainerAddress | address | maintainer address to remove. |
Last modified 7mo ago