creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/PTeETH26DECPriceFeedUSD.sol": {
        "content": "pragma solidity ^0.8.0;\n\nimport {IChainLinkOracle} from \"./Interfaces/IChainLinkOracle.sol\";\nimport {IPendlePtLpOracle} from \"./Interfaces/IPendlePtLpOracle.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {IERC20Metadata} from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\ncontract PTeETH26DECPriceFeedUSD {\n    IChainLinkOracle public constant ETHlinkFeed = IChainLinkOracle(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);\n    IPendlePtLpOracle public constant PEETHlinkFeed = IPendlePtLpOracle(0x66a1096C6366b2529274dF4f5D8247827fe4CEA8);\n    \n    address public marketAddress = 0x7d372819240D14fB477f17b964f95F33BeB4c704;\n    uint16 public constant duration = 300;\n    uint8 public constant decimals = 18;\n\n    constructor () {}\n\n    /**\n     * Function to retrieve the price of 1 PEETH token in USD, scaled by 1e18\n     *\n     * @return PEETHUSDPrice Price of 1 PEETH token in USD\n     */\n    function latestAnswer() external view returns (uint256 PEETHUSDPrice) {\n        // Retrieve PTEETH relative to ETH\n        int256 PEETHPrice = int256(PEETHlinkFeed.getPtToAssetRate(marketAddress, duration));\n        uint256 PEETHPriceInUint = uint256(PEETHPrice);\n\n        // Retrieve ETH price in USD\n        int256 ethUSDPrice = ETHlinkFeed.latestAnswer();\n\n        // Calculate PEETHPrice relative to USD\n        uint256 PEETHConversionUSD = (\n            PEETHPriceInUint * uint256(ethUSDPrice)\n        ) / (10 ** ETHlinkFeed.decimals());\n\n        // Calculate the price of 1 WSTETH token in USD\n       PEETHUSDPrice = (PEETHConversionUSD * 1 ether) / (10 ** decimals);\n\n        return PEETHUSDPrice;\n    }\n\n    function fmul(\n        uint256 x,\n        uint256 y,\n        uint256 baseUnit\n    ) internal pure returns (uint256 z) {\n        assembly {\n            if iszero(eq(div(mul(x,y),x),y)) {revert(0,0)}\n            z := div(mul(x,y),baseUnit)\n        }\n    }\n\n    function fdiv(\n        uint256 x,\n        uint256 y,\n        uint256 baseUnit\n    ) internal pure returns (uint256 z) {\n        assembly {\n            if iszero(eq(div(mul(x,baseUnit),x),baseUnit)) {revert(0,0)}\n            z := div(mul(x,baseUnit),y)\n        }\n    }\n}"
      },
      "src/Interfaces/IChainLinkOracle.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IChainLinkOracle {\n  function decimals() external view returns (uint8);\n\n  function description() external view returns (string memory);\n\n  function latestAnswer() external view returns (int256);\n\n  function latestTimestamp() external view returns (uint256);\n\n  function latestRound() external view returns (uint256);\n\n  function getAnswer(uint256 roundId) external view returns (int256);\n\n  function getTimestamp(uint256 roundId) external view returns (uint256);\n\n  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);\n\n  event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n\n  function version() external view returns (uint256);\n\n  // getRoundData and latestRoundData should both raise \"No data present\"\n  // if they do not have data to report, instead of returning unset values\n  // which could be misinterpreted as actual reported values.\n  function getRoundData(uint80 _roundId)\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n\n  function latestRoundData()\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n}\n"
      },
      "src/Interfaces/IPendlePtLpOracle.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\ninterface IPendlePtLpOracle {\n    function getPtToAssetRate(address market, uint32 duration) external view returns (uint256);\n\n    function getLpToAssetRate(address market, uint32 duration) external view returns (uint256);\n\n    function getPtToSyRate(address market, uint32 duration) external view returns (uint256);\n\n    function getLpToSyRate(address market, uint32 duration) external view returns (uint256);\n    \n    function getOracleState(address market, uint32 duration) external view returns (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
        "forge-std/=lib/forge-std/src/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "paris",
      "libraries": {}
    }
  }}