PendleOracleImpl ​
Inherits: OracleError
This contract is used to get the exchange rate for a Pendle market (PT-Asset).
State Variables ​
_PENDLE_ORACLE ​
Pendle pyYtLpOracle address, see Pendle docs for deployment address.
IPendlePYLpOracle internal immutable _PENDLE_ORACLE;
_PENDLE_MARKET ​
Pendle market address for which this Oracle is intended for.
IPendleMarketV3 internal immutable _PENDLE_MARKET;
_EXPIRY ​
timestamp when PT reaches maturity. read and stored from Immutable at the _PENDLE_MARKET
contract.
uint256 internal immutable _EXPIRY;
_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
uint32 internal immutable _TWAP_DURATION;
_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.
uint256 internal immutable _MAX_EXPECTED_BORROW_RATE;
_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.
uint256 internal immutable _MIN_YIELD_RATE;
_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.
uint256 internal immutable _MAX_YIELD_RATE;
_DEBT_TOKEN_DECIMALS ​
decimals of the debt token for correct scaling out the output rate
uint8 internal immutable _DEBT_TOKEN_DECIMALS;
_PENDLE_DECIMALS ​
uint8 internal constant _PENDLE_DECIMALS = 18;
Functions ​
constructor ​
constructor(
IPendlePYLpOracle pendleOracle_,
IPendleMarketV3 pendleMarket_,
uint32 twapDuration_,
uint256 maxExpectedBorrowRate_,
uint256 minYieldRate_,
uint256 maxYieldRate_,
uint8 debtTokenDecimals_
);
_getPendleExchangeRateOperate ​
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.
function _getPendleExchangeRateOperate() internal view returns (uint256 rate_);
_getPendleExchangeRateLiquidate ​
returns the pendle oracle exchange rate for liquidate(): 1PT = 1 underlying (e.g. 1PT-sUSDE = 1 USDE). scaled by OracleUtils.RATE_OUTPUT_DECIMALS
.
function _getPendleExchangeRateLiquidate() internal view returns (uint256 rate_);
pendleOracleData ​
returns all Pendle oracle related data as utility for easy off-chain use / block explorer in a single view method
function pendleOracleData()
public
view
returns (
IPendlePYLpOracle pendleOracle_,
IPendleMarketV3 pendleMarket_,
uint256 expiry_,
uint32 twapDuration_,
uint256 maxExpectedBorrowRate_,
uint256 minYieldRate_,
uint256 maxYieldRate_,
uint8 debtTokenDecimals_,
uint256 exchangeRateOperate_,
uint256 exchangeRateLiquidate_,
uint256 ptToAssetRateTWAP_
);
_priceAtRateToMaturity ​
returns the price_
in 1e27, given a yearlyRatePercent_
yield in percent (1e2 = 1%) and a timeToMaturity_
.
function _priceAtRateToMaturity(uint256 yearlyRatePercent_, uint256 timeToMaturity_)
internal
pure
returns (uint256 price_);