# Aave V3 Pool Configurator Contract

The `PoolConfigurator` contract implements the configuration methods for the Aave Protocol. The 'write methods' below are grouped by permissioned system roles that are managed by [`ACLManager`](./acl-manager).

The source code is available on [GitHub](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/pool/PoolConfigurator.sol).

## Asset Listing or Pool Admin Methods

### initReserves

```solidity
function initReserves(ConfiguratorInputTypes.InitReserveInput[] calldata input) external override onlyAssetListingOrPoolAdmins
```

Initializes multiple reserves using the array of initialization parameters as input.

**Input Parameters:**

| Name  | Type                                        | Description                            |
| :---- | :------------------------------------------ | :------------------------------------- |
| **input** | `ConfiguratorInputTypes.InitReserveInput[]` | The array of initialization parameters |

The [ConfiguratorInputTypes.InitReserveInput[]](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol) struct is composed of the following fields:

| Name                        | Type      | Description                                                         |
| :-------------------------- | :-------- | :------------------------------------------------------------------ |
| **aTokenImpl**                  | `address` | The address of the aToken contract implementation                   |
| **variableDebtTokenImpl**       | `address` | The address of the variable debt token contract                     |
| **underlyingAsset**             | `address` | The address of the underlying asset                                 |
| **aTokenName**                  | `string`  | The name of the aToken                                              |
| **aTokenSymbol**                | `string`  | The symbol of the aToken                                            |
| **variableDebtTokenName**       | `string`  | The name of the variable debt token                                 |
| **variableDebtTokenSymbol**     | `string`  | The symbol of the variable debt token                               |
| **params**                      | `bytes`   | A set of encoded parameters for additional initialization           |
| **interestRateData**            | `bytes`   | Encoded interest rate strategy data                                 |

## Emergency or Pool Admin Methods

### setPoolPause

```solidity
function setPoolPause(bool paused, uint40 gracePeriod) public override onlyEmergencyOrPoolAdmin
function setPoolPause(bool paused) external override onlyEmergencyOrPoolAdmin
```

Pauses or unpauses all the protocol reserves. In the paused state all the protocol interactions are suspended. The overload without `gracePeriod` uses a grace period of 0.

**Input Parameters:**

| Name        | Type     | Description                                                                                          |
| :---------- | :------- | :--------------------------------------------------------------------------------------------------- |
| **paused**  | `bool`   | `true` if the protocol needs to be paused, otherwise `false`                                         |
| **gracePeriod** | `uint40` | Seconds after unpausing during which liquidations stay blocked, capped by `MAX_GRACE_PERIOD()` |

### setReservePause

```solidity
function setReservePause(address asset, bool paused, uint40 gracePeriod) public override onlyEmergencyOrPoolAdmin
function setReservePause(address asset, bool paused) external override onlyEmergencyOrPoolAdmin
```

Pauses a reserve. A paused reserve does not allow any interaction (supply, borrow, repay, liquidate, aToken transfers). The overload without `gracePeriod` uses a grace period of 0.

**Input Parameters:**

| Name        | Type      | Description                                                                                    |
| :---------- | :-------- | :--------------------------------------------------------------------------------------------- |
| **asset**   | `address` | The address of the underlying asset of the reserve                                             |
| **paused**  | `bool`    | `true` if pausing the reserve, `false` if unpausing the reserve                                |
| **gracePeriod** | `uint40`  | Seconds after unpausing during which liquidations stay blocked, capped by `MAX_GRACE_PERIOD()` |

### disableLiquidationGracePeriod

```solidity
function disableLiquidationGracePeriod(address asset) external override onlyEmergencyOrPoolAdmin
```

Disables the liquidation grace period for a reserve.

**Input Parameters:**

| Name  | Type      | Description                  |
| :---- | :-------- | :--------------------------- |
| **asset** | `address` | Address of the reserve asset |

## Pool Admin Methods

### updateAToken

```solidity
function updateAToken(ConfiguratorInputTypes.UpdateATokenInput calldata input) external override onlyPoolAdmin
```

Updates the aToken implementation for the reserve. Takes the aToken update parameters as input.

**Input Parameters:**

| Name  | Type                                       | Description                  |
| :---- | :----------------------------------------- | :--------------------------- |
| **input** | `ConfiguratorInputTypes.UpdateATokenInput` | The aToken update parameters |

The [ConfiguratorInputTypes.UpdateATokenInput](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol) struct is composed of the following fields:

| Name                 | Type      | Description                                               |
| :------------------- | :-------- | :-------------------------------------------------------- |
| **asset**                | `address` | The address of the underlying asset of the reserve        |
| **name**                 | `string`  | The name of the aToken                                    |
| **symbol**               | `string`  | The symbol of the aToken                                  |
| **implementation**       | `address` | The new aToken implementation                             |
| **params**               | `bytes`   | A set of encoded parameters for additional initialization |

### updateVariableDebtToken

```solidity
function updateVariableDebtToken(ConfiguratorInputTypes.UpdateDebtTokenInput calldata input) external override onlyPoolAdmin
```

Updates the variable debt token implementation for the reserve.

**Input Parameters:**

| Name  | Type                                          | Description                             |
| :---- | :-------------------------------------------- | :-------------------------------------- |
| **input** | `ConfiguratorInputTypes.UpdateDebtTokenInput` | The variableDebtToken update parameters |

The [ConfiguratorInputTypes.UpdateDebtTokenInput](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol) struct is composed of the following fields:

| Name                 | Type      | Description                                                         |
| :------------------- | :-------- | :------------------------------------------------------------------ |
| **asset**                | `address` | The address of the underlying asset of the reserve                  |
| **name**                 | `string`  | The name of the variableDebtToken                                   |
| **symbol**               | `string`  | The symbol of the variableDebtToken                                 |
| **implementation**       | `address` | The new variableDebtToken implementation                            |
| **params**               | `bytes`   | A set of encoded parameters for additional initialization           |

### setReserveActive

```solidity
function setReserveActive(address asset, bool active) external override onlyPoolAdmin
```

Activate or deactivate a reserve.

**Input Parameters:**

| Name   | Type      | Description                                                 |
| :----- | :-------- | :---------------------------------------------------------- |
| **asset** | `address` | The address of the underlying asset of the reserve          |
| **active** | `bool`    | `true` if the reserve needs to be active, `false` otherwise |

### updateFlashloanPremium

```solidity
function updateFlashloanPremium(uint128 newFlashloanPremium) external override onlyPoolAdmin
```

Updates the flash loan premium. The premium is calculated on the total amount borrowed, is expressed in bps, and is collected in full by the protocol treasury.

**Input Parameters:**

| Name                | Type      | Description                              |
| :------------------ | :-------- | :--------------------------------------- |
| **newFlashloanPremium** | `uint128` | The flash loan premium, expressed in bps |

## Risk or Pool Admin Methods

### setReserveFlashLoaning

```solidity
function setReserveFlashLoaning(address asset, bool enabled) external override onlyRiskOrPoolAdmins
```

Enables or disables flash loans for a reserve.

**Input Parameters:**

| Name    | Type      | Description                      |
| :------ | :-------- | :------------------------------- |
| **asset** | `address` | Address of the reserve asset     |
| **enabled** | `bool`    | true to enable, false to disable |

### setReserveBorrowing

```solidity
function setReserveBorrowing(address asset, bool enabled) external override onlyRiskOrPoolAdmins
```

Enables or disables borrowing on a reserve.

**Input Parameters:**

| Name    | Type      | Description                                                |
| :------ | :-------- | :--------------------------------------------------------- |
| **asset** | `address` | The address of the underlying asset of the reserve         |
| **enabled** | `bool`    | `true` if borrowing needs to be enabled, `false` otherwise |

### configureReserveAsCollateral

```solidity
function configureReserveAsCollateral(
    address asset,
    uint256 ltv,
    uint256 liquidationThreshold,
    uint256 liquidationBonus
) external override onlyRiskOrPoolAdmins
```

Configures the reserve collateralization parameters. All the values are expressed in bps. A value of 10000 results in 100.00%. The `liquidationBonus` is always above 100%. A value of 105% means the liquidator will receive a 5% bonus.

**Input Parameters:**

| Name                 | Type      | Description                                                                                        |
| :------------------- | :-------- | :------------------------------------------------------------------------------------------------- |
| **asset**            | `address` | The address of the underlying asset of the reserve                                                 |
| **ltv**              | `uint256` | The loan to value of the asset when used as collateral                                             |
| **liquidationThreshold** | `uint256` | The threshold at which loans using this asset as collateral will be considered undercollateralized |
| **liquidationBonus** | `uint256` | The bonus liquidators receive to liquidate this asset                                              |

### setReserveFactor

```solidity
function setReserveFactor(address asset, uint256 newReserveFactor) external override onlyRiskOrPoolAdmins
```

Updates the reserve factor of a reserve.

**Input Parameters:**

| Name             | Type      | Description                                        |
| :--------------- | :-------- | :------------------------------------------------- |
| **asset**        | `address` | The address of the underlying asset of the reserve |
| **newReserveFactor** | `uint256` | The new reserve factor of the reserve              |

### setBorrowCap

```solidity
function setBorrowCap(address asset, uint256 newBorrowCap) external override onlyRiskOrPoolAdmins
```

Updates the borrow cap of a reserve. Allows [`RISK_ADMIN`](./acl-manager#risk-admin) and [`POOL_ADMIN`](./acl-manager#pool-admin) to add/update cap on the total borrow that can be borrowed from the reserve. Once the borrow cap is reached, no more borrow positions for the given reserve asset can be initiated.

**Input Parameters:**

| Name         | Type      | Description                                                                                         |
| :----------- | :-------- | :-------------------------------------------------------------------------------------------------- |
| **asset**    | `address` | The address of the underlying asset of the reserve                                                  |
| **newBorrowCap** | `uint256` | The new borrow cap of the reserve in whole tokens. A borrow cap of 0 signifies that there is no cap |

### setSupplyCap

```solidity
function setSupplyCap(address asset, uint256 newSupplyCap) external override onlyRiskOrPoolAdmins
```

Updates the supply cap of a reserve. Allows [`RISK_ADMIN`](./acl-manager#risk-admin) and [`POOL_ADMIN`](./acl-manager#pool-admin) to add/update liquidity supply cap on the reserve. Once the supply cap is reached, no more liquidity for the given reserve asset can be supplied to the pool.

**Input Parameters:**

| Name         | Type      | Description                                                                                         |
| :----------- | :-------- | :-------------------------------------------------------------------------------------------------- |
| **asset**    | `address` | The address of the underlying asset of the reserve                                                  |
| **newSupplyCap** | `uint256` | The new supply cap of the reserve in whole tokens. A supply cap of 0 signifies that there is no cap |

### setLiquidationProtocolFee

```solidity
function setLiquidationProtocolFee(address asset, uint256 newFee) external override onlyRiskOrPoolAdmins
```

Updates the liquidation protocol fee of reserve.

**Input Parameters:**

| Name   | Type      | Description                                                       |
| :----- | :-------- | :---------------------------------------------------------------- |
| **asset** | `address` | The address of the underlying asset of the reserve                |
| **newFee** | `uint256` | The new liquidation protocol fee of the reserve, expressed in bps |

### setEModeCategory

```solidity
function setEModeCategory(
    uint8 categoryId,
    uint16 ltv,
    uint16 liquidationThreshold,
    uint16 liquidationBonus,
    string calldata label,
    bool isolated
) external override onlyRiskOrPoolAdmins
```

Adds a new efficiency mode (E-Mode) category. Allows [`RISK_ADMIN`](./acl-manager#risk-admin) and [`POOL_ADMIN`](./acl-manager#pool-admin) to configure existing or add new `eModeCategory`

**Input Parameters:**

| Name                 | Type     | Description                                                                                                                    |
| :------------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------- |
| **categoryId**       | `uint8`  | The id of the category to be configured. categoryId ≠ 0. NOTE: category 0 is reserved for the default category i.e. non-E-Mode |
| **ltv**              | `uint16` | The loan to value for the associated E-Mode category. It must be less than or equal to the liquidationThreshold                |
| **liquidationThreshold** | `uint16` | The liquidation threshold associated with the category                                                                         |
| **liquidationBonus** | `uint16` | The liquidation bonus associated with the category                                                                             |
| **label**            | `string` | A custom label identifying the category                                                                                        |
| **isolated**         | `bool`   | If `true`, users with collateral outside the category cannot enter it, and assets outside the category get LTV 0 (Aave V3.7)   |

### setAssetCollateralInEMode

```solidity
function setAssetCollateralInEMode(address asset, uint8 categoryId, bool allowed) external override onlyRiskOrPoolAdmins
```

Assign collateral status to an asset for a particular efficiency mode (E-Mode) category. Allows [`RISK_ADMIN`](./acl-manager#risk-admin) and [`POOL_ADMIN`](./acl-manager#pool-admin) to configure `eModeCategory` of an asset.

**Input Parameters:**

| Name       | Type      | Description                                                           |
| :--------- | :-------- | :-------------------------------------------------------------------- |
| **asset**  | `address` | The address of the underlying asset of the reserve                    |
| **categoryId** | `uint8`   | E-Mode category id to set asset collateral status for                 |
| **allowed** | `bool`    | `true` if `asset` is enabled as collateral in designated `categoryId` |

### setAssetBorrowableInEMode

```solidity
function setAssetBorrowableInEMode(address asset, uint8 categoryId, bool borrowable) external override onlyRiskOrPoolAdmins
```

Configures if an asset can be borrowed in a specific E-Mode category.

**Input Parameters:**

| Name       | Type      | Description                      |
| :--------- | :-------- | :------------------------------- |
| **asset**  | `address` | Address of the reserve asset     |
| **categoryId** | `uint8`   | E-Mode category ID               |
| **borrowable** | `bool`    | true to enable, false to disable |

### setReserveInterestRateData

```solidity
function setReserveInterestRateData(address asset, bytes calldata rateData) external onlyRiskOrPoolAdmins
```

Sets custom interest rate parameters for a reserve.

**Input Parameters:**

| Name     | Type      | Description                      |
| :------- | :-------- | :------------------------------- |
| **asset** | `address` | Address of the reserve asset     |
| **rateData** | `bytes`   | Encodes rate strategy parameters |

## Risk, Pool or Emergency Admin Methods

### setReserveFreeze

```solidity
function setReserveFreeze(address asset, bool freeze) external override onlyRiskOrPoolOrEmergencyAdmins
```

Freeze or unfreeze a reserve. A frozen reserve doesn’t allow new supply or borrow but allows repayments, liquidations and withdrawals. Freezing also sets the reserve LTV to zero, including in every E-Mode where it is collateral.

**Input Parameters:**

| Name   | Type      | Description                                                 |
| :----- | :-------- | :---------------------------------------------------------- |
| **asset** | `address` | The address of the underlying asset of the reserve          |
| **freeze** | `bool`    | `true` if the reserve needs to be frozen, `false` otherwise |

### setEModeCategoryIsolated

```solidity
function setEModeCategoryIsolated(uint8 categoryId, bool isolated) external onlyRiskOrPoolOrEmergencyAdmins
```

Sets the isolated flag of an E-Mode category. When `true`, users with collateral enabled outside the category cannot enter it, and assets outside the category get LTV 0. The liquidation threshold is unaffected, so the Health Factor of existing positions is preserved. Added in Aave V3.7.

**Input Parameters:**

| Name       | Type    | Description                               |
| :--------- | :------ | :---------------------------------------- |
| **categoryId** | `uint8` | The E-Mode category id                    |
| **isolated** | `bool`  | `true` if the E-Mode category is isolated |
