> For the complete documentation index, see [llms.txt](https://docs.ionprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionprotocol.io/devs/smart-contract-architecture/oracles/spot/lst/swethspotoracle.md).

# 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);
```
