Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carson/swell deployment #36

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
35 changes: 35 additions & 0 deletions src/helper/PendlePTRateProvider.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pragma solidity 0.8.21;

import { IRateProvider } from "src/interfaces/IRateProvider.sol";

import { IPMarket } from "lib/ion-protocol/lib/pendle-core-v2-public/contracts/interfaces/IPMarket.sol";

import { IStandardizedYield } from "lib/ion-protocol/lib/pendle-core-v2-public/contracts/interfaces/IStandardizedYield.sol";
import { IPPtLpOracle } from "lib/ion-protocol/lib/pendle-core-v2-public/contracts/interfaces/IPPtLpOracle.sol";

/**
* @title PendlePTRateProvider
* @custom:security-contact [email protected]
*/
contract PendlePTRateProvider is IRateProvider {
/// @notice constant values
IPPtLpOracle public constant ORACLE = IPPtLpOracle(0x14030836AEc15B2ad48bB097bd57032559339c92);
uint32 public constant DURATION = 1 days;

/// @notice the pendle market this rate provider serves
IPMarket public immutable market;

/// @param pendleMarket to serve the PT rate
constructor(IPMarket pendleMarket) {
market = pendleMarket;
}
Comment on lines +29 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duration should be in the constructor and immutable for this contract to be reusable across multiple durations


/// @notice getRate for a Pendle PT token
function getRate() external view returns (uint256) {
(IStandardizedYield sy,,) = market.readTokens();
uint256 syRate = sy.exchangeRate();
uint256 ptRate = ORACLE.getPtToAssetRate(address(market), DURATION);

return syRate * ptRate / 1e18;
}
}
Loading