IAssetManager
Asset managers are contracts that can be plugged into a reserve (eTokens or PremiumsAccounts). They have the responsibility of managing the assets of the contract and reinvesting them in other DeFi protocols to generate additional yields. IAssetManager
defines the interface of these asset managers that can later have several implementations diverging mostly in where the funds are invested and in how much of the funds are invested and how much remains as liquid funds in the reserve contract.
They operate in the context of the reserves, behind specific functions that use delegatecalls to the asset manager interface. In a way, the assets managers aren't itself contracts, but instead, they are code chunks that are plugged into the reserve contract.
Events
MoneyInvested
Event emitted when funds are removed from Reserve liquidity and invested in the investment strategy.
amount
uint256
The amount invested
MoneyDeinvested
Event emitted when funds are deinvested from the investment strategy and returned to the reserve as liquid funds.
amount
uint256
The amount de-invested
EarningsRecorded
Event emitted when investment yields are accounted in the reserve.
earnings
int256
The amount of earnings generated since last record. It's positive in the case of earnings or negative when there are losses.
External Methods
connect
Function called when an asset manager is plugged into a reserve. Useful for initialization tasks.
rebalance
Gives the opportunity to the asset manager to rebalance the funds between those that are kept liquid in the reserve balance and those that are invested. Called with delegatecall by the reserve from the external function rebalance (see {Reserve-rebalance}).
Events:
Emits {MoneyInvested} or {MoneyDeinvested}
recordEarnings
Gives the opportunity to the asset manager to rebalance the funds between those that are kept liquid in the reserve balance and those that are invested. Called with delegatecall by the reserve from the external function rebalance (see {Reserve-rebalance}).
Events:
Emits {MoneyInvested} or {MoneyDeinvested}
refillWallet
Refills the reserve balance with enough money to do a payment. Called from the reserve when a payment needs to be made and there's no enough liquid balance (currency().balanceOf(reserve) < paymentAmount
)
Events:
Emits {MoneyDeinvested} with the amount transferred to the liquid balance.
paymentAmount
uint256
The total amount of the payment that needs to be made. If this function is called, it's because paymentAmount > balanceOf(reserve). The minimum amount that needs to be transferred to the reserve is paymentAmount - balanceOf(reserve)
, but it can transfer more.
[0]
uint256
Returns the actual amount transferred
deinvestAll
Deinvests all the funds transfer all the assets to the liquid balance. Called from the reserve when the asset manager is unplugged.
Events:
Emits {MoneyDeinvested} with the amount transferred to the liquid balance.
Emits {EarningsRecorded} with the amount of earnings since earnings were recorded last time.
[0]
int256
Returns the earnings or losses (negative) since last time earnings were recorded.
Last updated