Developers
Search…
πŸ₯
Core - Protocol Integrity
Maintaining the protocol unity

1. Introduction

The Core contract keeps track of all the StableMaster contracts associated to the different stablecoins of the protocol. Its main role is to facilitate governance and to allow changes at the level of the protocol (like a change in a governance address) to be propagated across all the underlying contracts of the protocol.
This is a way to reduce the trust stakeholders of Angle protocol have to place in governance, and to guarantee that whenever a reference is modified somewhere, it is automatically going to be modified in other relevant places. It removes some potential for human errors in the way the protocol is handled.
The way a governance change occurs is that it is notified by governance (or by the guardian) to the Core which then propagates this change to all the StableMaster contracts of the protocol. Each StableMaster then notifies the AgToken contract it relates to as well as all the PoolManager.
The Core contract is however not linked to all the contracts of the protocol. Among other things, The following functions do not propagate the changes they induce to some bricks of the protocol like the CollateralSettler, the BondingCurve, the staking and rewards distribution contracts and the oracle contracts using Uniswap. Governance should be wary when calling these functions and make equivalent changes in these contracts to maintain consistency at the scale of the protocol.

2. Contract Details

Interfaces

Implements ICore
The contract is not upgradeable and the reference to it can be changed in a StableMasterthrough the setCore function in governance can call in the Core contract.

Parameters

  • _governorList: List of all the governor addresses of Angle's protocol. Initially, only the timelock will be appointed governor but it may not be the only one
  • guardian: Address of the guardian of the protocol
  • _stablecoinList: List of all the stablecoins accepted by the system represented with the address of the corresponding StableMaster contract
  • governorMap: Map to track the addresses with a GOVERNOR_ROLE within Angle protocol. It has been defined to facilitate the Access Control logic in the Core contract.
  • deployedStableMasterMap: Map to track the addresses of the stableMaster contracts that have already been deployed. This is used to avoid deploying a revoked stableMaster contract again and hence potentially creating inconsistencies in the GOVERNOR_ROLE and GUARDIAN_ROLE of this stableMaster.

Access Control

There is no OpenZeppelin Access Control in this contract. The reason for this is that otherwise governor addresses could circumvent the addGovernor and removeGovernor functions through grantRole / revokeRole. Custom modifiers have thus been defined to act as equivalents to OpenZeppelin modifiers

3. Key Mechanisms & Concepts

Governor Functions Interacting with StableMasters

setCore

1
function setCore(ICore newCore) external;
Copied!
Changes the Core contract of the protocol, thus making the current Core contract useless. The governance of the new Core contract should be exactly the same of this one.
Parameters:
  • newCore: Address of the new Core contract

deployStableMaster

1
function deployStableMaster(address agToken) external;
Copied!
Adds a new stablecoin to the system. To maintain consistency, the address of the StableMaster contract corresponding to theAgToken is automatically retrieved. The StableMaster receives the reference to the governor and guardian addresses of the protocol.
The AgToken and StableMaster contracts should have previously been initialized with correct references in it, with for the StableMaster a reference to the Core contract and for the AgToken a reference to the StableMaster
Parameters:
  • agToken: Address of the new AgToken contract

revokeStableMaster

1
function revokeStableMaster(address stableMaster) external;
Copied!
Revokes a StableMaster contract. This function just removes a StableMaster contract from the stablecoinList. The consequence is that the StableMaster contract will no longer be affected by changes in governor or guardian occuring from the protocol
This function is mostly here to clean the mappings and save some storage space.
Parameters:
  • stableMaster: Address of the StableMaster to revoke

Access Control Governor Functions

The Core contract has the ability to add a new governor or remove a governor from the system and propagate this change across all underlying contracts of the protocol. The two functions existing governors can interact with to do that are:
  • addGovernor
  • removeGovernor: there must however always be one remaining governor in the protocol

Guardian Functions

The guardian can also interact with the Core contract. The guardian is indeed able to transfer its power to another address or to revoke itself. Changing or revoking a guardian from the Core will automatically echo this change across all core modules of the protocol.
Functions guardian can call are:
  • setGuardian
  • revokeGuardian

View Functions

The Core contract implements a getter governorList() for the _governorList: this is used in different places of the protocol, notably when a new collateral is deployed, for the StableMaster to fetch correct info about the governors of the protocol.
The same goes for the _stablecoinList: a getter called stablecoinList() has been implemented.