# PtSpotOracle

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

**Inherits:** SpotOracle

Spot Oracle for PT MARKETs

*This contract assumes that the SY is pegged 1:1 with the underlying asset of IonPool. This is a major assumption to be aware of since this oracle will return a valuation in SY, which may or may not be the same as the underlying in the IonPool.*

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

#### [MARKET](broken://pages/FOQl6w7CDNYsIhr8fzW1) <a href="#market" id="market"></a>

```
IPMarketV3 public immutable MARKET;
```

#### [TWAP\_DURATION](broken://pages/FOQl6w7CDNYsIhr8fzW1) <a href="#twap_duration" id="twap_duration"></a>

```
uint32 public immutable TWAP_DURATION;
```

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

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

Construct a new `PtSpotOracle` instance

```
constructor(
    IPMarketV3 _market,
    uint32 _twapDuration,
    uint256 _ltv,
    address _reserveOracle
)
    SpotOracle(_ltv, _reserveOracle);
```

**Parameters**

| Name             | Type         | Description                                |
| ---------------- | ------------ | ------------------------------------------ |
| `_market`        | `IPMarketV3` | The Pendle Market to get the PT price from |
| `_twapDuration`  | `uint32`     | The duration of the TWAP                   |
| `_ltv`           | `uint256`    | The Loan To Value ratio                    |
| `_reserveOracle` | `address`    | The oracle to get the reserve price from   |

#### [getPrice](broken://pages/FOQl6w7CDNYsIhr8fzW1) <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 override returns (uint256 price);
```

**Returns**

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

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

#### [InsufficientOracleSlots](broken://pages/FOQl6w7CDNYsIhr8fzW1) <a href="#insufficientoracleslots" id="insufficientoracleslots"></a>

```
error InsufficientOracleSlots(uint256 currentSlots);
```


---

# 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/ptspotoracle.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.
