Treasurycontract is the contract handling the accounting across all the
VaultManagercontracts of a stablecoin. It is the one which responsible to redistribute profits to governance. The role of the
Treasurycontract is also to manage the different
VaultManagercontracts by granting minting rights on the AgToken to new contracts or by removing this right to others.
Treasurycontract per stablecoin of the protocol within this module.
Initializable. This contract is upgradeable.
core: Reference to the
CoreBorrowcontract of the module which handles all AccessControl logic
flashLoanModule: Flash Loan Module with a minter right on the stablecoin
stablecoin: Stablecoin handled by this contract.
surplusManager: Address responsible for handling the surplus made by the treasury
vaultManagerList: List of the accepted
VaultManagerof the protocol for this stablecoin
vaultManagerMap: Maps an address to whether it was initialized as a
badDebt: Amount of bad debt (unbacked stablecoin) accumulated across all
VaultManagercontracts linked to this stablecoin
surplusBuffer: Surplus amount accumulated by the contract waiting to be distributed to governance. Technically only a share of this
surplusBufferwill go to governance. Once a share of the surplus buffer has been given to governance, then this surplus is reset
surplusForGovernance: Share of the
surplusBufferdistributed to governance (in
surplusManagercontract. This function makes sure to fetch surplus from all
VaultManagercontracts and from the flashloan module if it is initialized to make sure no surplus is given to governance if bad debt accrued somewhere. Typically this function is to be called once every week by a keeper to distribute rewards to veANGLE holders.
VaultManager). If surplus is bigger than bad debt (or is bigger than the bad debt accrued during previous calls), then a buffer is stored and this function splits this buffer between a portion for governance and a portion for the protocol's reserves. The portion for governance is sent to the
surplusManageraddress. There is no storage variable which keeps track of the protocol's reserves.
governanceAllocation: Amount of stablecoins for governance
amountis greater than the current value of the
pushSurplusfunction can be used for this.
fetchSurplusFromAll: Fetches the surplus accrued across all the
VaultManagercontracts controlled by this
Treasurycontract as well as from the fees of the
FlashLoanmodule (if initialized)
fetchSurplusFromFlashLoan: Fetches the surplus accrued in the flash loan module and updates the
surplusBuffer. It reverts if the
flashLoanModulehas not been initialized
VaultManageror the flashloan module:
addMinter: Adds a new minter for the stablecoin
addVaultManager: Adds a new
removeMinter: Removes a minter from the stablecoin contract
removeVaultManager: Removes a
recoverERC20: For governance to recover tokens mistakenly sent or accruing to this contract
setTreasury: Changes the treasury contract and communicates this change to all
setSurplusForGovernance: Sets the
setSurplusManager: Sets the
surplusManagercontract responsible for handling the surplus of the protocol
setCore: Sets a new
setFlashLoanModule: Sets a new flash loan module for this stablecoin
VaultManagercontracts to verify roles of addresses calling it:
isVaultManager: Checks whether an address is a
isGovernor: Checks whether an address has the
GOVERNOR_ROLEin the associated
isGovernorOrGuardian: Checks whether an address has the