Skip to content

Commit ae7b08a

Browse files
authored
Merge pull request #57 from Gearbox-protocol/pendle-price-to-sy
feat: Pendle price to SY
2 parents 7389bb8 + 3a90cf0 commit ae7b08a

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

contracts/oracles/pendle/PendleTWAPPTPriceFeed.sol

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,33 @@ contract PendleTWAPPTPriceFeed is IPriceFeed, PriceFeedValidationTrait, SanityCh
5252
/// @notice The size of the TWAP observation window
5353
uint32 public immutable twapWindow;
5454

55-
constructor(address _market, address _priceFeed, uint32 _stalenessPeriod, uint32 _twapWindow) {
55+
/// @notice Whether this price feed prices to SY
56+
bool public immutable priceToSy;
57+
58+
constructor(address _market, address _priceFeed, uint32 _stalenessPeriod, uint32 _twapWindow, bool _priceToSY) {
5659
market = _market;
5760
expiry = IPendleMarket(_market).expiry();
5861
priceFeed = _priceFeed;
5962
stalenessPeriod = _stalenessPeriod;
6063
skipCheck = _validatePriceFeed(priceFeed, stalenessPeriod);
6164
twapWindow = _twapWindow;
65+
priceToSy = _priceToSY;
6266

6367
address pt;
6468

6569
(sy, pt, yt) = IPendleMarket(_market).readTokens();
6670

6771
string memory ptName = IERC20Metadata(pt).name();
6872

69-
description = string(abi.encodePacked(ptName, " Pendle Market TWAP * ", IPriceFeed(priceFeed).description()));
73+
description = string(
74+
abi.encodePacked(
75+
ptName,
76+
" Pendle Market TWAP ",
77+
priceToSy ? "to SY" : "to asset",
78+
" * ",
79+
IPriceFeed(priceFeed).description()
80+
)
81+
);
7082
}
7183

7284
/// @dev Gets the ln(impliedRate) from the market TWAP
@@ -113,6 +125,10 @@ contract PendleTWAPPTPriceFeed is IPriceFeed, PriceFeedValidationTrait, SanityCh
113125
answer = int256(uint256(answer) * syIndex / pyIndex);
114126
}
115127

128+
if (priceToSy) {
129+
answer = int256(FixedPoint.divDown(uint256(answer), syIndex));
130+
}
131+
116132
return (0, answer, 0, 0, 0);
117133
}
118134
}

contracts/test/suites/PriceFeedDeployer.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ contract PriceFeedDeployer is Test, PriceFeedDataLive {
704704
pendlePTPriceFeeds[i].market,
705705
priceFeeds[underlying],
706706
stalenessPeriods[underlying],
707-
pendlePTPriceFeeds[i].twapWindow
707+
pendlePTPriceFeeds[i].twapWindow,
708+
pendlePTPriceFeeds[i].priceToSy
708709
)
709710
);
710711

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@gearbox-protocol/core-v3": "^1.51.0",
3535
"@gearbox-protocol/eslint-config": "^1.6.1",
3636
"@gearbox-protocol/prettier-config": "^1.5.0",
37-
"@gearbox-protocol/sdk-gov": "^2.28.0",
37+
"@gearbox-protocol/sdk-gov": "^2.30.0",
3838
"@openzeppelin/contracts": "4.9.3",
3939
"@redstone-finance/evm-connector": "0.2.5",
4040
"@typechain/ethers-v5": "^10.1.0",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,10 +993,10 @@
993993
resolved "https://registry.yarnpkg.com/@gearbox-protocol/prettier-config/-/prettier-config-1.5.0.tgz#4df8e9fd2305fee6ab8c1417a02e31343836932a"
994994
integrity sha512-FUoprSsBdZyBjgxXCKL6mTkbeUJytaLzPJqIOoQpDmBRTX0seCc2o5I9PI9tySoRIlNnd/XXnKCXq1xHDEGbxw==
995995

996-
"@gearbox-protocol/sdk-gov@^2.28.0":
997-
version "2.28.0"
998-
resolved "https://registry.yarnpkg.com/@gearbox-protocol/sdk-gov/-/sdk-gov-2.28.0.tgz#f858222b0d4bf2661e7213d250f96e112aee8ce3"
999-
integrity sha512-qwvXZALpqYRAc77B6ZC0OSIDk6uEX8Z1B10yfN10ETBvftnDvMwJ6XVhVt/RyRgeW0vqh0W6T4F/y2PFiiW0bw==
996+
"@gearbox-protocol/sdk-gov@^2.30.0":
997+
version "2.30.0"
998+
resolved "https://registry.yarnpkg.com/@gearbox-protocol/sdk-gov/-/sdk-gov-2.30.0.tgz#9a82585b2d8c70ba3f015b6e2fe018f4b335c857"
999+
integrity sha512-y72nz8ZBO4U+wH2XeDA4xaeCEQNRZk86i7UlfIGgSt6rj+Y3AFyWarwH6UqxoVdQ2KAYFJxVxOihk72IQPe7rw==
10001000
dependencies:
10011001
ethers "6.12.1"
10021002
humanize-duration-ts "^2.1.1"

0 commit comments

Comments
 (0)