# SpotOracle

[Git Source](https://github.com/Ion-Protocol/ion-protocol/blob/88cc595825f1dc2eb738fb93e172a3e8ab7a5c43/src/oracles/spot/SpotOracle.sol)

The `SpotOracle` is supposed to reflect the current market price of a collateral asset. It is used by `IonPool` to determine the health factor of a vault as a user is opening or closing a position. NOTE: The price data provided by this contract is not used by the liquidation module at all. The spot price will also always be bounded by the collateral's corresponding reserve oracle price to ensure that a user can never open position that is directly liquidatable.

### [State Variables](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#state-variables" id="state-variables"></a>

#### [LTV](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#ltv" id="ltv"></a>

```
uint256 public immutable LTV;
```

#### [RESERVE\_ORACLE](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#reserve_oracle" id="reserve_oracle"></a>

```
ReserveOracle public immutable RESERVE_ORACLE;
```

### [Functions](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#functions" id="functions"></a>

#### [constructor](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#constructor" id="constructor"></a>

Creates a new `SpotOracle` instance.

```
constructor(uint256 _ltv, address _reserveOracle);
```

**Parameters**

| Name             | Type      | Description                                |
| ---------------- | --------- | ------------------------------------------ |
| `_ltv`           | `uint256` | Loan to value ratio for the collateral.    |
| `_reserveOracle` | `address` | Address for the associated reserve oracle. |

#### [getPrice](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#getprice" id="getprice"></a>

Gets the price of the collateral asset in ETH.

*Overridden by collateral specific spot oracle contracts.*

```
function getPrice() public view virtual returns (uint256 price);
```

**Returns**

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

#### [getSpot](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#getspot" id="getspot"></a>

Gets the risk-adjusted market price.

```
function getSpot() external view returns (uint256 spot);
```

**Returns**

| Name   | Type      | Description                     |
| ------ | --------- | ------------------------------- |
| `spot` | `uint256` | The risk-adjusted market price. |

### [Errors](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#errors" id="errors"></a>

#### [InvalidLtv](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#invalidltv" id="invalidltv"></a>

```
error InvalidLtv(uint256 ltv);
```

#### [InvalidReserveOracle](broken://pages/uHI3W7DXDqHnS5vxNxTs) <a href="#invalidreserveoracle" id="invalidreserveoracle"></a>

```
error InvalidReserveOracle();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ionprotocol.io/devs/smart-contract-architecture/oracles/spot/spotoracle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
