@pendle/core-v2 4.5.1-beta-2 → 4.5.1-oracle-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol/PendleERC20WithSupplyCapSY.dbg.json +1 -1
  2. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol/PendleERC20WithSupplyCapSY.json +2 -2
  3. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol/PendleSwellRswETHStakingSY.dbg.json +4 -0
  4. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol/PendleSwellRswETHStakingSY.json +1049 -0
  5. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol/PendleSwellStakingERC20SY.dbg.json +4 -0
  6. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol/PendleSwellStakingERC20SY.json +1039 -0
  7. package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.dbg.json +1 -1
  8. package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.json +32 -1154
  9. package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.dbg.json +1 -1
  10. package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.json +60 -1182
  11. package/build/artifacts/contracts/interfaces/IPGovernanceProxy.sol/IPGovernanceProxy.dbg.json +4 -0
  12. package/build/artifacts/contracts/interfaces/IPGovernanceProxy.sol/IPGovernanceProxy.json +60 -0
  13. package/build/artifacts/contracts/interfaces/IPPYLpOracle.sol/IPPYLpOracle.dbg.json +4 -0
  14. package/build/artifacts/contracts/interfaces/{IPPtLpOracle.sol/IPPtLpOracle.json → IPPYLpOracle.sol/IPPYLpOracle.json} +50 -2
  15. package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.dbg.json +4 -0
  16. package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.json +25 -0
  17. package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.dbg.json +4 -0
  18. package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.json +207 -0
  19. package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.dbg.json +4 -0
  20. package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.json +401 -0
  21. package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.dbg.json +1 -1
  22. package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.json +2 -2
  23. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
  24. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.json +2 -2
  25. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
  26. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.json +2 -2
  27. package/build/artifacts/contracts/oracles/PendlePYLpOracle.sol/PendlePYLpOracle.dbg.json +4 -0
  28. package/build/artifacts/contracts/oracles/PendlePYLpOracle.sol/PendlePYLpOracle.json +422 -0
  29. package/build/artifacts/contracts/oracles/PendlePYOracleLib.sol/PendlePYOracleLib.dbg.json +4 -0
  30. package/build/artifacts/contracts/oracles/{PendlePtOracleLib.sol/PendlePtOracleLib.json → PendlePYOracleLib.sol/PendlePYOracleLib.json} +4 -4
  31. package/build/artifacts/contracts/oracles/samples/BoringLpGlpOracle.sol/BoringLpGlpOracle.dbg.json +1 -1
  32. package/build/artifacts/contracts/oracles/samples/BoringLpGlpOracle.sol/BoringLpGlpOracle.json +2 -2
  33. package/build/artifacts/contracts/oracles/samples/BoringPYUsdChainlinkAssetOracle.sol/BoringPYUsdChainlinkAssetOracle.dbg.json +4 -0
  34. package/build/artifacts/contracts/oracles/samples/BoringPYUsdChainlinkAssetOracle.sol/BoringPYUsdChainlinkAssetOracle.json +183 -0
  35. package/build/artifacts/contracts/oracles/samples/BoringPYUsdChainlinkSYOracle.sol/BoringPYUsdChainlinkSYOracle.dbg.json +4 -0
  36. package/build/artifacts/contracts/oracles/samples/BoringPYUsdChainlinkSYOracle.sol/BoringPYUsdChainlinkSYOracle.json +183 -0
  37. package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.dbg.json +1 -1
  38. package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.json +2 -2
  39. package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.dbg.json +1 -1
  40. package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.json +34 -1156
  41. package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.dbg.json +1 -1
  42. package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.json +2 -2
  43. package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.dbg.json +1 -1
  44. package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.json +2 -2
  45. package/build/artifacts/contracts/router/base/ActionBase.sol/ActionBase.dbg.json +1 -1
  46. package/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol +6 -1
  47. package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol +56 -0
  48. package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol +111 -0
  49. package/contracts/interfaces/IPActionMiscV3.sol +0 -92
  50. package/contracts/interfaces/IPGovernanceProxy.sol +14 -0
  51. package/contracts/interfaces/{IPPtLpOracle.sol → IPPYLpOracle.sol} +5 -1
  52. package/contracts/interfaces/IPPausingInterface.sol +8 -0
  53. package/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol +66 -0
  54. package/contracts/offchain-helpers/PendleGovernanceProxy.sol +84 -0
  55. package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +12 -4
  56. package/contracts/oracles/PendleLpOracleLib.sol +4 -4
  57. package/contracts/oracles/{PendlePtLpOracle.sol → PendlePYLpOracle.sol} +44 -16
  58. package/contracts/oracles/{PendlePtOracleLib.sol → PendlePYOracleLib.sol} +31 -1
  59. package/contracts/oracles/samples/BoringLpGlpOracle.sol +2 -2
  60. package/contracts/oracles/samples/{BoringPtUsdChainlinkOracle.sol → BoringPYUsdChainlinkAssetOracle.sol} +36 -12
  61. package/contracts/oracles/samples/BoringPYUsdChainlinkSYOracle.sol +102 -0
  62. package/contracts/router/ActionMiscV3.sol +36 -150
  63. package/contracts/router/ActionSwapYTV3.sol +85 -0
  64. package/contracts/router/base/ActionBase.sol +1 -106
  65. package/deployments/1-markets/EZETH-MAINNET-SEP2024.json +11 -0
  66. package/deployments/1-markets/PUFETH-MAINNET-SEP2024.json +11 -0
  67. package/deployments/1-markets/RSETH-MAINNET-SEP2024.json +11 -0
  68. package/deployments/1-markets/RSWETH-SWELL-STAKING-MAINNET-JUL2024.json +11 -0
  69. package/deployments/1-markets/SUSDE-MAINNET-SEP2024.json +13 -0
  70. package/deployments/1-markets/WEETH-MAINNET-SEP2024.json +11 -0
  71. package/deployments/42161-markets/EZETH-ARB-SEP2024.json +11 -0
  72. package/deployments/42161-markets/RSETH-ARBITRUM-SEP2024.json +11 -0
  73. package/deployments/42161-markets/SILO-PTEETH-ARBITRUM-JUNE2024.json +11 -0
  74. package/deployments/42161-markets/SILO-PTEZETH-ARBITRUM-JUNE2024.json +11 -0
  75. package/deployments/42161-markets/WEETH-ARB-SEP2024.json +11 -0
  76. package/deployments/56-markets/WEETH-BSC-SEP2024.json +11 -0
  77. package/package.json +1 -1
  78. package/typechain-types/ActionMiscV3.ts +16 -573
  79. package/typechain-types/BoringPYUsdChainlinkAssetOracle.ts +244 -0
  80. package/typechain-types/BoringPYUsdChainlinkSYOracle.ts +243 -0
  81. package/typechain-types/IPActionMiscV3.ts +16 -573
  82. package/typechain-types/IPAllActionV3.ts +0 -480
  83. package/typechain-types/IPGovernanceProxy.ts +142 -0
  84. package/typechain-types/IPPYLpOracle.ts +379 -0
  85. package/typechain-types/IPPausingInterface.ts +112 -0
  86. package/typechain-types/PendleGovernanceProxy.ts +603 -0
  87. package/typechain-types/PendlePYLpOracle.ts +612 -0
  88. package/typechain-types/factories/ActionAddRemoveLiqV3__factory.ts +1 -1
  89. package/typechain-types/factories/ActionMarketAuxStatic__factory.ts +1 -1
  90. package/typechain-types/factories/ActionMiscV3__factory.ts +33 -1155
  91. package/typechain-types/factories/ActionSwapPTV3__factory.ts +1 -1
  92. package/typechain-types/factories/ActionSwapYTV3__factory.ts +1 -1
  93. package/typechain-types/factories/BoringLpGlpOracle__factory.ts +1 -1
  94. package/typechain-types/factories/BoringPYUsdChainlinkAssetOracle__factory.ts +269 -0
  95. package/typechain-types/factories/BoringPYUsdChainlinkSYOracle__factory.ts +267 -0
  96. package/typechain-types/factories/IPActionMiscV3__factory.ts +32 -1154
  97. package/typechain-types/factories/IPAllActionV3__factory.ts +60 -1182
  98. package/typechain-types/factories/IPGovernanceProxy__factory.ts +75 -0
  99. package/typechain-types/factories/IPPYLpOracle__factory.ts +214 -0
  100. package/typechain-types/factories/IPPausingInterface__factory.ts +40 -0
  101. package/typechain-types/factories/PendleERC20WithSupplyCapSY__factory.ts +1 -1
  102. package/typechain-types/factories/PendleGovernanceProxy__factory.ts +458 -0
  103. package/typechain-types/factories/PendlePYLpOracle__factory.ts +487 -0
  104. package/typechain-types/factories/PendlePoolDeployHelper__factory.ts +1 -1
  105. package/typechain-types/factories/PendleSwellRswETHStakingSY__factory.ts +1 -1
  106. package/typechain-types/hardhat.d.ts +90 -0
  107. package/typechain-types/index.ts +20 -0
  108. package/build/artifacts/contracts/interfaces/IPPtLpOracle.sol/IPPtLpOracle.dbg.json +0 -4
  109. package/build/artifacts/contracts/oracles/PendlePtLpOracle.sol/PendlePtLpOracle.dbg.json +0 -4
  110. package/build/artifacts/contracts/oracles/PendlePtLpOracle.sol/PendlePtLpOracle.json +0 -367
  111. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +0 -4
  112. package/build/artifacts/contracts/oracles/samples/BoringPtUsdChainlinkOracle.sol/BoringPtUsdChainlinkOracle.dbg.json +0 -4
  113. package/build/artifacts/contracts/oracles/samples/BoringPtUsdChainlinkOracle.sol/BoringPtUsdChainlinkOracle.json +0 -157
  114. /package/deployments/1-markets/{EZETH-JUNE2024.json → EZETH-APR2024.json} +0 -0
  115. /package/deployments/42161-markets/{RSETH-MAY2024.json → RSETH-JUNE2024.json} +0 -0
  116. /package/deployments/42161-markets/{WEETH-MAY2024.json → WEETH-JUNE2024.json} +0 -0
@@ -26,26 +26,6 @@ interface IPActionMiscV3 {
26
26
  bytes returnData;
27
27
  }
28
28
 
29
- struct ExitPreExpReturnParams {
30
- uint256 netPtFromRemove;
31
- uint256 netSyFromRemove;
32
- uint256 netPyRedeem;
33
- uint256 netSyFromRedeem;
34
- uint256 netPtSwap;
35
- uint256 netYtSwap;
36
- uint256 netSyFromSwap;
37
- uint256 netSyFee;
38
- uint256 totalSyOut;
39
- }
40
-
41
- struct ExitPostExpReturnParams {
42
- uint256 netPtFromRemove;
43
- uint256 netSyFromRemove;
44
- uint256 netPtRedeem;
45
- uint256 netSyFromRedeem;
46
- uint256 totalSyOut;
47
- }
48
-
49
29
  event MintSyFromToken(
50
30
  address indexed caller,
51
31
  address indexed tokenIn,
@@ -100,42 +80,6 @@ interface IPActionMiscV3 {
100
80
  uint256 netSyInterm
101
81
  );
102
82
 
103
- event ExitPreExpToToken(
104
- address indexed caller,
105
- address indexed market,
106
- address indexed token,
107
- address receiver,
108
- uint256 netLpToRemove,
109
- uint256 totalTokenOut,
110
- ExitPreExpReturnParams params
111
- );
112
-
113
- event ExitPreExpToSy(
114
- address indexed caller,
115
- address indexed market,
116
- address indexed receiver,
117
- uint256 netLpToRemove,
118
- ExitPreExpReturnParams params
119
- );
120
-
121
- event ExitPostExpToToken(
122
- address indexed caller,
123
- address indexed market,
124
- address indexed token,
125
- address receiver,
126
- uint256 netLpIn,
127
- uint256 totalTokenOut,
128
- ExitPostExpReturnParams params
129
- );
130
-
131
- event ExitPostExpToSy(
132
- address indexed caller,
133
- address indexed market,
134
- address indexed receiver,
135
- uint256 netLpIn,
136
- ExitPostExpReturnParams params
137
- );
138
-
139
83
  function mintSyFromToken(
140
84
  address receiver,
141
85
  address SY,
@@ -199,42 +143,6 @@ interface IPActionMiscV3 {
199
143
  uint256 minTokenOut
200
144
  ) external payable returns (uint256 netTokenOut, uint256 netSyInterm);
201
145
 
202
- function exitPreExpToToken(
203
- address receiver,
204
- address market,
205
- uint256 netPtIn,
206
- uint256 netYtIn,
207
- uint256 netLpIn,
208
- TokenOutput calldata output,
209
- LimitOrderData calldata limit
210
- ) external returns (uint256 netTokenOut, ExitPreExpReturnParams memory params);
211
-
212
- function exitPreExpToSy(
213
- address receiver,
214
- address market,
215
- uint256 netPtIn,
216
- uint256 netYtIn,
217
- uint256 netLpIn,
218
- uint256 minSyOut,
219
- LimitOrderData calldata limit
220
- ) external returns (ExitPreExpReturnParams memory params);
221
-
222
- function exitPostExpToToken(
223
- address receiver,
224
- address market,
225
- uint256 netPtIn,
226
- uint256 netLpIn,
227
- TokenOutput calldata output
228
- ) external returns (uint256 netTokenOut, ExitPostExpReturnParams memory params);
229
-
230
- function exitPostExpToSy(
231
- address receiver,
232
- address market,
233
- uint256 netPtIn,
234
- uint256 netLpIn,
235
- uint256 minSyOut
236
- ) external returns (ExitPostExpReturnParams memory params);
237
-
238
146
  function boostMarkets(address[] memory markets) external;
239
147
 
240
148
  function multicall(Call3[] calldata calls) external payable returns (Result[] memory res);
@@ -0,0 +1,14 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity ^0.8.0;
3
+
4
+ interface IPGovernanceProxy {
5
+ struct Call {
6
+ address target;
7
+ uint256 value;
8
+ bytes callData;
9
+ }
10
+
11
+ function pause(address[] calldata addrs) external;
12
+
13
+ function aggregate(Call[] calldata calls) external payable returns (bytes[] memory rtnData);
14
+ }
@@ -1,15 +1,19 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- interface IPPtLpOracle {
4
+ interface IPPYLpOracle {
5
5
  event SetBlockCycleNumerator(uint16 newBlockCycleNumerator);
6
6
 
7
7
  function getPtToAssetRate(address market, uint32 duration) external view returns (uint256);
8
8
 
9
+ function getYtToAssetRate(address market, uint32 duration) external view returns (uint256);
10
+
9
11
  function getLpToAssetRate(address market, uint32 duration) external view returns (uint256);
10
12
 
11
13
  function getPtToSyRate(address market, uint32 duration) external view returns (uint256);
12
14
 
15
+ function getYtToSyRate(address market, uint32 duration) external view returns (uint256);
16
+
13
17
  function getLpToSyRate(address market, uint32 duration) external view returns (uint256);
14
18
 
15
19
  function getOracleState(
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity ^0.8.0;
3
+
4
+ interface IPPausingInterface {
5
+ function pause() external;
6
+
7
+ function unpause() external;
8
+ }
@@ -0,0 +1,66 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.0;
3
+
4
+ interface ISwellSimpleStakingERC20 {
5
+ /// @notice Struct to hold the supported booleans
6
+ /// @param deposit true if deposit is supported
7
+ /// @param withdraw true if withdraw is supported
8
+ struct Supported {
9
+ bool deposit;
10
+ bool withdraw;
11
+ }
12
+
13
+ /// @notice Error emitted when the amount is null
14
+ error AMOUNT_NULL();
15
+
16
+ /// @notice Error emitted when the address is null
17
+ error ADDRESS_NULL();
18
+
19
+ /// @notice Error emitted when the balance is insufficient
20
+ error INSUFFICIENT_BALANCE();
21
+
22
+ /// @notice Error emitted when the token is not allowed
23
+ error TOKEN_NOT_ALLOWED(address token);
24
+
25
+ /// @notice Event emitted when a token is added or removed
26
+ /// @param token address of the token
27
+ /// @param supported struct with deposit and withdraw booleans
28
+ event SupportedToken(address indexed token, Supported supported);
29
+
30
+ /// @notice Event emitted when a deposit is made
31
+ /// @param token address of the token
32
+ /// @param staker address of the staker
33
+ /// @param amount amount of the deposit
34
+ event Deposit(address indexed token, address indexed staker, uint256 amount);
35
+
36
+ /// @notice Event emitted when a withdrawal is made
37
+ /// @param token address of the token
38
+ /// @param staker address of the staker
39
+ /// @param amount amount of the withdrawal
40
+ event Withdraw(address indexed token, address indexed staker, uint256 amount);
41
+
42
+ /// @notice Method to deposit tokens
43
+ /// @dev token are transferred from the sender, and the receiver is credited
44
+ /// @param _token address of the token
45
+ /// @param _amount amount to deposit
46
+ /// @param _receiver address of the receiver
47
+ function deposit(address _token, uint256 _amount, address _receiver) external;
48
+
49
+ /// @notice Method to rescue tokens, only callable by the owner
50
+ /// @dev difference between balance and internal balance is transferred to the owner
51
+ /// @param _token address of the token
52
+ function rescueERC20(address _token) external;
53
+
54
+ /// @notice Method to add or remove a token
55
+ /// @dev only callable by the owner
56
+ /// @param _token address of the token
57
+ /// @param _supported struct with deposit and withdraw booleans
58
+ function supportToken(address _token, Supported calldata _supported) external;
59
+
60
+ /// @notice Method to rescue tokens, only callable by the owner
61
+ /// @dev token are transferred to the receiver and sender is credited
62
+ /// @param _token address of the token
63
+ /// @param _amount amount to withdraw
64
+ /// @param _receiver address of the receiver
65
+ function withdraw(address _token, uint256 _amount, address _receiver) external;
66
+ }
@@ -0,0 +1,84 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import "../interfaces/IPPausingInterface.sol";
5
+ import "../interfaces/IPGovernanceProxy.sol";
6
+ import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
7
+ import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
8
+
9
+ // solhint-disable custom-errors
10
+ // solhint-disable no-inline-assembly
11
+ // solhint-disable no-empty-blocks
12
+
13
+ contract PendleGovernanceProxy is AccessControlUpgradeable, UUPSUpgradeable, IPGovernanceProxy {
14
+ bytes32 public constant GUARDIAN = keccak256("GUARDIAN");
15
+
16
+ modifier onlyGuardian() {
17
+ require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(GUARDIAN, msg.sender), "not authorized");
18
+ _;
19
+ }
20
+
21
+ modifier onlyAdmin() {
22
+ require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "not authorized");
23
+ _;
24
+ }
25
+
26
+ constructor() {
27
+ _disableInitializers();
28
+ }
29
+
30
+ /*///////////////////////////////////////////////////////////////
31
+ PAUSING
32
+ //////////////////////////////////////////////////////////////*/
33
+
34
+ function pause(address[] calldata addrs) external onlyGuardian {
35
+ uint256 length = addrs.length;
36
+ for (uint256 i = 0; i < length; ) {
37
+ IPPausingInterface(addrs[i]).pause();
38
+ unchecked {
39
+ ++i;
40
+ }
41
+ }
42
+ }
43
+
44
+ /*///////////////////////////////////////////////////////////////
45
+ ADMIN CALL
46
+ //////////////////////////////////////////////////////////////*/
47
+
48
+ function aggregate(
49
+ IPGovernanceProxy.Call[] calldata calls
50
+ ) external payable onlyAdmin returns (bytes[] memory rtnData) {
51
+ uint256 length = calls.length;
52
+ rtnData = new bytes[](length);
53
+
54
+ Call calldata call;
55
+ for (uint256 i = 0; i < length; ) {
56
+ call = calls[i];
57
+
58
+ (bool success, bytes memory resp) = call.target.call{value: call.value}(call.callData);
59
+ if (!success) {
60
+ assembly {
61
+ revert(add(32, resp), mload(resp))
62
+ }
63
+ }
64
+
65
+ rtnData[i] = resp;
66
+
67
+ unchecked {
68
+ ++i;
69
+ }
70
+ }
71
+ }
72
+
73
+ receive() external payable {}
74
+
75
+ /*///////////////////////////////////////////////////////////////
76
+ UPGRADABLE RELATED
77
+ //////////////////////////////////////////////////////////////*/
78
+
79
+ function initialize(address governance) external initializer {
80
+ _grantRole(DEFAULT_ADMIN_ROLE, governance);
81
+ }
82
+
83
+ function _authorizeUpgrade(address) internal view override onlyAdmin {}
84
+ }
@@ -114,12 +114,20 @@ contract ActionMarketAuxStatic is IPActionMarketAuxStatic {
114
114
  function getLpToAssetRate(address market) public view returns (uint256) {
115
115
  MarketState memory state = _readState(market);
116
116
  PYIndex pyIndexCurrent = _pyIndex(market);
117
- MarketPreCompute memory comp = state.getMarketPreCompute(pyIndexCurrent, block.timestamp);
118
117
 
119
- int256 totalHypotheticalAsset = comp.totalAsset +
120
- state.totalPt.mulDown(int256(_getPtToAssetRate(market, state, pyIndexCurrent)));
118
+ int256 totalHypotheticalAsset;
119
+ if (state.expiry <= block.timestamp) {
120
+ // 1 PT = 1 Asset post-expiry
121
+ totalHypotheticalAsset = state.totalPt + pyIndexCurrent.syToAsset(state.totalSy);
122
+ } else {
123
+ MarketPreCompute memory comp = state.getMarketPreCompute(pyIndexCurrent, block.timestamp);
124
+
125
+ totalHypotheticalAsset =
126
+ comp.totalAsset +
127
+ state.totalPt.mulDown(int256(_getPtToAssetRate(market, state, pyIndexCurrent)));
128
+ }
121
129
 
122
- return uint256(totalHypotheticalAsset.divDown(state.totalLp));
130
+ return totalHypotheticalAsset.divDown(state.totalLp).Uint();
123
131
  }
124
132
 
125
133
  function getPtToAssetRate(address market) public view returns (uint256) {
@@ -1,10 +1,10 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- import "./PendlePtOracleLib.sol";
4
+ import "./PendlePYOracleLib.sol";
5
5
 
6
6
  library PendleLpOracleLib {
7
- using PendlePtOracleLib for IPMarket;
7
+ using PendlePYOracleLib for IPMarket;
8
8
  using PMath for uint256;
9
9
  using PMath for int256;
10
10
  using MarketMathCore for MarketState;
@@ -16,7 +16,7 @@ library PendleLpOracleLib {
16
16
  * @param duration twap duration
17
17
  */
18
18
  function getLpToAssetRate(IPMarket market, uint32 duration) internal view returns (uint256) {
19
- (uint256 syIndex, uint256 pyIndex) = PendlePtOracleLib.getSYandPYIndexCurrent(market);
19
+ (uint256 syIndex, uint256 pyIndex) = PendlePYOracleLib.getSYandPYIndexCurrent(market);
20
20
  uint256 lpToAssetRateRaw = _getLpToAssetRateRaw(market, duration, pyIndex);
21
21
  if (syIndex >= pyIndex) {
22
22
  return lpToAssetRateRaw;
@@ -32,7 +32,7 @@ library PendleLpOracleLib {
32
32
  * @param duration twap duration
33
33
  */
34
34
  function getLpToSyRate(IPMarket market, uint32 duration) internal view returns (uint256) {
35
- (uint256 syIndex, uint256 pyIndex) = PendlePtOracleLib.getSYandPYIndexCurrent(market);
35
+ (uint256 syIndex, uint256 pyIndex) = PendlePYOracleLib.getSYandPYIndexCurrent(market);
36
36
  uint256 lpToAssetRateRaw = _getLpToAssetRateRaw(market, duration, pyIndex);
37
37
  if (syIndex >= pyIndex) {
38
38
  return lpToAssetRateRaw.divDown(syIndex);
@@ -1,16 +1,16 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
  pragma solidity ^0.8.17;
3
3
 
4
- import "./PendlePtOracleLib.sol";
4
+ import "./PendlePYOracleLib.sol";
5
5
  import "./PendleLpOracleLib.sol";
6
- import "../interfaces/IPPtLpOracle.sol";
6
+ import "../interfaces/IPPYLpOracle.sol";
7
7
  import "../core/libraries/BoringOwnableUpgradeable.sol";
8
8
 
9
9
  // This is a pre-deployed version of PendlePtOracleLib & PendleLpOracleLib with additional utility functions.
10
10
  // Use of this contract rather than direct library integration resulting in a smaller bytecode size and simpler structure
11
11
  // but slightly higher gas usage (~ 4000 gas, 2 external calls & 1 cold code load)
12
- contract PendlePtLpOracle is BoringOwnableUpgradeable, IPPtLpOracle {
13
- using PendlePtOracleLib for IPMarket;
12
+ contract PendlePYLpOracle is BoringOwnableUpgradeable, IPPYLpOracle {
13
+ using PendlePYOracleLib for IPMarket;
14
14
  using PendleLpOracleLib for IPMarket;
15
15
 
16
16
  error InvalidBlockRate(uint256 blockCycleNumerator);
@@ -26,38 +26,52 @@ contract PendlePtLpOracle is BoringOwnableUpgradeable, IPPtLpOracle {
26
26
  uint16 public blockCycleNumerator;
27
27
  uint16 public constant BLOCK_CYCLE_DENOMINATOR = 1000;
28
28
 
29
- constructor(uint16 _blockCycleNumerator) initializer {
30
- __BoringOwnable_init();
31
- setBlockCycleNumerator(_blockCycleNumerator);
29
+ constructor(uint16 _blockCycleNumerator) {
30
+ _setBlockCycleNumerator(_blockCycleNumerator);
32
31
  }
33
32
 
34
- function setBlockCycleNumerator(uint16 newBlockCycleNumerator) public onlyOwner {
35
- if (newBlockCycleNumerator < BLOCK_CYCLE_DENOMINATOR) {
36
- revert InvalidBlockRate(newBlockCycleNumerator);
37
- }
38
-
39
- blockCycleNumerator = newBlockCycleNumerator;
40
- emit SetBlockCycleNumerator(newBlockCycleNumerator);
33
+ function initialize() external initializer {
34
+ __BoringOwnable_init();
41
35
  }
42
36
 
37
+ /*///////////////////////////////////////////////////////////////
38
+ PT, YT, LP to Asset (see EIP-5115)
39
+ //////////////////////////////////////////////////////////////*/
40
+
41
+ /// @notice make sure you have taken into account the risk of not being able to withdraw from SY to Asset
42
+ /// More info in StandardizedYield
43
43
  function getPtToAssetRate(address market, uint32 duration) external view returns (uint256) {
44
44
  return IPMarket(market).getPtToAssetRate(duration);
45
45
  }
46
46
 
47
- /// @notice make sure you have taken into account the risk of not being able to withdraw from SY to Asset
48
- /// More info in StandardizedYield
47
+ function getYtToAssetRate(address market, uint32 duration) external view returns (uint256) {
48
+ return IPMarket(market).getYtToAssetRate(duration);
49
+ }
50
+
49
51
  function getLpToAssetRate(address market, uint32 duration) external view returns (uint256) {
50
52
  return IPMarket(market).getLpToAssetRate(duration);
51
53
  }
52
54
 
55
+ /*///////////////////////////////////////////////////////////////
56
+ PT, YT, LP to SY (repricing token)
57
+ //////////////////////////////////////////////////////////////*/
58
+
53
59
  function getPtToSyRate(address market, uint32 duration) external view returns (uint256) {
54
60
  return IPMarket(market).getPtToSyRate(duration);
55
61
  }
56
62
 
63
+ function getYtToSyRate(address market, uint32 duration) external view returns (uint256) {
64
+ return IPMarket(market).getYtToSyRate(duration);
65
+ }
66
+
57
67
  function getLpToSyRate(address market, uint32 duration) external view returns (uint256) {
58
68
  return IPMarket(market).getLpToSyRate(duration);
59
69
  }
60
70
 
71
+ /*///////////////////////////////////////////////////////////////
72
+ Utility functions
73
+ //////////////////////////////////////////////////////////////*/
74
+
61
75
  /**
62
76
  * A check function for the cardinality status of the market
63
77
  * @param market PendleMarket address
@@ -99,4 +113,18 @@ contract PendlePtLpOracle is BoringOwnableUpgradeable, IPPtLpOracle {
99
113
  }
100
114
  return uint16(cardinalityRequired);
101
115
  }
116
+
117
+ // --- Owner-Only Functions ---
118
+ function setBlockCycleNumerator(uint16 newBlockCycleNumerator) external onlyOwner {
119
+ _setBlockCycleNumerator(newBlockCycleNumerator);
120
+ }
121
+
122
+ function _setBlockCycleNumerator(uint16 newBlockCycleNumerator) internal {
123
+ if (newBlockCycleNumerator < BLOCK_CYCLE_DENOMINATOR) {
124
+ revert InvalidBlockRate(newBlockCycleNumerator);
125
+ }
126
+
127
+ blockCycleNumerator = newBlockCycleNumerator;
128
+ emit SetBlockCycleNumerator(newBlockCycleNumerator);
129
+ }
102
130
  }
@@ -6,7 +6,7 @@ import "../core/libraries/math/PMath.sol";
6
6
 
7
7
  // This library can & should be integrated directly for optimal gas usage.
8
8
  // If you prefer not to integrate it directly, the PendlePtOracle contract (a pre-deployed version of this contract) can be used.
9
- library PendlePtOracleLib {
9
+ library PendlePYOracleLib {
10
10
  using PMath for uint256;
11
11
  using PMath for int256;
12
12
 
@@ -25,6 +25,21 @@ library PendlePtOracleLib {
25
25
  }
26
26
  }
27
27
 
28
+ /**
29
+ * This function returns the twap rate YT/Asset on market, but take into account the current rate of SY
30
+ This is to account for special cases where underlying asset becomes insolvent and has decreasing exchangeRate
31
+ * @param market market to get rate from
32
+ * @param duration twap duration
33
+ */
34
+ function getYtToAssetRate(IPMarket market, uint32 duration) internal view returns (uint256) {
35
+ (uint256 syIndex, uint256 pyIndex) = getSYandPYIndexCurrent(market);
36
+ if (syIndex >= pyIndex) {
37
+ return getYtToAssetRateRaw(market, duration);
38
+ } else {
39
+ return (getYtToAssetRateRaw(market, duration) * syIndex) / pyIndex;
40
+ }
41
+ }
42
+
28
43
  /// @notice Similar to getPtToAsset but returns the rate in SY instead
29
44
  function getPtToSyRate(IPMarket market, uint32 duration) internal view returns (uint256) {
30
45
  (uint256 syIndex, uint256 pyIndex) = getSYandPYIndexCurrent(market);
@@ -35,6 +50,16 @@ library PendlePtOracleLib {
35
50
  }
36
51
  }
37
52
 
53
+ /// @notice Similar to getPtToAsset but returns the rate in SY instead
54
+ function getYtToSyRate(IPMarket market, uint32 duration) internal view returns (uint256) {
55
+ (uint256 syIndex, uint256 pyIndex) = getSYandPYIndexCurrent(market);
56
+ if (syIndex >= pyIndex) {
57
+ return getYtToAssetRateRaw(market, duration).divDown(syIndex);
58
+ } else {
59
+ return getYtToAssetRateRaw(market, duration).divDown(pyIndex);
60
+ }
61
+ }
62
+
38
63
  /// @notice returns the raw rate without taking into account whether SY is solvent
39
64
  function getPtToAssetRateRaw(IPMarket market, uint32 duration) internal view returns (uint256) {
40
65
  uint256 expiry = market.expiry();
@@ -49,6 +74,11 @@ library PendlePtOracleLib {
49
74
  }
50
75
  }
51
76
 
77
+ /// @notice returns the raw rate without taking into account whether SY is solvent
78
+ function getYtToAssetRateRaw(IPMarket market, uint32 duration) internal view returns (uint256) {
79
+ return PMath.ONE - getPtToAssetRateRaw(market, duration);
80
+ }
81
+
52
82
  function getSYandPYIndexCurrent(IPMarket market) internal view returns (uint256 syIndex, uint256 pyIndex) {
53
83
  (IStandardizedYield SY, , IPYieldToken YT) = market.readTokens();
54
84
 
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.17;
3
3
 
4
4
  import "../PendleLpOracleLib.sol";
5
- import "../../interfaces/IPPtLpOracle.sol";
5
+ import "../../interfaces/IPPYLpOracle.sol";
6
6
  import "../../interfaces/GMX/IGlpManager.sol";
7
7
  import "../../core/libraries/math/PMath.sol";
8
8
 
@@ -23,7 +23,7 @@ contract BoringLpGlpOracle {
23
23
  market = _market;
24
24
  glpManager = _glpManager;
25
25
 
26
- (bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPtLpOracle(_ptOracle).getOracleState(
26
+ (bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = IPPYLpOracle(_ptOracle).getOracleState(
27
27
  market,
28
28
  twapDuration
29
29
  );
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
  pragma solidity ^0.8.17;
3
3
 
4
- import "../../interfaces/IPPtLpOracle.sol";
4
+ import "../../interfaces/IPPYLpOracle.sol";
5
5
  import "../../interfaces/IPMarket.sol";
6
6
  import "../../core/libraries/math/PMath.sol";
7
7
  import "../PendleLpOracleLib.sol";
@@ -9,29 +9,41 @@ import "../PendleLpOracleLib.sol";
9
9
  import {AggregatorV2V3Interface as IChainlinkAggregator} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
10
10
 
11
11
  /**
12
- * @notice The returned price from this contract is multiplied by the default USD price of the asset, as read from Chainlink Oracles.
13
- * For more details into how the oracle is implemented, refer to PendlePtOracle & PendlePtOracleLib.
12
+ * @notice The returned price from this contract is multiplied by the default USD price of the
13
+ * underlying asset, as read from a Chainlink-interface oracle.
14
+ *
15
+ * Example of this usage:
16
+ * - PT-wstETH = ptToAssetRate * stETH price
17
+ * - PT-silo-crvUSD = ptToAssetRate * crvUSD price
18
+ *
19
+ * For more details into how the oracle is implemented, refer to PendlePYLpOracle & PendlePYOracleLib.
14
20
  */
15
- contract BoringPtUsdChainlinkOracle {
16
- using PendlePtOracleLib for IPMarket;
21
+ contract BoringPYUsdChainlinkAssetOracle {
22
+ using PendlePYOracleLib for IPMarket;
17
23
 
18
24
  uint32 public immutable twapDuration;
19
25
  address public immutable market;
20
26
  address public immutable feed;
21
27
  uint8 public immutable feedDecimals;
22
- address public immutable ptOracle;
28
+ address public immutable pyLpOracle;
23
29
 
24
- constructor(uint32 _twapDuration, address _market, address _feed, address _ptOracle) {
30
+ constructor(uint32 _twapDuration, address _market, address _feed, address _pyLpOracle) {
25
31
  twapDuration = _twapDuration;
26
32
  market = _market;
27
33
  feed = _feed;
28
34
  feedDecimals = IChainlinkAggregator(feed).decimals();
29
35
 
30
36
  // required only for sample2
31
- ptOracle = _ptOracle;
37
+ pyLpOracle = _pyLpOracle;
38
+
39
+ /**
40
+ * @notice All pricing functions in this contract should only be used after checkOracleState() is ran successfully without reverting.
41
+ * This equals to calling checkOracleState() in your oracle constructor.
42
+ */
43
+ // checkOracleState();
32
44
  }
33
45
 
34
- /// @notice direct integration with PendlePtOracleLib, which optimizes gas efficiency.
46
+ /// @notice direct integration with PendlePYOracleLib, which optimizes gas efficiency.
35
47
  /// @notice please checkOracleState() before use
36
48
  function getPtPriceSample1() external view virtual returns (uint256) {
37
49
  uint256 ptRate = IPMarket(market).getPtToAssetRate(twapDuration);
@@ -43,11 +55,23 @@ contract BoringPtUsdChainlinkOracle {
43
55
  /// but slightly higher gas usage (~ 4000 gas, 2 external calls & 1 cold code load)
44
56
  /// @notice please checkOracleState() before use
45
57
  function getPtPriceSample2() external view virtual returns (uint256) {
46
- uint256 ptRate = IPPtLpOracle(ptOracle).getPtToAssetRate(market, twapDuration);
58
+ uint256 ptRate = IPPYLpOracle(pyLpOracle).getPtToAssetRate(market, twapDuration);
47
59
  uint256 assetPrice = _getUnderlyingAssetPrice();
48
60
  return (assetPrice * ptRate) / PMath.ONE;
49
61
  }
50
62
 
63
+ function getYtPriceSample1() external view virtual returns (uint256) {
64
+ uint256 ytRate = IPMarket(market).getYtToAssetRate(twapDuration);
65
+ uint256 assetPrice = _getUnderlyingAssetPrice();
66
+ return (assetPrice * ytRate) / PMath.ONE;
67
+ }
68
+
69
+ function getYtPriceSample2() external view virtual returns (uint256) {
70
+ uint256 ytRate = IPPYLpOracle(pyLpOracle).getYtToAssetRate(market, twapDuration);
71
+ uint256 assetPrice = _getUnderlyingAssetPrice();
72
+ return (assetPrice * ytRate) / PMath.ONE;
73
+ }
74
+
51
75
  function _getUnderlyingAssetPrice() internal view virtual returns (uint256) {
52
76
  uint256 rawPrice = uint256(IChainlinkAggregator(feed).latestAnswer());
53
77
  return feedDecimals < 18 ? rawPrice * 10 ** (18 - feedDecimals) : rawPrice / 10 ** (feedDecimals - 18);
@@ -60,8 +84,8 @@ contract BoringPtUsdChainlinkOracle {
60
84
 
61
85
  /// @notice Call only once for each (market, duration). Once successful, it's permanently valid (also for any shorter duration).
62
86
  function checkOracleState() external view {
63
- (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied) = IPPtLpOracle(
64
- ptOracle
87
+ (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied) = IPPYLpOracle(
88
+ pyLpOracle
65
89
  ).getOracleState(market, twapDuration);
66
90
 
67
91
  if (increaseCardinalityRequired) {