# OracleManager.sol

### OracleManager

The Oracle Manager stores oracle implementations. *External contracts can call `getPrice` to get the price of an asset.*

#### oracles

```solidity
contract IBasePriceOracle[] oracles
```

Active oracle implementations.

*Stored in priority order.*

#### numOracles

```solidity
uint256 numOracles
```

The number of active oracle implementations.

#### quoteAsset

```solidity
address quoteAsset
```

The ERC20 in which the price is quoted.

#### MIN\_SUPPORTED\_ORACLES

```solidity
uint256 MIN_SUPPORTED_ORACLES
```

The minimum number of supported oracles.

#### MAX\_SUPPORTED\_ORACLES

```solidity
uint256 MAX_SUPPORTED_ORACLES
```

The maximum number of supported oracles.

#### constructor

```solidity
constructor(address _quoteAsset) public
```

Sets the ERC20 in which the price is quoted.

**Parameters**

| Name         | Type    | Description                     |
| ------------ | ------- | ------------------------------- |
| \_quoteAsset | address | the address of the quote token. |

#### getPrice

```solidity
function getPrice(address _asset) external view returns (uint256)
```

Returns the price of the asset quoted in terms of the base asset.

*Iterates through `oracles` in order, and calls `IBasePriceOracle.getPrice()` if the oracle supports the asset. Reverts if no oracle supports by asset.*

**Parameters**

| Name    | Type    | Description                        |
| ------- | ------- | ---------------------------------- |
| \_asset | address | the address of the asset to quote. |

**Return Values**

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| \[0] | uint256 | The price of the asset in WAD. |

#### setOracles

```solidity
function setOracles(contract IBasePriceOracle[] _oracles) external
```

Sets the oracle implementations.

*First it zeroes out the `oracles` array in storage. It copies elements from `_oracles` then updates `numOracles`. 10 >= number of oracles > 0. Can be called only by the owner.*

**Parameters**

| Name      | Type                         | Description                                     |
| --------- | ---------------------------- | ----------------------------------------------- |
| \_oracles | contract IBasePriceOracle\[] | an array of `IBasePriceOracle` implementations. |

#### getOracles

```solidity
function getOracles() external view returns (contract IBasePriceOracle[] _oracles)
```

Retrieves the oracle implementations.

*Used for off-chain data retrieval.*

**Return Values**

| Name      | Type                         | Description                                                   |
| --------- | ---------------------------- | ------------------------------------------------------------- |
| \_oracles | contract IBasePriceOracle\[] | The current active oracle implementations in iteration order. |
