PendleOracleImpl

This contract is used to get the exchange rate for a Pendle market (PT-Asset).

_PENDLE_ORACLE

contract IPendlePYLpOracle _PENDLE_ORACLE

Pendle pyYtLpOracle address, see Pendle docs for deployment address.

_PENDLE_MARKET

contract IPendleMarketV3 _PENDLE_MARKET

Pendle market address for which this Oracle is intended for.

_EXPIRY

uint256 _EXPIRY

timestamp when PT reaches maturity. read and stored from Immutable at the _PENDLE_MARKET contract.

_TWAP_DURATION

uint32 _TWAP_DURATION

TWAP duration for the pendle AMM oracle rate fetch. The recommended duration is 15 mins (900 secs) or 30 mins (1800 secs), but it can vary depending on the market. See https://docs.pendle.finance/Developers/Oracles/HowToIntegratePtAndLpOracle#second-choose-a-market--duration

_MAX_EXPECTED_BORROW_RATE

uint256 _MAX_EXPECTED_BORROW_RATE

maximum expected borrow rate for the borrow asset at the Fluid vault. Affects the increasing price for operate(), creating an effective CF at the vault that increases as we get closer to maturity.

_MIN_YIELD_RATE

uint256 _MIN_YIELD_RATE

minimum ever expected yield rate at Pendle for the PT asset. If TWAP price is outside of this range, the oracle will revert, stopping any new borrows during a time of unexpected state of the Pendle market.

_MAX_YIELD_RATE

uint256 _MAX_YIELD_RATE

maximum ever expected yield rate at Pendle for the PT asset. If TWAP price is outside of this range, the oracle will revert, stopping any new borrows during a time of unexpected state of the Pendle market.

_DEBT_TOKEN_DECIMALS

uint8 _DEBT_TOKEN_DECIMALS

decimals of the debt token for correct scaling out the output rate

_PENDLE_DECIMALS

uint8 _PENDLE_DECIMALS

constructor

constructor(contract IPendlePYLpOracle pendleOracle_, contract IPendleMarketV3 pendleMarket_, uint32 twapDuration_, uint256 maxExpectedBorrowRate_, uint256 minYieldRate_, uint256 maxYieldRate_, uint8 debtTokenDecimals_) internal

_getPendleExchangeRateOperate

function _getPendleExchangeRateOperate() internal view returns (uint256 rate_)

_returns the pendle oracle exchange rate for operate() scaled by OracleUtils.RATE_OUTPUT_DECIMALS. checks that the AMM TWAP rate at Pendle is within the allowed yield ranges, and returns the rate_ based on maturity and a maximum expected borrow rate at Fluid, resulting into an automatically with block.timestamp adjusting effective CF at the vault, increasing as we get closer to maturity._

_getPendleExchangeRateLiquidate

function _getPendleExchangeRateLiquidate() internal view returns (uint256 rate_)

returns the pendle oracle exchange rate for liquidate(): 1PT = 1 underlying (e.g. 1PT-sUSDE = 1 USDE). scaled by OracleUtils.RATE_OUTPUT_DECIMALS.

pendleOracleData

function pendleOracleData() public view returns (contract IPendlePYLpOracle pendleOracle_, contract IPendleMarketV3 pendleMarket_, uint256 expiry_, uint32 twapDuration_, uint256 maxExpectedBorrowRate_, uint256 minYieldRate_, uint256 maxYieldRate_, uint8 debtTokenDecimals_, uint256 exchangeRateOperate_, uint256 exchangeRateLiquidate_, uint256 ptToAssetRateTWAP_)

returns all Pendle oracle related data as utility for easy off-chain use / block explorer in a single view method

_priceAtRateToMaturity

function _priceAtRateToMaturity(uint256 yearlyRatePercent_, uint256 timeToMaturity_) internal pure returns (uint256 price_)

_returns the price_in 1e27, given ayearlyRatePercent* yield in percent (1e2 = 1%) and atimeToMaturity*._