Architecture
Gearbox V3 separates logic for utilizing Credit Accounts into several contracts for increased modularity. These include:
Contract | Responsibility |
---|---|
CreditAccount | The Credit Account itself, which has simple logic for transferring assets and executing calls with a target and calldata passed to it by the Credit Manager. |
CreditManager | A "backend" for all Credit Account operations, which performs collateral checks and facilitates execution of both external and internal (account management) calls. It also stores important parameters and provides a unified interface for computing CA health. |
CreditFacade | A "frontend" contract that CA owners directly interact with. To manage CAs, users submit arrays of MultiCall structs that the Credit Facade parses, orchestrating the requested internal and external actions. There is always a one-to-one relationship between the Credit Facade and Credit Manager. |
CreditConfigurator | A contract that is used to change important Credit Manager and Credit Facade parameters. Can only be directly interacted with by the Gearbox DAO and some assigned controllers. There is always a one-to-one relationship between the Credit Configurator and Credit Manager. |
Adapters | A set of contracts that are used as interfaces to interact with external protocols. Adapters build the calldata that is then passed by the Credit Manager to CA for execution. Cannot be called directly; instead, calls to them must be included into Credit Facade multicalls. |
Pool | The pool is the contract that stores liquidity available for borrowing. There is always only one pool per Credit Manager, but several Credit Managers can be connected to a single pool |
PoolQuotaKeeper | PoolQuotaKeeper is a contract that stores quotas set by CA owners and tracks quota interest and quota increase fees. There is one PoolQuotaKeeper per pool. |
AccountFactory | AccountFactory is a contract that stores reusable Credit Accounts. Credit Accounts are handed off to Credit Managers on account opening, and returned on account closure. |
PriceOracle and price feeds | PriceOracle is a contract that supplies prices for collateral calculations. There are many price feeds connected to a single PriceOracle, which serves as the main entry point for all price retrieval. |
Gauge | The Gauge is a contract that computes quota interest rates and supplies them to the PoolQuotaKeeper. It is not directly involved with Credit Account operations, but can be useful for the purposes of data analysis and planning |