# Aave V3 Oracle Contract

The `AaveOracle` contract returns asset prices and manages price sources.

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

> [!NOTE]
> Write methods are restricted to `POOL_ADMIN` and `ASSET_LISTING_ADMIN` via the
> ACLManager.

## AaveOracle

### Write Methods

#### setAssetSources

```solidity
function setAssetSources(address[] calldata assets, address[] calldata sources) external override onlyAssetListingOrPoolAdmins
```

Sets the price `sources` for given list of `assets`.

> [!NOTE]
> Only callable by a `POOL_ADMIN` or `ASSET_LISTING_ADMIN`. See
> [`ACLManager`](./acl-manager) for roles.

**Input Parameters:**

| Name    | Type        | Description                                                                                |
| :------ | :---------- | :----------------------------------------------------------------------------------------- |
| **assets** | `address[]` | The addresses of the assets for which source is being set                                  |
| **sources** | `address[]` | The address of the source of each asset. Length of assets and sources array should be same |

#### setFallbackOracle

```solidity
function setFallbackOracle(address fallbackOracle) external override onlyAssetListingOrPoolAdmins
```

Sets/updates the `fallbackOracle`.

> [!NOTE]
> Only callable by a `POOL_ADMIN` or `ASSET_LISTING_ADMIN`. See
> [`ACLManager`](./acl-manager) for roles.

**Input Parameters:**

| Name           | Type      | Description                        |
| :------------- | :-------- | :--------------------------------- |
| **fallbackOracle** | `address` | The address of the fallback oracle |

### View Methods

#### getAssetPrice

```solidity
function getAssetPrice(address asset) public view override returns (uint256)
```

Returns the price of the supported `asset` in [`BASE_CURRENCY`](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/interfaces/IPriceOracleGetter.sol) of the Aave Market, scaled by `BASE_CURRENCY_UNIT` (8 decimals on USD markets).

**Input Parameters:**

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

**Return Values:**

| Type      | Description                                                         |
| :-------- | :------------------------------------------------------------------ |
| `uint256` | The price of the asset in `BASE_CURRENCY` of the Aave market, scaled by `BASE_CURRENCY_UNIT` (8 decimals on USD markets) |

#### getAssetsPrices

```solidity
function getAssetsPrices(address[] calldata assets) external view override returns (uint256[] memory)
```

Returns a list of prices from a list of the supported `assets` addresses in [`BASE_CURRENCY`](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/interfaces/IPriceOracleGetter.sol) of the Aave Market. All prices are scaled by `BASE_CURRENCY_UNIT` (8 decimals on USD markets).

**Input Parameters:**

| Name   | Type        | Description                                                   |
| :----- | :---------- | :------------------------------------------------------------ |
| **assets** | `address[]` | The list of assets addresses for which price is being queried |

**Return Values:**

| Type        | Description                                                                 |
| :---------- | :-------------------------------------------------------------------------- |
| `uint256[]` | The prices of the given assets in `BASE_CURRENCY` of the Aave market, scaled by `BASE_CURRENCY_UNIT` (8 decimals on USD markets) |

#### getSourceOfAsset

```solidity
function getSourceOfAsset(address asset) external view override returns (address)
```

Returns the address of the price source for an `asset` address.

**Input Parameters:**

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

**Return Values:**

| Type      | Description               |
| :-------- | :------------------------ |
| `address` | The address of the source |

#### getFallbackOracle

```solidity
function getFallbackOracle() external view returns (address)
```

Returns the `address` of the fallback oracle.

**Return Values:**

| Type      | Description                        |
| :-------- | :--------------------------------- |
| `address` | The address of the fallback oracle |

## PriceOracleSentinel

Aave V3.7 removed the `PriceOracleSentinel` and its sequencer oracle. Borrows and liquidations are no longer gated by L2 sequencer uptime: borrows succeed when the standard checks pass, and liquidations proceed whenever the Health Factor is below 1 and the liquidation grace period has elapsed.

> [!NOTE]
> Some Aave V3 instances may still run Aave V3.6, where the sentinel can block
> borrows and delay liquidations after a sequencer outage. `POOL_REVISION()` on
> the Pool returns `10` on [Aave V3.6](/resources/changelog#aave-v36) and `11`
> on [Aave V3.7](/resources/changelog#aave-v37-part-1). See the [Aave V3.6
> source](https://github.com/aave-dao/aave-v3-origin/blob/v3.6.0/src/contracts/misc/PriceOracleSentinel.sol).
