PoolAccountant
PoolAccountant
This contract is the "accountant" for Vesper pools which keeps records of strategies. Each deployed pool has one associated accountant.
VERSION
string VERSION
MAX_BPS
uint256 MAX_BPS
EarningReported
event EarningReported(address strategy, uint256 profit, uint256 loss, uint256 payback, uint256 strategyDebt, uint256 poolDebt, uint256 creditLine)
LossReported
event LossReported(address strategy, uint256 loss)
StrategyAdded
event StrategyAdded(address strategy, uint256 debtRatio, uint256 externalDepositFee)
StrategyRemoved
event StrategyRemoved(address strategy)
StrategyMigrated
event StrategyMigrated(address oldStrategy, address newStrategy)
UpdatedExternalDepositFee
event UpdatedExternalDepositFee(address strategy, uint256 oldFee, uint256 newFee)
UpdatedPoolExternalDepositFee
event UpdatedPoolExternalDepositFee(uint256 oldFee, uint256 newFee)
UpdatedStrategyDebtRatio
event UpdatedStrategyDebtRatio(address strategy, uint256 oldDebtRatio, uint256 newDebtRatio)
init
function init(address _pool) public
This init function meant to be called after proxy deployment. DO NOT CALL it with proxy deploy; only after the proxy has been successfully deployed.
_pool
address
Address of Vesper pool proxy
addStrategy
function addStrategy(address _strategy, uint256 _debtRatio, uint256 _externalDepositFee) public
Add strategy. Once a strategy is added it can call rebalance and borrow funds from the pool and invest those funds in a provider/lender.
Recalculate pool level external deposit fee after all state variables are updated.
_strategy
address
Strategy address
_debtRatio
uint256
Pool fund allocation to this strategy
_externalDepositFee
uint256
External deposit fee of strategy
setup
function setup() external
OnlyPool:: Helper function for V5 upgrade
removeStrategy
function removeStrategy(uint256 _index) external
Remove strategy and recalculate the pool level external deposit fee.
Revoke and remove strategy from the strategy array. Update withdraw queue. Withdraw queue order should not change after remove. Strategy can be removed only after it has paid all debt. Use he migratestrategy function if debt is not paid and you want to upgrade the strategy.
updateExternalDepositFee
function updateExternalDepositFee(address _strategy, uint256 _externalDepositFee) external
Update external deposit fee of the strategy and recalculate the pool level external deposit fee.
_strategy
address
Strategy address for which external deposit fee is being updated
_externalDepositFee
uint256
New external deposit fee
recalculatePoolExternalDepositFee
function recalculatePoolExternalDepositFee() external
Recalculate the pool external deposit fee. It is calculated using debtRatio and the external deposit fee of each strategy.
Whenever debtRatio changes, recalculation is required. DebtRatio changes if a strategy reports loss, in which case an off-chain application can watch for it and take action accordingly. This function is 'gas heavy', so we do not want to call it during reportLoss.
sweepERC20
function sweepERC20(address _fromToken) external virtual
Transfer given ERC20 token to pool
_fromToken
address
Token address to sweep
updateDebtRatio
function updateDebtRatio(address _strategy, uint256 _debtRatio) external
Update debt ratio.
A strategy is retired when its debtRatio is 0. As debtRatio impacts pool level external deposit fee, it must be recalculated after updating debtRatio.
_strategy
address
Strategy address for which debt ratio is being updated
_debtRatio
uint256
New debt ratio
updateWithdrawQueue
function updateWithdrawQueue(address[] _withdrawQueue) external
Update withdraw queue. Withdraw queue is a list of strategies in the order in which funds should be withdrawn.
Pool always keeps some buffer amount to satisfy withdrawal requests. Any withdrawal request higher than what is in the buffer will cause withdrawal from the withdraw queue. So withdrawQueue[0] will be the first strategy where withdrawal request will be sent.
_withdrawQueue
address[]
Ordered list of strategy.
migrateStrategy
function migrateStrategy(address _old, address _new) external
Migrate an existing strategy to new strategy.
Migrating strategy aka old and new strategy should be of same type. New strategy will replace old strategy in strategy mapping, strategies array, withdraw queue.
_old
address
Address of strategy being migrated
_new
address
Address of new strategy
reportEarning
function reportEarning(address _strategy, uint256 _profit, uint256 _loss, uint256 _payback) external returns (uint256 _actualPayback, uint256 _creditLine)
Strategy calls this at regular intervals.
_strategy
address
_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(address _strategy, uint256 _loss) external
Update strategy loss.
_strategy
address
Strategy which incur loss
_loss
uint256
Loss of strategy
decreaseDebt
function decreaseDebt(address _strategy, uint256 _decreaseBy) external
Decrease debt of strategy; this also decreases totalDebt.
In case of withdraw from strategy, pool will decrease debt by the amount withdrawn
_strategy
address
Strategy Address
_decreaseBy
uint256
Amount by which strategy debt will be decreased
availableCreditLimit
function availableCreditLimit(address _strategy) external view returns (uint256)
Get available credit limit of strategy. This is the amount strategy can borrow from the pool.
Available credit limit is calculated based on current debt of pool and strategy and the current debt limit of pool and strategy. credit available = min(pool's debt limit, strategy's debt limit, max debt per rebalance). When any strategy does not pay back its outstanding debt, this impacts the credit line of other strategies if totalDebt of pool >= debtLimit of pool
_strategy
address
Strategy address
excessDebt
function excessDebt(address _strategy) external view returns (uint256)
Debt above current debt limit
_strategy
address
Address of strategy
getStrategies
function getStrategies() external view returns (address[])
Return the strategies array.
getWithdrawQueue
function getWithdrawQueue() external view returns (address[])
Return withdrawQueue array.
totalDebtOf
function totalDebtOf(address _strategy) external view returns (uint256)
Get total debt of given strategy.
_strategy
address
Strategy address
Last updated
Was this helpful?