# SwEthSpotOracle

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

**Inherits:** SpotOracle

The swETH spot oracle.

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

#### [POOL](broken://pages/3MfS8rIe4PB4MlRXobY0) <a href="#pool" id="pool"></a>

```
IUniswapV3Pool public immutable POOL;
```

#### [SECONDS\_AGO](broken://pages/3MfS8rIe4PB4MlRXobY0) <a href="#seconds_ago" id="seconds_ago"></a>

```
uint32 public immutable SECONDS_AGO;
```

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

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

Creates a new `SwEthSpotOracle` instance.

```
constructor(
    uint256 _ltv,
    address _reserveOracle,
    address _uniswapPool,
    uint32 _secondsAgo
)
    SpotOracle(_ltv, _reserveOracle);
```

**Parameters**

| Name             | Type      | Description                        |
| ---------------- | --------- | ---------------------------------- |
| `_ltv`           | `uint256` | The loan to value ratio for swETH. |
| `_reserveOracle` | `address` | The associated reserve oracle.     |
| `_uniswapPool`   | `address` | swETH/Eth Uniswap pool address.    |
| `_secondsAgo`    | `uint32`  | The TWAP period in seconds.        |

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

Gets the price of swETH in ETH.

*Uniswap returns price in swETH per ETH. This needs to be inversed.*

```
function getPrice() public view override returns (uint256 ethPerSwEth);
```

**Returns**

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

#### [\_getPriceInWadFromSqrtPriceX96](broken://pages/3MfS8rIe4PB4MlRXobY0) <a href="#getpriceinwadfromsqrtpricex96" id="getpriceinwadfromsqrtpricex96"></a>

Converts a sqrtPriceX96 to a price in WAD.

```
function _getPriceInWadFromSqrtPriceX96(uint256 sqrtPriceX96) internal pure returns (uint256);
```

**Parameters**

| Name           | Type      | Description            |
| -------------- | --------- | ---------------------- |
| `sqrtPriceX96` | `uint256` | Price in sqrtPriceX96. |

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

#### [InvalidSecondsAgo](broken://pages/3MfS8rIe4PB4MlRXobY0) <a href="#invalidsecondsago" id="invalidsecondsago"></a>

```
error InvalidSecondsAgo(uint32 invalidSecondsAgo);
```


---

# 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/lst/swethspotoracle.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.
