Reactorcontracts are contracts which allow people to deposit collateral which is then automatically added in a vault, and used to borrow stablecoins. They all work with an associated
VaultManagerand rely on a specific yield strategy on the borrowed stablecoins. Yield obtained is then split between the protocol and depositors of collateral.
Reactorcontracts should mostly be used for more risky collateral assets and
VaultManager, for which only whitelisted addresses can open vaults and borrow stablecoins.
Reactorcontracts rather than directly the
VaultManageris that there is a bigger protection against liquidations. Debt position is directly managed by the
Reactorwhich can pull agTokens invested in strategies as needed if the position is getting close to liquidation, or which can borrow more agTokens for more yield if position is getting healthy.
BaseReactorcontract, which conforms to the
IERC4626for yield bearing assets. Yield from these contracts is given in stablecoins.
asset: Reference to the asset controlled by this reactor. It should be the collateral of the associated `VaultManager``
stablecoin: Reference to the stablecoin this reactor handles
oracle: Oracle giving the price of the asset with respect to the stablecoin
treasury: Treasury contract handling access control
vaultManager: VaultManager contract on which this contract has a vault. While the
treasuryreferences can be automatically fetched from this address
vaultID: ID of the vault handled by this contract.
Reactorcontract only handle one specific vault
vaultManagerDust: Dust parameter for the stablecoins in a vault in
lowerCF: Lower value of the collateral factor (inverse of the collateral ratio), below this value, the reactor can borrow stablecoins
targetCF: Value of the collateral factor targeted by this vault. Each time the reactor borrows or repays stablecoins, it tries to arrive at this target value
upperCF: Value of the collateral factor above which stablecoins should be repaid to avoid liquidations
surplusManager: Address in charge of the surplus of the protocol
protocolInterestShare: Share of the gains going to the protocol
protocolInterestAccumulated: Protocol fee surplus
protocolDebt: Loss accumulated and to be repercuted on the protocol's P&L
claimableRewards: Rewards (in stablecoin) claimable by depositors of the reactor
currentLoss: Loss (in stablecoin) accumulated by the reactor: it's going to prevent the reactor from repaying its debt
rewardsAccumulator: Used to track rewards accumulated by all depositors of the reactor
claimedRewardsAccumulator: Tracks rewards already claimed by all depositors
lastTime: Last time rewards were claimed in the reactor
lastDebt: Last known stable debt to the
lastTimeOf: Maps an address to the last time it claimed its rewards
rewardsAccumulatorOf: Maps an address to a quantity depending on time and shares of the reactors used to compute the rewards an address can claim
IERC4626interface, such as
redeemfunctions, the contract automatically rebalances the strategy which means that it automatically deposits or withdraws collateral from the
VaultManagerand then pushes or pulls funds from or to the strategy. The withdrawal functions also automatically claim stablecoin rewards which accrued to an address.
_rebalanceinternal function (which has a wrapper built on top of).
_rebalancefunction which is called at each deposit or withdraw function. Based on an amount of assets to withdraw or an amount of assets received (which are 0 when this function is entered through the
rebalancefunction), this function adds or removes collateral from the associated vault of the reactor.
targetCF. If after adding or removing collateral, the collateral factor of the reactor goes above or below the
lowerCF, then stablecoins can be actually borrowed/repaid by the reactor.
dustparameter by just reading what's in the associated
setUint64: to modify collateral factors
recoverERC20: to recover tokens mistakenly sent. This function can notably be used to handle partial liquidation and debt repayment in case it is needed: in this case governance can withdraw assets, swap in stablecoins to repay debt
setSurplusManager: to change the address responsible for handling the surplus of the protocol