PoolAccountant

PoolAccountant

This contract is the "accountant" for Vesper pools which keeps records of strategies. Each deployed pool has one associated accountant.

VERSION

1
string VERSION
Copied!

MAX_BPS

1
uint256 MAX_BPS
Copied!

EarningReported

1
event EarningReported(address strategy, uint256 profit, uint256 loss, uint256 payback, uint256 strategyDebt, uint256 poolDebt, uint256 creditLine)
Copied!

LossReported

1
event LossReported(address strategy, uint256 loss)
Copied!

StrategyAdded

1
event StrategyAdded(address strategy, uint256 debtRatio, uint256 externalDepositFee)
Copied!

StrategyRemoved

1
event StrategyRemoved(address strategy)
Copied!

StrategyMigrated

1
event StrategyMigrated(address oldStrategy, address newStrategy)
Copied!

UpdatedExternalDepositFee

1
event UpdatedExternalDepositFee(address strategy, uint256 oldFee, uint256 newFee)
Copied!

UpdatedPoolExternalDepositFee

1
event UpdatedPoolExternalDepositFee(uint256 oldFee, uint256 newFee)
Copied!

UpdatedStrategyDebtRatio

1
event UpdatedStrategyDebtRatio(address strategy, uint256 oldDebtRatio, uint256 newDebtRatio)
Copied!

init

1
function init(address _pool) public
Copied!
This init function meant to be called after proxy deployment. DO NOT CALL it with proxy deploy
Name
Type
Description
_pool
address
Address of Vesper pool proxy

addStrategy

1
function addStrategy(address _strategy, uint256 _debtRatio, uint256 _externalDepositFee) public
Copied!
Add strategy. Once a strategy is added it can call rebalance and borrow funds from pool and invest those funds in provider/lender.
Recalculate pool level external deposit fee after all state variables are updated.
Name
Type
Description
_strategy
address
Strategy address
_debtRatio
uint256
Pool fund allocation to this strategy
_externalDepositFee
uint256
External deposit fee of strategy

setup

1
function setup() external
Copied!
OnlyPool:: Helper function for V5 upgrade

removeStrategy

1
function removeStrategy(uint256 _index) external
Copied!
Remove strategy and recalculate pool level external deposit fee.
Revoke and remove strategy from array. Update withdraw queue. Withdraw queue order should not change after remove. Strategy can be removed only after it has paid all debt. Use migrate strategy if debt is not paid and want to upgrade strategy.

updateExternalDepositFee

1
function updateExternalDepositFee(address _strategy, uint256 _externalDepositFee) external
Copied!
Update external deposit fee of strategy and recalculate pool level external deposit fee.
Name
Type
Description
_strategy
address
Strategy address for which external deposit fee is being updated
_externalDepositFee
uint256
New external deposit fee

recalculatePoolExternalDepositFee

1
function recalculatePoolExternalDepositFee() external
Copied!
Recalculate pool external deposit fee. It is calculated using debtRatio and external deposit fee of each strategy.
Whenever debtRatio changes recalculation is required. DebtRatio changes if strategy reports loss and in that case an off chain application can watch for it and take action accordingly. This function is gas heavy hence we do not want to call during reportLoss.

sweepERC20

1
function sweepERC20(address _fromToken) external virtual
Copied!
Transfer given ERC20 token to pool
Name
Type
Description
_fromToken
address
Token address to sweep

updateDebtRatio

1
function updateDebtRatio(address _strategy, uint256 _debtRatio) external
Copied!
Update debt ratio.
A strategy is retired when debtRatio is 0 As debtRatio impacts pool level external deposit fee hence recalculate it after updating debtRatio.
Name
Type
Description
_strategy
address
Strategy address for which debt ratio is being updated
_debtRatio
uint256
New debt ratio

updateWithdrawQueue

1
function updateWithdrawQueue(address[] _withdrawQueue) external
Copied!
Update withdraw queue. Withdraw queue is list of strategy in the order in which funds should be withdrawn.
Pool always keep some buffer amount to satisfy withdrawal request, any withdrawal request higher than buffer will withdraw from withdraw queue. So withdrawQueue[0] will be the first strategy where withdrawal request will be send.
Name
Type
Description
_withdrawQueue
address[]
Ordered list of strategy.

migrateStrategy

1
function migrateStrategy(address _old, address _new) external
Copied!
Migrate 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.
Name
Type
Description
_old
address
Address of strategy being migrated
_new
address
Address of new strategy

reportEarning

1
function reportEarning(address _strategy, uint256 _profit, uint256 _loss, uint256 _payback) external returns (uint256 _actualPayback, uint256 _creditLine)
Copied!
Strategy call this in regular interval.
Name
Type
Description
_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

1
function reportLoss(address _strategy, uint256 _loss) external
Copied!
Update strategy loss.
Name
Type
Description
_strategy
address
Strategy which incur loss
_loss
uint256
Loss of strategy

decreaseDebt

1
function decreaseDebt(address _strategy, uint256 _decreaseBy) external
Copied!
Decrease debt of strategy, also decrease totalDebt
In case of withdraw from strategy, pool will decrease debt by amount withdrawn
Name
Type
Description
_strategy
address
Strategy Address
_decreaseBy
uint256
Amount by which strategy debt will be decreased

availableCreditLimit

1
function availableCreditLimit(address _strategy) external view returns (uint256)
Copied!
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

excessDebt

1
function excessDebt(address _strategy) external view returns (uint256)
Copied!
Debt above current debt limit
Name
Type
Description
_strategy
address
Address of strategy

getStrategies

1
function getStrategies() external view returns (address[])
Copied!
Return strategies array

getWithdrawQueue

1
function getWithdrawQueue() external view returns (address[])
Copied!
Return withdrawQueue

totalDebtOf

1
function totalDebtOf(address _strategy) external view returns (uint256)
Copied!
Get total debt of given strategy
Name
Type
Description
_strategy
address
Strategy address