SwEthSpotOracle

Git Source

Inherits: SpotOracle

The swETH spot oracle.

State Variables

POOL

IUniswapV3Pool public immutable POOL;

SECONDS_AGO

uint32 public immutable SECONDS_AGO;

Functions

constructor

Creates a new SwEthSpotOracle instance.

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

Parameters

NameTypeDescription

_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

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

NameTypeDescription

ethPerSwEth

uint256

price of swETH in ETH. [WAD]

_getPriceInWadFromSqrtPriceX96

Converts a sqrtPriceX96 to a price in WAD.

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

Parameters

NameTypeDescription

sqrtPriceX96

uint256

Price in sqrtPriceX96.

Errors

InvalidSecondsAgo

error InvalidSecondsAgo(uint32 invalidSecondsAgo);