bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 39쪽
he bitmaps are set prior to the pool being set to the relevant permission level. This is because the `hasPermission` function will always return true if the bitmaps are not set. This is by design to allow certain functions to be permissionless such as transfers if required.
### Invariants
```
* Pool Permission Manager
* Invariant A: pool.permissionLevel ∈ [0, 3]
* Invariant B: pool.bitmap ∈ [0, MAX]
* Invariant C: lender.bitmap ∈ [0, MAX]
* Invariant D: pool.permissionLevel == public -> permanently public
```
# Admin Functions
# Governor Admin Actions
## Overview
The Governor is the on‑chain `GovernorTimelock` contract managed by a multisig (and other designated roles). It controls administrative functions in the protocol. See `technical-resources/singletons/governor-timelock.md` for scheduling and execution flows.
## Governor-Permissioned Functions
### Globals
* `acceptGovernor`
* `activatePoolManager`
* `setBootstrapMint`
* `setCanDeployFrom`
* `setContractPause`
* `setDefaultTimelockParameters`
* `setFunctionUnpause`
* `setManualOverridePrice`
* `setMapleTreasury`
* `setMaxCoverLiquidationPercent`
* `setMigrationAdmin`
* `setMinCoverAmount`
* `setOperationalAdmin`
* `setPendingGovernor`
* `setPlatformManagementFeeRate`
* `setPlatformOriginationFeeRate`
* `setPlatformServiceFeeRate`
* `setPriceOracle`
* `setProtocolPause`
* `setSecurityAdmin`
* `setTimelockWindow`
* `setTimelockWindows`
* `setValidBorrower`
* `setValidCollateralAsset`
* `setValidInstanceOf`
* `setValidPoolAsset`
* `setValidPoolDelegate`
* `setValidPoolDeployer`
* `unscheduleCall`
Note: `setValidPoolDeployer` is deprecated for enabling deployers and only supports disabling. Use `setCanDeployFrom(factory, account, true)` together with `setValidInstanceOf(<FACTORY_KEY>, factory, true)` to allow deployments.
### PoolManager
* `addStrategy`
* `finishCollateralLiquidation`
* `setDelegateManagementFeeRate`
* `setIsStrategy`
* `setLiquidityCap`
* `setPendingPoolDelegate`
* `setPoolPermissionManager`
* `setWithdrawalManager` (only before initial configuration; callable prior to `completeConfiguration`)
* `triggerDefault`
### Fixed Term LoanManager
* `impairLoan`
* `removeLoanImpairment`
* `setAllowedSlippage`
* `setMinRatio`
* `updateAccounting`
### Open Term Loan
* `skim`
### Open Term Loan Manager
* `impairLoan`
* `removeLoanImpairment`
### Pool Permission Manager
* `configurePool`
* `setLenderAllowlist`
* `setLenderBitmaps`
* `setPermissionAdmin`
* `setPoolBitmaps`
* `setPoolPermissionLevel`
### Strategies Contracts
* `claimRewards` (Aave Strategy only)
* `deactivateStrategy`
* `impairStrategy`
* `reactivateStrategy`
* `setStrategyFeeRate`
* `setPsm` (Sky Strategy only)
### Upgrading Contracts
The Governor can upgrade the following contracts:
* Globals
* Liquidator
* Withdrawal Manager
# Operational Admin Actions
## Overview
The `operationalAdmin` complements the Governor's capabilities by having the authority to execute essential operational functions for routine protocol management. The role holds limited powers compared to the Governor, ensuring a balance between operational efficiency and security.
The Governor retains the exclusive authority to appoint or replace the operationalAdmin at any time.
## Operational Admin Functions
### Globals
* `activatePoolManager`
* `setBootstrapMint`
* `setCanDeployFrom`
* `setMaxCoverLiquidationPercent`
* `setMinCoverAmount`
* `setPlatformManagementFeeRate`
* `setPlatformOriginationFeeRate`
* `setPlatformServiceFeeRate`
* `setValidInstanceOf`
* `setValidPoolDelegate`
* `setValidBorrower`
### Pool Manager
* `finishCollateralLiquidation`
* `setPendingPoolDelegate`
* `triggerDefault`
* `addStrategy`
* `setDelegateManagementFeeRate`
* `setIsStrategy`
* `setLiquidityCap`
* `setPoolPermissionManager`
* `setWithdrawalManager` (only before initial configuration; callable prior to `completeConfiguration`)
### Pool Permission Manager
* `configurePool`
* `setLenderAllowlist`
* `setLenderBitmaps`
* `setPermissionAdmin`
* `setPoolBitmaps`
* `setPoolPermissionLevel`
### Strategies Contracts
* `claimRewards` (Aave Strategy only)
* `deactivateStrategy`
* `impairStrategy`
* `reactivateStrategy`
* `setStrategyFeeRate`
* `setPsm` (Sky Strategy only)
### Withdrawal Manager (Queue)
* `processEmptyRedemptions`
* `processRedemptions`
* `removeRequest`
* `setManualWithdrawal`
# Pool Delegate Admin Actions
## Overview
The Pool Delegate is responsible for administrating a Pool which involves funding Loans, defaulting/impairing Loans and configuring various parameters. Below is a detailed list of the functions a Pool Delegate can call.
## Pool Delegate Callable Functions
### PoolManager
* `upgrade`
* `acceptPoolDelegate`
* `setPendingPoolDelegate`
* `addStrategy` (only before initial configuration; callable prior to `completeConfiguration`)
* `setDelegateManagementFeeRate` (only before initial configuration; callable prior to `completeConfiguration`)
* `setIsStrategy`
* `setLiquidityCap` (only before initial configuration; callable prior to `completeConfiguration`)
* `setPoolPermissionManager` (only before initial configuration; callable prior to `completeConfiguration`)
* `setWithdrawalManager` (only before initial configuration; callable prior to `completeConfiguration`)
* `finishCollateralLiquidation`
* `triggerDefault`
### FixedTermLoanManager
* `upgrade`
* `setAllowedSlippage`
* `setMinRatio`
* `updateAccounting`
* `acceptNewTerms`
* `fund`
* `rejectNewTerms`
* `impairLoan`
* `removeLoanImpairment`
### OpenTermLoanManager
* `upgrade`
* `fund`
* `impairLoan`
* `removeLoanImpairment`
### OpenTermLoan
* `proposeNewTerms`
* `rejectNewTerms`
* `callPrincipal`
* `removeCall`
### Pool Permission Manager
* `configurePool`
* `setLenderAllowlist`
* `setLenderBitmaps`
* `setPoolBitmaps`
* `setPoolPermissionLevel`
### Strategies Contracts
* `claimRewards` (Aave Strategy only)
* `deactivateStrategy`
* `impairStrategy`
* `reactivateStrategy`
* `setStrategyFeeRate`
* `setPsm` (Sky Strategy only)
### Withdrawal Manager (Queue)
* `upgrade`
* `processEmptyRedemptions`
* `processRedemptions`
* `removeRequest`
* `setManualWithdrawal`
---
[Next Page](https://docs.maple.finance/llms-full.txt/1)
# Timelocks
## Overview
Timelocks are a mechanism to delay an action that may have significant effects. This allows any stakeholders that foresee the transaction impacting them negatively the appropriate time to react accordingly.
## Governor-Level vs Pool-Delegate Timelocks
* Governor‑privileged actions now route through a dedicated `GovernorTimelock` contract. See `technical-resources/singletons/governor-timelock.md` for roles, lifecycle, and usage.
* Pool Delegate–level timelocks (e.g., PoolManager/LoanManager/WithdrawalManager upgrades) continue to use the protocol timelock checks documented on this page.
## Affected Actions
The following actions require a timelocked execution:
* `PoolManager.upgrade()`
* `LoanManager.upgrade()`
* `WithdrawalManager.upgrade()`
## Scheduling
To perform a timelocked action Pool Delegates need to perform the following actions:
1. Call `scheduleCall()` on the `MapleGlobals` contract.
2. Wait for the predetermined time to pass.
3. Call the target contract with the same parameters.
Example:
```
Pool Delegate wants to upgrade the poolManager to v2.
1. Call `globals.scheduleCall()`, passing the PoolManager address and the "upgrade" calldata properly encoded.
2. Wait for 2 weeks.
3. Call `upgrade` directly on the PoolManager.
The PoolManager contract will perform a check against Globals to ensure the call has been properly upgraded.
```
## Configuration
Timelocks parameters are set by the `Governor` and can be changed at any time, having a retroactive effect.
Example:
```
1. Current timelock is 2 weeks
2. Actor A schedules a call to a contract.
3. After 1 week, the Governor changes the time to be 1 week.
3. A can immediately call execute the contract, since it's been 1 week since the call was scheduled.
```
# Operations
# Protocol Deployment
## Protocol Deployment
1. Confirm Governor address.
2. Confirm Treasury address.
3. Deploy MapleGlobals implementation address and verify on Etherscan.
4. Deploy MapleGlobals proxy address and verify on Etherscan, declaring the Governor and implementation address.
5. Deploy the Pool Deployer contract, declaring the MapleGlobalsV2 address.
6. Set values in the MapleGlobals contract with the Governor address (revisit this):
1. `globals.setMapleTreasury(treasury);`
2. `globals.setMigrationAdmin(migrationAdmin);`
3. `globals.setSecurityAdmin(securityAdmin);`
4. `globals.setValidPoolAsset(USDC, true); (Do for all assets)`
5. `globals.setPriceOracle(USDC, <oracleAddress>, <maxDelay>);` (Do for all assets)
6. Allow deployments via factories by combining:
* `globals.setValidInstanceOf("<FACTORY_KEY>", <factoryAddress>, true);`
* `globals.setCanDeployFrom(<factoryAddress>, <deployer>, true);` (Note: `setValidPoolDeployer` is deprecated for enabling deployers; only disabling is supported.)
7. `globals.setDefaultTimelockParameters(1 weeks, 2 days);`
7. Deploy all proxy factories, implementations, and initializers, passing in MapleGlobals to the factories:
1. Liquidator
2. LoanManager
3. PoolManager
4. WithdrawalManager
5. Ignore Loan since it has already been deployed.
8. Register implementations for all factories and set default versions:
1. Liquidator - 100
2. LoanManager - 100
3. PoolManager - 100
4. WithdrawalManager - 100
5. Ignore Loan to avoid accidental deployments of V4 loans prior to migration.
9. Allowlist all factories in Maple Globals:
1. Liquidator
2. Loan
3. LoanManager
4. PoolManager
5. WithdrawalManager
10. Transfer ownership of MapleGlobals to the governor.
1. `globals.setPendingGovernor(governor);`
2. `globals.acceptGovernor();`
At this stage, the following is true:
1. MapleGlobals is deployed and controlled by the governor
2. All factories are ready to deploy protocol contracts.
3. Allowed Assets are ready to be used in the protocol.
4. Oracles are configured.
5. Migration and Security admins are configured. Note: Governor‑privileged transactions (steps that call governor-only functions) should be scheduled and executed via the GovernorTimelock.
# Open Term Loan Deployment
## Phase 1 - Deploy New Contracts
Deploy and verify the following contracts using a single forge script:
### New PoolDeployer
1. New PoolDeployer pointing to existing mapleGlobalsProxy
### Globals and PoolManager Upgrade Contracts
1. Globals v2.0.0 implementation
2. PoolManager v2.0.0 implementation
### Fixed Term Loan Upgrade Contracts
1. MapleLoan v5.0.1 implementation
2. MapleLoanInitializer for v5.0.0 deployments
3. MapleLoanMigrator for v4.0.0 -> v5.0.0 upgrades
4. LoanManager v3.0.1 implementation
### Open Term Loan Manager Contracts
1. LoanManagerFactory
2. LoanManagerImplementation v1.0.0 implementation
3. LoanManagerInitializer for v1.0.0 deployments
### Open Term Loan Contracts
1. MapleLoanFactory
2. MapleLoanInitializer for v1.0.1 deployments
3. MapleLoanImplementation v1.0.1 implementation
4. MapleRefinancer for v1.0.1 deployments
## Phase 2 - Configuration of Protocol by Governor
This phase will be set up by the smart contracts team with JSONs and Gnosis Safe. This set of transactions will be simulated on Tenderly and validated. This will include three main actions:
1. Upgrade Globals
2. Allowlist all relevant contracts in Globals
3. Configure factories with newest contract versions
4. Upgrade all PoolManager and LoanManager contracts
5. Set canDeploy for all existing borrowers
Details are outlined below.
### Upgrade Globals
```solidity
globals.setImplementation(newGlobalsImplementation)
```
### Allowlist All Contracts
```solidity
globals_.setValidInstanceOf("LIQUIDATOR_FACTORY", liquidatorFactory, true);
globals_.setValidInstanceOf("POOL_MANAGER_FACTORY", poolManagerFactory, true);
globals_.setValidInstanceOf("WITHDRAWAL_MANAGER_FACTORY", withdrawalManagerFactory, true);
globals_.setValidInstanceOf("FT_LOAN_FACTORY", fixedTermLoanFactory, true);
globals_.setValidInstanceOf("LOAN_FACTORY", fixedTermLoanFactory, true);
globals_.setValidInstanceOf("OT_LOAN_FACTORY", openTermLoanFactory, true);
globals_.setValidInstanceOf("LOAN_FACTORY", openTermLoanFactory, true);
globals_.setValidInstanceOf("FT_LOAN_MANAGER_FACTORY", fixedTermLoanManagerFactory, true);
globals_.setValidInstanceOf("LOAN_MANAGER_FACTORY", fixedTermLoanManagerFactory, true);
globals_.setValidInstanceOf("OT_LOAN_MANAGER_FACTORY", openTermLoanManagerFactory, true);
globals_.setValidInstanceOf("LOAN_MANAGER_FACTORY", openTermLoanManagerFactory, true);
globals_.setValidInstanceOf("FT_REFINANCER", fixedTermRefinancerV2, true);
globals_.setValidInstanceOf("REFINANCER", fixedTermRefinancerV2, true);
globals_.setValidInstanceOf("OT_REFINANCER", openTermRefinancerV1, true);
globals_.setValidInstanceOf("REFINANCER", openTermRefinancerV1, true);
globals_.setValidInstanceOf("FEE_MANAGER", fixedTermFeeManagerV1, true);
globals_.setCanDeployFrom(poolManagerFactory, poolDeployerV2, true);
globals_.setCanDeployFrom(withdrawalManagerFactory, poolDeployerV2, true);
// setCanDeploy for all valid borrowers for OTL Factory
for (uint256 i; i < validBorrowers.length; ++i) {
globals_.setCanDeployFrom(openTermLoanFactory, validBorrowers[i], true);
}
```
### Configure Factories
#### Register PoolManager Version v2.0.0 and v1.0.0 -> v2.0.0 Upgrade
```solidity
poolManagerFactory.registerImplementation(200, poolManagerImplementationV200, poolManagerInitializer);
poolManagerFactory.setDefaultVersion(200);
poolManagerFactory.enableUpgradePath(100, 200, address(0));
```
#### Register FixedTermLoan Version v5.0.1 and v4.0.0 -> v5.0.1 Upgrade
```solidity
fixedTermLoanFactory.registerImplementation(501, fixedTermLoanImplementationV501, fixedTermLoanInitializerV500);
fixedTermLoanFactory.setDefaultVersion(501);
fixedTermLoanFactory.enableUpgradePath(400, 501, fixedTermLoanMigratorV500);
```
#### Register FixedTermLoanManager Version v3.0.1 and v2.0.0 -> v3.0.1 Upgrade
```solidity
fixedTermLoanManagerFactory.registerImplementation(301, fixedTermLoanManagerImplementationV301, fixedTermLoanManagerInitializerV300);
fixedTermLoanManagerFactory.setDefaultVersion(301);
fixedTermLoanManagerFactory.enableUpgradePath(200, 301, address(0));
```
#### Register OpenTermLoan Version v1.0.1
```solidity
openTermLoanFactory.registerImplementation(101, openTermLoanImplementationV101, openTermLoanInitializerV100);
openTermLoanFactory.setDefaultVersion(101);
```
#### Register OpenTermLoanManager Version v1.0.0
```solidity
openTermLoanManagerFactory.registerImplementation(100, openTermLoanManagerImplementationV100, openTermLoanManagerInitializerV100);
openTermLoanManagerFactory.setDefaultVersion(100);
```
### Upgrade all PoolManagers
Upgrade all (currently 8) outstanding PoolManager contracts.
```solidity
poolManager.upgrade(200, "0x");
```
### Upgrade all Fixed Term LoanManagers
Upgrade all (currently 8) outstanding LoanManager contracts.
```solidity
loanManager.upgrade(301, "0x");
```
This procedure contains a significant amount of function calls, so it will need to determined if it can all be performed in one transaction or will require multiple.
## Phase 3 - Security Admin Upgrades all Loans
This step will also be done with a JSON fed into a Gnosis Safe multisig, which will be simulated against Tenderly and validated by the smart contracts team before being performed on mainnet. The number of function calls will depend on the number of outstanding loans at deployment.
```solidity
loan.upgrade(501, "0x")
```
## Key Deprecation in Globals
Once the smart contracts team has deemed it safe, all old keys used for allowlisting can be set to false.
### Remove Contracts from Old Allowlist
```solidity
globals_.setValidInstanceOf("LIQUIDATOR", liquidatorFactory, false);
globals_.setValidInstanceOf("LOAN_MANAGER", fixedTermLoanManagerFactory, false);
globals_.setValidInstanceOf("POOL_MANAGER", poolManagerFactory, false);
globals_.setValidInstanceOf("WITHDRAWAL_MANAGER", withdrawalManagerFactory, false);
globals_.setValidInstanceOf("LOAN", fixedTermLoanFactory, false);
globals_.setValidPoolDeployer(poolDeployer, false);
```
## Post-Upgrade
### Adding Open Term Loan Managers
After the protocol has been deployed, the PoolDelegates can call:
```solidity
poolManager.addLoanManager(openTermLoanManagerFactory)
```
to add a new OpenTermLoanManager to their Pools if they would like to fund new Open Term Loans.
# December 2023 Deployment & Upgrade Procedure
### 1. Deploy All New Contracts
The first step is deploying various new contract implementations and initializing some of them. Here's a breakdown of the contracts being deployed:
| **contract** | **description** |
| --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `FixedTermLoanFactoryV2` | The new version of the fixed term loan factory |
| `FixedTermLoanImplementationV502` | The new version of the fixed term loan implementation. Identical to V501, but needed for factory migration |
| `FixedTermLoanV502Migrator` | The migrator contract for setting the new factory on deployed versions of the fixed term loan |
| `GlobalsImplementationV3` | The new version of the globals contract |
| `PoolDeployerV3` | The new version of the pool deployer contract |
| `PoolManagerImplementationV300` | The new version of the pool manager contract |
| `PoolManagerImplementationV301` | The new version of the pool manager contract. Identical to V300 but needed for allowing a migration |
| `PoolManagerInitializer` | The initializer for the pool manager contract |
| `PoolManagerMigrator` | The migrator contract for setting the new pool permission manager implementation on deployed versions of the pool manager |
| `PoolManagerWMMigrator` | The migrator contract for setting the new queue withdrawal manager implementation on deployed versions of the pool manager |
| `NonTransparentProxy (PoolPermissionManager)` | The new pool permission manager contract. This will be a non transparent proxy. |
| `PoolPermissionManagerImplementation` | The new pool permission manager contract implementation. |
| `WithdrawalManagerCyclical` | The new implementation of the withdrawal manager cyclical contract |
| `WithdrawalManagerCyclicalInitializer` | The initializer for the withdrawal manager cyclical contract |
| `PoolPermissionManagerInitializer` | The new pool permission manager Initializer contract. |
| `WithdrawalManagerQueueFactory` | The factory for creating instances of the withdrawal manager queue contract |
| `WithdrawalManagerQueue` | The new implementation of the withdrawal manager queue contract |
| `WithdrawalManagerQueueInitializer` | The initializer for the withdrawal manager queue contract |
### 2. Upgrade Globals
The Globals contract is upgraded to the new implementation (V3) deployed in the previous step. This involves pointing the proxy contract to the new implementation address.
### 3. Enable Globals Keys
This function sets various permissions and configurations in the Globals contract. It registers new valid instances, enables deployment from specific factories, and sets permission for deploying contracts. Breakdown of values:
| Function Name | Parameter 1 | Parameter 2 | Parameter 3 |
| -------------------- | ------------------------------------ | -------------------------------- | ----------- |
| `setValidInstanceOf` | `"LOAN_FACTORY"` | `fixedTermLoanFactoryV2` | `true` |
| `setValidInstanceOf` | `"FT_LOAN_FACTORY"` | `fixedTermLoanFactoryV2` | `true` |
| `setValidInstanceOf` | `"POOL_PERMISSION_MANAGER"` | `address(poolPermissionManager)` | `true` |
| `setValidInstanceOf` | `"WITHDRAWAL_MANAGER_CYCLE_FACTORY"` | `withdrawalManagerFactory` | `true` |
| `setValidInstanceOf` | `"WITH프로젝트로 돌아가기