PoolAccountant
PoolAccountant
This contract is the "accountant" for Vesper pools which keeps records of strategies. Each deployed pool has one associated accountant.
VERSION
MAX_BPS
EarningReported
LossReported
StrategyAdded
StrategyRemoved
StrategyMigrated
UpdatedExternalDepositFee
UpdatedPoolExternalDepositFee
UpdatedStrategyDebtRatio
init
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.
addStrategy
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.
setup
OnlyPool:: Helper function for V5 upgrade
removeStrategy
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
Update external deposit fee of the strategy and recalculate the pool level external deposit fee.
recalculatePoolExternalDepositFee
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
Transfer given ERC20 token to pool
updateDebtRatio
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.
updateWithdrawQueue
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.
migrateStrategy
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.
reportEarning
Strategy calls this at regular intervals.
reportLoss
Update strategy loss.
decreaseDebt
Decrease debt of strategy; this also decreases totalDebt.
In case of withdraw from strategy, pool will decrease debt by the amount withdrawn
availableCreditLimit
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
excessDebt
Debt above current debt limit
getStrategies
Return the strategies array.
getWithdrawQueue
Return withdrawQueue array.
totalDebtOf
Get total debt of given strategy.
Last updated