# CoreOracle

The contract provides price feeds to other contracts, such as the `BlueberryBank.sol` Contract

### State Variables

The `CoreOracle` contract contains the following state variables:

#### routes

{% code overflow="wrap" %}

```solidity
mapping(address => address) public routes;
```

{% endcode %}

This mapping stores the oracle source routes for tokens. For each token address `t`, the mapping stores the oracle source route address for `t`.

#### liqThresholds

{% code overflow="wrap" %}

```solidity
mapping(address => uint256) public liqThresholds;
```

{% endcode %}

This mapping stores the liquidation threshold for tokens. The number is multiplied by 1e4. For volatile tokens 85% and 90% for stablecoins as a negative Profit loss on the position in comparison to the supplied tokens as isolated collateral.

#### whitelistedERC1155

{% code overflow="wrap" %}

```solidity
mapping(address => bool) public whitelistedERC1155;
```

{% endcode %}

This mapping stores the wrapper addresses for the whitelisted status of ERC1155 tokens in the protocol.

### Functions

#### initialize

{% code overflow="wrap" %}

```solidity
function initialize() external initializer
```

{% endcode %}

This function initializes the `CoreOracle` contract. It is called during contract deployment.

#### setRoutes

{% code overflow="wrap" %}

```solidity
function setRoutes(address[] calldata tokens, address[] calldata oracleRoutes) external onlyOwner
```

{% endcode %}

This function sets the oracle source routes for tokens. It takes two arrays as inputs, `tokens` and `oracleRoutes`, both of which must have the same length. For each index `i`, the function sets the oracle source route for the token at index `i` to the address in `oracleRoutes[i]`.

#### setLiqThresholds

{% code overflow="wrap" %}

```solidity
function setLiqThresholds(address[] memory tokens, uint256[] memory thresholds) external onlyOwner
```

{% endcode %}

This function sets the token liquidation thresholds. It takes two arrays as inputs, `tokens` and `thresholds`, both of which must have the same length. For each index `i`, the function sets the liquidation threshold for the token at index `i` to the value in `thresholds[i]`.

#### setWhitelistERC1155

{% code overflow="wrap" %}

```solidity
function setWhitelistERC1155(address[] memory tokens, bool ok) external onlyOwner
```

{% endcode %}

This function whitelists ERC1155 tokens. It takes an array `tokens` of tokens to whitelist and a boolean `ok` indicating whether to whitelist or blacklist the tokens. For each token in `tokens`, the function sets its whitelist status to the value in `ok`.

#### \_getPrice

{% code overflow="wrap" %}

```solidity
function _getPrice(address token) internal view returns (uint256)
```

{% endcode %}

This internal function returns the USD price of a given token, multiplied by 10^18.

#### getPrice

{% code overflow="wrap" %}

```solidity
function getPrice(address token) external view override returns (uint256)
```

{% endcode %}

This function returns the USD price of a given token, multiplied by 10^18

#### isWrappedTokenSupported

{% code overflow="wrap" %}

```solidity
function isWrappedTokenSupported(address token,uint256 tokenId) external view override returns (bool)
```

{% endcode %}

This function returns a boolean indicating whether the oracle supports the underlying token of a given wrapper token. Only validate wrappers of Blueberry protocol such as WERC20

#### isTokenSupported

{% code overflow="wrap" %}

```solidity
function isTokenSupported(address token) external view override returns (bool)
```

{% endcode %}

This function returns a boolean indicating whether the oracle supports a given ERC20 token.
