AccessManager

The AccessManager contract governs the roles and permissions required to manage various aspects of the TermMax protocol. It is built upon OpenZeppelin's AccessControlUpgradeable and UUPSUpgradeable modules, enabling role-based access control and upgradeable smart contract functionality.

Roles and Responsibilities

1. DEFAULT_ADMIN_ROLE

The Admin role holds the highest level of authority in the contract. It is responsible for critical administrative operations and governance. Specific responsibilities include:

  • Granting and revoking roles to other addresses.

  • Deploying new markets using the createMarket function.

  • Updating the ownership of entities through the transferOwnership function.

  • Upgrading the implementation of subcontracts using the upgradeSubContract function.

  • Configuring the GT implementation via the setGtImplement function.

Functions Accessible:

  • createMarket

  • transferOwnership

  • upgradeSubContract

  • setGtImplement


2. CURATOR_ROLE

The Curator role manages configurations and operational parameters for the TermMax protocol. Responsibilities include setting market fee rates, updating treasurer addresses, and managing whitelist settings.

Responsibilities:

  • Market Fee Management:

    • Adjusts lending, borrowing, and other fee parameters using the setMarketFeeRate function.

    • Fee rates

      • uint32 lendFeeRatio: lending fee ratio

      • uint32 minNLendFeeR: minimal lending fee ratio based on notional

      • uint32 borrowFeeRatio: borrowing fee ratio

      • uint32 minNBorrowFeeR: minimal borrowing fee ratio based on notional

      • uint32 redeemFeeRatio: redeem fee ratio

      • uint32 issueFtfeeRatio: issue FT fee ratio

      • uint32 lockingPercentage: percentage of fee locked for diamond-hand LPs

      • uint32 protocolFeeRatio: fee ratio of distributing fee to protocol

  • Treasurer Management:

    • Updates the treasurer's address with the setMarketTreasurer function.

  • Market Settings:

    • Updates parameters like lsf (liquidity scaling factor) and minting switches (setMarketLsf, setSwitchOfMintingGt).

  • Whitelist Management:

    • Controls access to markets and adapters through the setMarketWhitelist and setAdapterWhitelist functions.

Functions Accessible:

  • setMarketFeeRate

  • setMarketTreasurer

  • setMarketLsf

  • setSwitchOfMintingGt

  • setMarketWhitelist

  • setAdapterWhitelist


3. PAUSER_ROLE

The Pauser role is tasked with enabling or disabling operations for the protocol components. This ensures security and operational control during emergencies or maintenance.

Responsibilities:

  • Market State Management:

    • Pauses or unpauses specific markets using the setSwitchOfMarket function.

  • GT Functionality Management:

    • Toggles GT-specific states via the setSwitchOfGt function.

  • Router State Management:

    • Pauses or resumes router functionality with setSwitchOfRouter.

Functions Accessible:

  • setSwitchOfMarket

  • setSwitchOfGt

  • setSwitchOfRouter


Key Functionalities and Workflow

1. Role Initialization

Roles are initialized in the constructor, granting the DEFAULT_ADMIN_ROLE, CURATOR_ROLE, and PAUSER_ROLE to the specified admin address.

2. Market Deployment

The admin can deploy new markets using the createMarket function, requiring deployment parameters and an associated factory.

3. Market and Protocol Configuration

Curators adjust critical settings, including fee rates, treasury addresses, and whitelist statuses, ensuring the protocol remains configurable and operational.

4. Emergency Controls

Pausers ensure protocol safety by pausing or unpausing components, such as markets and routers, when necessary.

5. Upgradeable Architecture

The AccessManager contract is upgradeable via the UUPS mechanism, allowing the admin to deploy new implementations securely.


Security Considerations

  • Role-Based Access Control: The system uses OpenZeppelin's AccessControlUpgradeable to ensure only authorized roles perform sensitive operations.

  • Upgradeable Contract: The _authorizeUpgrade function restricts upgrades to the DEFAULT_ADMIN_ROLE.

  • Emergency Controls: The PAUSER_ROLE provides a mechanism to respond to incidents or vulnerabilities.


Events

The contract does not currently emit specific events for its operations, but integrating events for actions like role changes, market deployments, and configuration updates would enhance transparency.

Last updated