From 6f0da03e916fdb37b0143eca16e64281180fc965 Mon Sep 17 00:00:00 2001 From: UncleGrandpa925 Date: Fri, 15 Nov 2024 20:47:13 +0800 Subject: [PATCH] Add Chainlink test --- bun.lockb | Bin 51059 -> 57064 bytes package.json | 2 +- test/ChainlinkOracleSample.sol | 94 +++++++++++++++++++++++++++++++++ test/OracleSample.sol | 2 +- 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 test/ChainlinkOracleSample.sol diff --git a/bun.lockb b/bun.lockb index feda7fda340ce8fe60aad7be95dc351e3684ea0e..f75c5180c7d205eef22b458d6f4590ea2ba1b5e3 100755 GIT binary patch delta 11891 zcmeHNdwfmT^56R;k?ceSd7YDl1WC|J$V(7%Xi8o}f`||y;Y30tk;Ge^6G|kl5JRh? zUe&7N7NHMBONGX-rQw$LYTfGNR$J~>+A3}NednCLa*}ed-|zGJeeUm{yFX|4?3r0> z)~uOXYwvw#->SB`T5q#DxTn_#y{7hcYncDa-v^$*xc%0?mkY~ZdUeWIxek{C;xj*7 zmNxFPWIn2D(tN$YSYaV7XLm_5Ey86tU_(ufXVxdOBsqd8&C1RXt7qP-+3pyy}h=jWA_N+&5@)*E+$#oSR)#I1J#w*$^A$Tbw_m6qfcdc%(h$u?f`rixD&9UxVW%5$T05;4CeMnRr!?Mto#|0WRy-| zG#)TFt0X8VKWo}v5N!TGn`{B(?O72{Jn%-~uE4%fjGyTsMrZsAFgq!xqov(W)o^uS zbzCRwz?*2R#?vUg*8w(op?d|oaZIubO7n}uOG}E14W*@dhT;swk%tdaF-$P~&rk}# zmB1vOB>6%9wudCa0@Eod!KG;;FegYitt8=Ra#C@2LGW~RGfGZq!1J$#06I)zYKLz@ zdxJgz%!a{Vx!k3}#}ak}qFPj%H)R^U&iyih*}!c0KdWG>qz)kMQ4Jcc4m`ais3bQl zOxkBQ&?uQc!v%gOTWIMFd`2BO57S|VS%#7zHnl=EtXRcgK{4lFoJucM2WV3Hw}E+L zGgSUu=-?yUFeNuERFa~YZ$y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|&G=Cb^Y5y#Twm7XyXQIY8R<33}`wT^-i z1`T5;`)2zm_j8fN4Mo2u-cV*3=&{k>{?bbshaE z@V%!twNfqn(`&m8t<6!J2l!Jn+-v2RpLYKL<&AsG9$#6}{LGvre@fW-RAsAPG-XS+ zbibeq{GV9tu+dNZGN7HrKXXZ)=9k3CPy4K(9pgXiq(*OQ5Zy)0Ra^3cXv2qwe`1Sc zwzcWAn#j3vl%Mty#A&+m{&|nRgOorhOY4gu%4v*}nuDmJag=l|h`wtyI5?jG#7Xs zeHnQcGBsP(7{GaH?;^oLab-79`hf(u z+6ILau6#*54+NSVOhQ3XX0KWKrFk=p%EL=+xdk~HCAP*}2ZB24ly?O3Jr&)!{c?AS znob*N&{wXYok=|Z3SB+jj=ntaM>S^*^yelI`u0=@@;K9m1~hrfMfnA`B7E^IrouBl z$l7c{O(Jz{9!<7Sff|GDZrajPt(q33~p=X_M1@Tc*3?$5X+yu?b%r(3k1i zuR0hKY$f=%j4!GAb8J~9y|VK2ic9c$)uCYAnOA9R^K2?_>PCCNmZ|hq5Uo7zt_%R$ zXg-_kM7OW>q%2f;!H=D%yk!hE&ps1l((zACjnP;AC2~1rT64yOwq6RLPfvBF^d=u? je7%g~26XMxGD^K@hOiBNb72s5y;Marze%J0dA0uwAAZ3R diff --git a/package.json b/package.json index 3350c1a..e56ca25 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "forge-std": "github:foundry-rs/forge-std#v1.7.5", "prettier": "^3.0.0", "solhint": "^3.6.2", - "@pendle/core-v2": "^4.7.0" + "@pendle/core-v2": "^5.2.0-beta-5" }, "keywords": [ "blockchain", diff --git a/test/ChainlinkOracleSample.sol b/test/ChainlinkOracleSample.sol new file mode 100644 index 0000000..f04d8bd --- /dev/null +++ b/test/ChainlinkOracleSample.sol @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.23 <0.9.0; + +import { PRBTest } from "@prb/test/src/PRBTest.sol"; +import { console2 as console } from "forge-std/src/console2.sol"; +import { StdCheats } from "forge-std/src/StdCheats.sol"; +import "@pendle/core-v2/contracts/interfaces/IPAllActionV3.sol"; +import "@pendle/core-v2/contracts/interfaces/IPMarket.sol"; +import "@pendle/core-v2/contracts/oracles/PtYtLpOracle/PendlePYLpOracle.sol"; +import "../src/StructGen.sol"; +import { AggregatorV2V3Interface as IChainlinkAggregator } from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol"; +import "@pendle/core-v2/contracts/oracles/PtYtLpOracle/chainlink/PendleChainlinkOracleFactory.sol"; +import "@pendle/core-v2/contracts/oracles/PtYtLpOracle/chainlink/PendleChainlinkOracle.sol"; + +contract ChainlinkOracleSample2 is PRBTest, StdCheats, StructGen { + using PendlePYOracleLib for IPMarket; + using PendleLpOracleLib for IPMarket; + + IStandardizedYield public SY; + IPPrincipalToken public PT; + IPYieldToken public YT; + + IPMarket public constant market = IPMarket(0xCaE62858DB831272A03768f5844cbe1B40bB381f); + PendleChainlinkOracleFactory public factory; + PendleChainlinkOracle public PT_LBTC_oracle; + PendleChainlinkOracle public YT_LBTC_oracle; + PendleChainlinkOracle public LP_LBTC_oracle; + PendleChainlinkOracleWithQuote public PT_USD_oracle; + PendleChainlinkOracleWithQuote public YT_USD_oracle; + PendleChainlinkOracleWithQuote public LP_USD_oracle; + + IChainlinkAggregator public constant LBTC_USD_feed = IChainlinkAggregator(0x5c29868C58b6e15e2b962943278969Ab6a7D3212); + + uint16 public constant twapDuration = 900; + + function setUp() public virtual { + vm.createSelectFork({ urlOrAlias: "mainnet", blockNumber: 21193294 }); + (SY, PT, YT) = IPMarket(market).readTokens(); + factory = new PendleChainlinkOracleFactory(0x9a9Fa8338dd5E5B2188006f1Cd2Ef26d921650C2); + PT_LBTC_oracle = PendleChainlinkOracle( + factory.createOracle(address(market), twapDuration, PendleOracleType.PT_TO_SY) + ); + YT_LBTC_oracle = PendleChainlinkOracle( + factory.createOracle(address(market), twapDuration, PendleOracleType.YT_TO_SY) + ); + LP_LBTC_oracle = PendleChainlinkOracle( + factory.createOracle(address(market), twapDuration, PendleOracleType.LP_TO_SY) + ); + + PT_USD_oracle = PendleChainlinkOracleWithQuote( + factory.createOracleWithQuote(address(market), twapDuration, PendleOracleType.PT_TO_SY, address(LBTC_USD_feed)) + ); + YT_USD_oracle = PendleChainlinkOracleWithQuote( + factory.createOracleWithQuote(address(market), twapDuration, PendleOracleType.YT_TO_SY, address(LBTC_USD_feed)) + ); + LP_USD_oracle = PendleChainlinkOracleWithQuote( + factory.createOracleWithQuote(address(market), twapDuration, PendleOracleType.LP_TO_SY, address(LBTC_USD_feed)) + ); + } + + function test_get_prices_in_SY() external view { + (uint80 roundId, int256 answer, , uint256 updatedAt, uint80 answeredInRound) = PT_LBTC_oracle.latestRoundData(); + console.log("PT LBTC to SY-LBTC"); + console.log(uint256(roundId), uint256(answer), updatedAt, uint256(answeredInRound)); + // answer = 992893819205953801, meaning 1 PT = 0.992893819205953801 SY-LBTC + + (roundId, answer, , updatedAt, answeredInRound) = YT_LBTC_oracle.latestRoundData(); + console.log("YT LBTC to SY-LBTC"); + console.log(uint256(roundId), uint256(answer), updatedAt, uint256(answeredInRound)); + // answer = 7106180794046199, meaning 1 YT = 0.007106180794046199 SY-LBTC + + (roundId, answer, , updatedAt, answeredInRound) = LP_LBTC_oracle.latestRoundData(); + console.log("LP LBTC to SY-LBTC"); + console.log(uint256(roundId), uint256(answer), updatedAt, uint256(answeredInRound)); + // answer = 20865967605624365040000000000, meaning 1 LP = 20865967605.624363 SY-LBTC (note that 1 LP = 10^18 unit of LP, actual LP qty is much smaller) + } + + function test_get_prices_in_quote() external view { + (uint80 roundId, int256 answer, , uint256 updatedAt, uint80 answeredInRound) = PT_USD_oracle.latestRoundData(); + console.log("PT LBTC to BTC"); + console.log(uint256(roundId), uint256(answer), updatedAt, uint256(answeredInRound)); + // answer = 990999427443599801, meaning 1 PT = 0.9909994274435997 BTC + + (roundId, answer, , updatedAt, answeredInRound) = YT_USD_oracle.latestRoundData(); + console.log("YT LBTC to BTC"); + console.log(uint256(roundId), uint256(answer), updatedAt, uint256(answeredInRound)); + // answer = 7092622556400198, meaning 1 YT = 0.007092622556400198 BTC + + (roundId, answer, , updatedAt, answeredInRound) = LP_USD_oracle.latestRoundData(); + console.log("LP LBTC to BTC"); + console.log(uint256(roundId), uint256(answer), updatedAt, uint256(answeredInRound)); + // answer = 20826156382731214032721932000, meaning 1 LP = 20826156382.731216 BTC (note that 1 LP = 10^18 unit of LP, actual LP qty is much smaller) + } +} diff --git a/test/OracleSample.sol b/test/OracleSample.sol index 456a57d..e29d6f1 100644 --- a/test/OracleSample.sol +++ b/test/OracleSample.sol @@ -6,7 +6,7 @@ import { console2 as console } from "forge-std/src/console2.sol"; import { StdCheats } from "forge-std/src/StdCheats.sol"; import "@pendle/core-v2/contracts/interfaces/IPAllActionV3.sol"; import "@pendle/core-v2/contracts/interfaces/IPMarket.sol"; -import "@pendle/core-v2/contracts/oracles/PendlePYLpOracle.sol"; +import "@pendle/core-v2/contracts/oracles/PtYtLpOracle/PendlePYLpOracle.sol"; import "../src/StructGen.sol"; import { AggregatorV2V3Interface as IChainlinkAggregator } from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";