angle-core
repo.StableMaster
contract handles all the collateral types accepted for a given stablecoin. It does all the accounting, contains the logic for the fees and directly interacts with the AgToken
and SanToken
contracts handling respectively Angle's stablecoins and SLP tokens.closePerpetual()
: for a HA to close position and get the current amount of her position depending on the entry oracle value and the current oracle valueaddToPerpetual()
: for a HA to decrease the leverage of a given position by adding collateral to itremoveFromPerpetual()
: for a HA to cash out some collateral of a perpetual she controls and hence increase leverageforceClosePerpetuals()
: forces the cash out of perpetuals in the case where the amount covered by Hedging Agents is too big compared with what they can coverCore
contract maintains the integrity of the module, it is the contract storing the addresses with the governor role and the guardian address. It also stores the references to all the stablecoins of the Core Module (all the StableMaster
contracts). Whenever there is a new governor address in Angle, then Core
makes sure that this change is effective across most contracts of Angle's protocol.Core
contract does not propagate changes to some bricks of the module like the oracle contracts.AgToken
contracts are the contracts representing these stablecoins, they are all associated to a StableMaster
contract, which is the only contract within this module with the ability to mint agTokens or burn it against collateral.AgToken
contracts are upgradeable and also implement EIP-2612 which thanks to the permit function enables gas-less transfers and single transaction approve+actions.SanToken
contracts represent these tokens. There is one SanToken
contract per pair stablecoin/collateral.AgToken
contracts, all SanToken
contracts are upgradeable and also implement EIP-2612.AgToken
contracts, only the corresponding StableMaster
contract can mint sanTokens or burn it against the corresponding amount of collateral.PoolManager
contract per pair stablecoin/collateral. Whenever a new collateral is deployed for a stablecoin, a specific PoolManager
should be deployed.StableMaster
in case of gains or losses. This contract stores all the collateral for a pool, and it is the only place of the module that holds collateral. For instance, when a user calls the StableMaster
to get stablecoins from collateral, this collateral sent is directly transferred to the PoolManager
that corresponds. The role of the PoolManager
is then to make efficient use of this collateral through strategies in order to get yield on it.FeeManager
contracts are the place with which keepers interact. There is one FeeManager
contract per pair stablecoin/collateral.FeeManager
contract, governance can induce a dependence on the collateral ratio too.updateUsersSLP()
: to change parameters linked to stable holders and SLPs in the corresponding StableMaster
updateHA()
: to change the parameters related to HAs opening and closing their perpetuals in PerpetualManager
StableMaster
, PerpetualManager
).PoolManager
contract and the different yield farming platforms associated to it.Lender
contract is the interface between the protocol and a lending platform in the context of the first strategy implemented by the module. There is one such contract per lending or yield farming platform associated to a strategy. Each contract contains the logic associated to its corresponding platform.Strategy
contracts (one per collateral), and 4 different Lending
contracts (two per Strategy
).Strategy
contracts when it comes to adjusting debt ratios to lending strategies and recording capital gains by calling the harvest
function.external
folder of the repo. Still, for the particular needs of the protocol, some libraries and contracts were developed internally to be reused at different places of the code.Pausable
contract and generalizes it. Like the contract above, this module can only be used through inheritance.StableMaster
contract to pause mint or burn of stablecoins against a given collateral but not against another collateral.GOVERNOR_ROLE
and GUARDIAN_ROLE
introduced in the global section, this module introduces a set of different roles and permissions. These include:CORE_ROLE
KEEPER_ROLE
STABLEMASTER_ROLE
POOLMANAGER_ROLE
STRATEGY_ROLE
FEEMANAGER_ROLE
Core
contract maintains the integrity of these roles across all the contracts of the module.CORE_ROLE
enables to make some changes to the underlying StableMaster
contracts. It is given to the Core
contract. When changes need to be propagated across all the contracts of the protocol (like a guardian getting revoked, or a new governor being promoted), then the core calls the functions of the StableMaster
notifying this change.StableMaster
contract like the governor, the guardian or the aToken role.STABLEMASTER_ROLE
is found in the PoolManager
, the AgToken
and the SanToken
contracts. It is only given to StableMaster
contracts. It serves to propagating governance changes from the StableMaster
contract and to ask the AgToken
and SanToken
contracts to mint or burn their underlying tokens.PoolManager
is basically to hub when it comes to a stablecoin/collateral pair, most of the changes in parameters or in oracles related to a pair go through this type of contract.POOLMANAGER_ROLE
, PoolManager
contracts are able to communicate with all contracts of the protocol associated to their collateral. It is for instance used in the FeeManager
, Strategy
and PerpetualManager
contracts to propagate governance changes.Strategy
contracts to let them interact with the corresponding PoolManager
contract and report their gains or lossesFEEMANAGER_ROLE
is given to the FeeManager
contracts allowed to update some protocol parameters (including fee and slippage for SLPs) as a function of the collateral ratio or of some other parameters.StableMaster
and PerpetualManager
contracts with which FeeManager
contracts interact.PERPETUALMANAGER_ROLE
is indirectly used in the StableMaster
contract when a PerpetualManager
seeks to call updateStockUsers
.