StableMasterFront.sol
StableMaster
is the contract handling all the collateral types accepted for a given stablecoin: there is one such contract per stablecoin of the protocol.stocksUsers
that is the amount of stablecoins that were minted/burnt using this collateral type, or the sanRate
that is the exchange rate between sanTokens and collateral.PoolManager
for instance). It is also at the level of this contract that governance can deploy new collateral types or set new parameters.transfer
transactions, collateral, sanTokens or agTokens is never stored on it. When someone sends collateral to the StableMaster
to get stablecoins, this collateral directly goes to the PoolManager
of the associated collateral.FunctionUtils
, AccessControlUpgradeable
, PausableMapUpgradeable
, IStableMaster
.agToken
: Reference to the agToken used in this StableMaster
_managerList
: List of all the collateral managers, that is the PoolManager
contracts handling the different types of accepted collateral_core
: Reference to the Core
contract of the protocolcollateralMap
between the corresponding PoolManager
contract to a struct of references, variables and parameters. References and variables associated to a collateral include:token
: Interface for the token accepted by the underlying PoolManager
contractsanToken
: Reference to the SanToken
for the poolperpetualManager
: Reference to the PerpetualManager
for the pooloracle
: Address of the oracle for the change rate between collateral and the corresponding stablecoinstocksUsers
: Amount of stablecoins minted using this collateral minus the amount of stablecoins that was burnt while asking for this collateral typesanRate
: Exchange rate between sanTokens and collateralcollatBase
: Base used in the collateral implementationslpData
: Struct containing parameters for SLPs in the protocolfeeData
: Struct containing the fee parameters of the protocolStableMaster
contracts recognize a collateral from the address of the PoolManager
associated associated to this collateral.lastBlockUpdated
: Last timestamp at which the sanRate
has been updated for SLPs.lockedInterests
: Fees accumulated from previous blocks and to be distributed to SLPsmaxInterestsDistributed
: Max interests used to update the sanRate
in a single block. It should be in collateral token basesanRate
does not increase by too much in a small period. Someone seeing that lots of interests are to be distributed to SLPs could for instance take a flash loan, become a SLP, receive the interests and then withdraw its collateral. By not distributing all the fees directly to SLPs and locking some interests, Angle protocol manages to avoid such manipulations.slippage
: Slippage factor that's applied to SLPs exiting (depends on collateral ratio). If it is equal to BASE
, SLPs can get nothing, if this is null, SLPs can get their full claim. The parameter is updated by keepersslippageFee
: Part of the fees normally going to SLPs that is left aside before the protocol is collateralized back again (depends on collateral ratio). Updated by keepersfeesAside
: Amount of fees left aside for SLPs and that will be distributed when the protocol is collateralized back againfeesForSLPs
: Portion of the fees from users minting and burning that goes to SLPsinterestsForSLPs
: Portion of the interests from lending going to SLPs (the rest goes to surplus)BASE_PARAMS
:xFeeMint, xFeeBurn
: Values of the thresholds to compute the minting or burning fees depending on HA coverageyFeeMint, yFeeBurn
: Values of the fees at thresholdsbonusMalusMint, bonusMalusBurn
: Minting/Burning fees correction set by the FeeManager
contract depending on the collateral ratio: they are going to be multiplied to the value of the fees computed using the hedge curve. These parameters can either serve as a bonus or as a malus. If the bonusMalus > BASE_PARAMS
, then agents incur a malus and will have larger fees, while fee < BASE_PARAMS
they incur a smaller fee than what they would have if fees just consisted in what was obtained using coverage.capOnStableMinted
: Parameter used to limit the number of stablecoins that can be issued using the concerned collateralCORE_ROLE
, the GOVERNOR_ROLE
and the GUARDIAN_ROLE
are defined in this contract with the Core
being the admin of all roles.StableMaster
needs to be called by FeeManager
and PerpetualManager
, it needs a way to recognize these contracts. The StableMaster
uses a _contractMap
that is a mapping between an address and the PoolManager
contract associated. Using this is cheaper than OpenZeppelin Access Control logic.poolManager
parameter which specifies the collateral brought or given in return (in the burn
case) . It is hence possible to come and mint agEUR for DAI and redeem USDC from these agEUR.amount
will always be taken from the msg.sender
, it is possible to have this collateral sent to another address.PoolManager
and hence the collateral brought by the user valid, the contract verifies that the collateral associated to it has well a token associated to it in the collateralMap
mapping.amount
: Amount of collateral sentuser
: Address of the contract or the person to give the minted tokens topoolManager
: Address of the PoolManager
of the required collateralminStableAmount
: Minimum amount of stablecoins the user wants to get with this transaction. This serves as a slippage protection for users.PoolManager
in exchange for that.burner
) and then send the obtained collateral to another dest
address. The msg.sender
should however have approval to burn from the burner
or the msg.sender
should be the burner.
amount
: Amount of stable asset burntburner
: Address from which the agTokens will be burntdest
: Address where collateral is going to bepoolManager
: Collateral type requested by the user burningminCollatAmount
: Minimum amount of collateral requested by the user burning stablecoins. It is a slippage protection for users.user
: Address of the SLP to send sanTokens toamount
: Amount of collateral sentpoolManager
: Address of the PoolManager
of the required collateralmsg.sender
should have approval to burn from the burner
or the msg.sender
should be the burner
.amount
: Amount of sanTokens burnt by the SLPburner
: Address that will burn its sanTokensdest
: Address that will receive the collateralpoolManager
: Address of the PoolManager
of the required collateralpoolManager
parameter in the functions). The reason is that the StableMaster
can automatically recognize the caller contract through a _contractMap
.agToken
contract. It allows the agToken
contract to update the stocksUsers
for a given collateral after a burn with no redeem.amount
: Amount by which stocksUsers
should decreasepoolManager
: Reference to PoolManager
for which stocksUsers
needs to be updatedsanRate
or locking the interests to be distributed for a short time amount of time before distributing it. This function can only be called by a PoolManager
contract having some strategies associated.gain
: Interests accumulated from lendingPoolManager
contract having some yield farming strategies associated. Fees are not accumulated for this function before being distributed: everything is directly used to decrease the sanRate.
loss
: Loss made by the yield farming strategystocksUsers
available for perpetuals. This function can only be called by the PerpetualManager
: it allows to maintain the consistency between the data in PerpetualManager
and in StableMaster
.PerpetualManager
contract when a HA wishes to cash out but there is not enough collateral in reserves.amount
: The amount to transformuser
: Address to mint sanTokens toPerpetualManager
the max amount HAs can cover.stockUsers
: The amount of stablecoins minted using the collateral corresponding to the PerpetualManager
minus the amount of stablecoins that were burnt for this collateral.updateUsersSLPs
function in the FeeManager
contract. This function can hence only be called by an accepted FeeManager
contract.manager
: Reference to the PoolManager
contract corresponding to the collateral of interest_bonusMalusMint
: New corrector of user mint fees for this collateral. These fees will correct the mint fees from users that just depend on the hedge curve by HAs by introducing other dependencies. In normal times they will be equal to BASE_PARAMS
meaning fees will just depend on coverage._bonusMalusBurn
: New corrector of user burn fees, depending on collateral ratio_slippage
: New global slippage (the SLP fees from withdrawing) factor_slippageFee
: New global slippage fee (the non distributed accumulated fees) factorStableMaster
contract contains functions that allow the Core
contract of the protocol handling all the stablecoins to change parameters in the StableMaster
and then to have this contract propagate the changes to the AgToken
contract and to all the collateral managers. The PoolManager
contracts then propagate changes to the contracts of the same pair stablecoin/collateral they are associated to like the PerpetualManager.
addGovernor()
: to add a new governor address to the governor listremoveGovernor()
: to remove an address from the governor listsetGuardian()
: to change the guardian addressrevokeGuardian()
: to revoke the guardian addresssetCore()
: to change the reference to the _core
address of the StableMaster
Core
contract, governance has the ability to directly modify some parameters and call some functions in the StableMaster
contract, especially functions regarding a given collateral.collateralMap
about the deployed collateral can directly be retrieved from the other contracts passed as reference in this function. This is the case for the associated token
which is already stored in the poolManager
contract.poolManager
: Contract managing and storing the deployed collateral for this stablecoinperpetualManager
: Contract managing HA perpetuals for this stablecoin/collateral pairoracle
: Reference to the oracle that will give the price of the collateral with respect to the stablecoinsanToken
: Reference to the sanTokens associated to the collateralpoolManager
: Reference to the contract managing this collateral for this stablecoin in the protocolsettlementContract
: Settlement contract that will be used to close everyone's positions and to let users, SLPs and HAs redeem if not all a portion of their claimSTABLE
, it is going to be impossible for users to mint stablecoins using the collateral specified by poolManager
or to burn their stablecoins against the collateral specified by poolManager
. If agent is SLP
, it is going to be impossible for SLPs to deposit the collateral corresponding to poolManager
and receive sanTokens in exchange, or to withdraw the same collateral from their sanTokensagent
: Bytes representing the agent (SLP
or STABLE
) and the collateral type that is going to be paused. To get the bytes32
from a string, we use in Solidity a keccak256
functionpoolManager
: Reference to the contract managing this collateral for this stablecoin in the protocol and for which agent
needs to be pausedagent
: Agent (SLP
or STABLE
) to unpause the action ofpoolManager
: Reference to the associated PoolManager
stocksUsers
for a given pair of collateral. This function can be called in case where the reserves of the protocol for each collateral do not exactly match what is stored in the stocksUsers
because of increases or decreases in collateral prices at times in which the protocol was not fully covered by HAs.amount
: Amount of stocksUsers
to transfer from a pool to anotherpoolManagerUp
: Reference to PoolManager
for which stocksUsers
needs to increasepoolManagerDown
Reference to PoolManager
for which stocksUsers
needs to decreaseGUARDIAN_ROLE
. Each of these functions take a PoolManager
contract as parameter:setUserFees
: Sets the x array (ie thresholds of hedge ratio) and the y array (ie values of fees at thresholds) used to compute mint and burn fees for userssetCapOnStableAndMaxInterests
: Changes the parameters to cap the number of stablecoins you can issue using one collateral type and the maximum interests you can distribute to SLPs in a sanRate update in a blocksetIncentivesForSLPs
: Sets the proportion of fees from burn/mint of users and of lending interests going to SLPs. The higher these proportions the bigger the APY for SLPssetFeeManager
: Sets a new FeeManager
contract for a given collateral and removes the old one which becomes useless