> For the complete documentation index, see [llms.txt](https://tech.usual.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tech.usual.money/smart-contracts/utility-contracts/eth0/lido-wsteth-oracle.md).

# Lido wstETH Oracle

{% hint style="info" %}
The contract operates under the assumption that stETH maintains a 1:1 peg with ETH, as stETH represents staked ETH in the Lido protocol.
{% endhint %}

## High-Level Overview

The `LidoProxyWstETHPriceFeed` contract is a specialized oracle implementation that serves as a proxy for the Lido wstETH/ETH price feed. It implements the Chainlink AggregatorV3Interface to provide standardized price feed data for wstETH in terms of ETH, making it compatible with the broader Chainlink oracle ecosystem.

## Contract Summary

This contract acts as a wrapper around the Lido wstETH contract, converting the stETH per token ratio into a standardized price feed format. It maintains compatibility with the Chainlink AggregatorV3Interface while providing real-time wstETH/ETH price data.

### Key Features

1. **Chainlink Compatibility**

* Implements the AggregatorV3Interface
* Provides standardized price feed data structure
* Maintains consistent decimal precision (18 decimals)

2. **Real-time Price Data**

* Fetches live wstETH/ETH conversion rates from the Lido contract
* Updates price data on every query
* Provides both round-specific and latest price data

3. **Standardized Interface**

* Returns price data in a format compatible with Chainlink consumers
* Includes round information, timestamps, and price values
* Maintains consistent decimal precision across all operations

### Functions Description

#### Public/External Functions

* `decimals()`: Returns the number of decimals used in the price feed (18)
* `description()`: Returns the description of the price feed ("wstETH / ETH")
* `version()`: Returns the version of the price feed implementation (1)
* `getRoundData(uint80 roundId_)`: Returns historical price data for a specific round
* `latestRoundData()`: Returns the most recent price data

Returns:

* `roundId`: The latest round ID (always 1)
* `answer`: The current wstETH/ETH price
* `startedAt`: Current block timestamp
* `updatedAt`: Current block timestamp
* `answeredInRound`: The round ID (always 1)

#### State Variables

* `WST_ETH_CONTRACT`: Immutable address of the Lido wstETH contract
* `PRICE_FEED_DECIMALS`: Constant value of 18, representing the number of decimals used in price feed output

#### Error Handling

`InvalidDecimalsNumber()`: Thrown when the wstETH contract's decimals don't match the expected PRICE\_FEED\_DECIMALS (18)

### Security Considerations

1. I**mmutable Contract Address**

* The wstETH contract address is set during construction and cannot be changed
* Prevents potential manipulation of the price source

2. **Decimal Validation**

* Validates the wstETH contract's decimals during construction
* Ensures consistent decimal precision across the system

3. **Real-time Price Updates**

* Price data is fetched directly from the Lido contract on each query
* No stale price data is stored or returned

Integration Notes

1. **Chainlink Compatibility**

* Can be used as a drop-in replacement for Chainlink price feeds
* Compatible with any system expecting AggregatorV3Interface implementation

2. **Price Data Usage**

* The answer returned represents the wstETH/stETH exchange rate based on the `stEthPerToken()` function
* All price data is returned with 18 decimal precision
* Timestamps are based on block.timestamp for real-time accuracy

3. **Round Data**

* While the contract implements the round-based interface, it doesn't maintain historical round data
* All round queries return current price data with appropriate round identifiers
