Skip to main content

How to Integrate PT and LP Oracle

Integrating PT and LP oracles into your system can be accomplished in six easy steps. This document provides detailed instructions along with runnable examples. If you need personalized assistance, don't hesitate to contact us via our Developers channel on Discord.

First, Understand SY, PT, LP

You can read High Level Architecture & StandardizedYield to understand the Pendle system.

Refer to the examples here & here for further understanding.

Second, Choose a Market & Duration

We recommend choosing a market with high trading activities & deep liquidity. For instance, we'll choose EtherFi's weETH market on Arbitrum, which has 70M USD liquidity at block 192_001_277.

The recommended duration is 15 mins (900 secs) or 30 mins (1800 secs), but it can vary depending on the market.

For a detailed guide on assessing the risk, depth of liquidity & twap duration, refer to the corresponding risk assessment docs.

Third, Initialize the Oracle

By default, markets' oracles are un-initialized. You can check the oracle's status & initialize it if necessary using getOracleState on the PtAndLpOracle contract.

/img/Developers/Pasted_image_20240319215123.png

Fourth, Get the Price

There are 2 units PT / LP can be denominated in, in SY or in Asset. To get the price in SY, call getPtToSyRate(), else call getPtToAssetRate(). Ensure to use the appropriate function as SY price is well defined for some markets, but Asset price is not & vice-versa.

For example:

  • 1 SY-rsETH equals 1 rsETH, so the SY price is well-defined since rsETH is a tradable asset. The asset of SY-rsETH is ETH staked in Kelp, which is not a tradable asset. Therefore, getPtToSyRate is recommended.
  • 1 SY-cUSDC (Compound) equals 1 cUSDC, but cUSDC is not a tradable asset. The asset of SY-cUSDC is USDC staked in Compound. Assuming Compound is always solvent, SY-cUSDC can be valued on USDC instead. For this, getPtToAssetRate is recommended.
  • 1 SY-weETH (Ether.fi) equals 1 weETH, so the SY price is well-defined since weETH is a tradable asset. The asset of SY-weETH is eETH, which is also a tradable asset. In this case, both functions can be used.

Refer to StandardizedYield docs to choose the denomination correctly.

Below is an example of how to call the functions.

/img/Developers/Pasted_image_20240319221744.png

/img/Developers/Pasted_image_20240319221801.png

If you don't want to use the library, you can call the PendlePtLpOracle directly though it will take around ~4k additional gas.

/img/Developers/Pasted_image_20240319230732.png

(Optional) Fifth, Multiply the Price with a 3rd Price

You can multiply the PT-weETH to weETH price by weETH/ETH price to get the PT-weETH/ETH price, which is more applicable for money markets.

For example:

/img/Developers/Pasted_image_20240319230333.png

/img/Developers/Pasted_image_20240319230350.png

Lastly, Handle liquidation & LP's rewards

For PT liquidation

  • When a liquidation with PTPT as collateral occurs, commonly, the liquidator will have to sell PTPT into common asset to pay their debt.
  • In Pendle's system, we support converting PTPT back to SYSY by selling PTPT on our AMM (before maturity) or redeeming directly from PendleYieldToken contract (post maturity). This will then allow the liquidator to redeem their SYSY into one of the output token of SYSY (see EIP-5115).
  • For reference, we have written the BoringPtSeller contract to sell PTPT into one of the output token.
  • You can extend this abstract contract to use in a liquidation system.

For LP liquidation

  • When a liquidation with LPLP as collateral occurs, commonly, the liquidator will have to sell LPLP into common asset to pay their debt.
  • In Pendle's system, we support converting LPLP back to SYSY by removing liquidity single-sided into SYSY on our AMM (before maturity) or redeeming PTPT + SYSY and redeeming PTPT to SYSY directly from PendleYieldToken contract (post maturity). This will then allow the liquidator to redeem their SYSY into one of the output token of SYSY (see EIP-5115).
  • For reference, we have written the BoringLpSeller contract to sell LPLP into one of SY's output tokens.
  • You can extend this abstract contract to use in a liquidation system.

Handling of Pendle LP's rewards:

  • Holding Pendle LP tokens will generate PENDLE incentives and potential reward tokens (like WETH for LP for GLP pool)
  • The money market contracts will need to redeem these rewards by calling the redeemRewards function and implement logic to distribute these rewards to their users