@pendle/core-v2 4.5.1-beta-1 → 4.5.1-beta-3

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 (104) 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 +805 -80
  9. package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.dbg.json +1 -1
  10. package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.json +958 -233
  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/IPPausingInterface.sol/IPPausingInterface.dbg.json +4 -0
  14. package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.json +25 -0
  15. package/build/artifacts/contracts/interfaces/IPPtLpOracle.sol/IPPtLpOracle.dbg.json +1 -1
  16. package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.dbg.json +4 -0
  17. package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.json +207 -0
  18. package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.dbg.json +4 -0
  19. package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.json +401 -0
  20. package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.dbg.json +1 -1
  21. package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.json +2 -2
  22. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
  23. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.json +2 -2
  24. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
  25. package/build/artifacts/contracts/oracles/PendlePtLpOracle.sol/PendlePtLpOracle.dbg.json +1 -1
  26. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +1 -1
  27. package/build/artifacts/contracts/oracles/samples/BoringLpGlpOracle.sol/BoringLpGlpOracle.dbg.json +1 -1
  28. package/build/artifacts/contracts/oracles/samples/BoringPtUsdChainlinkOracle.sol/BoringPtUsdChainlinkOracle.dbg.json +1 -1
  29. package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.dbg.json +1 -1
  30. package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.json +2 -2
  31. package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.dbg.json +1 -1
  32. package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.json +707 -140
  33. package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.dbg.json +1 -1
  34. package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.json +2 -2
  35. package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.dbg.json +1 -1
  36. package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.json +2 -2
  37. package/build/artifacts/contracts/router/Reflector.sol/Reflector.dbg.json +4 -0
  38. package/build/artifacts/contracts/router/Reflector.sol/Reflector.json +39 -0
  39. package/build/artifacts/contracts/router/base/ActionBase.sol/ActionBase.dbg.json +1 -1
  40. package/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol +6 -1
  41. package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol +56 -0
  42. package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol +111 -0
  43. package/contracts/interfaces/IPActionMiscV3.sol +85 -25
  44. package/contracts/interfaces/IPGovernanceProxy.sol +14 -0
  45. package/contracts/interfaces/IPPausingInterface.sol +8 -0
  46. package/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol +66 -0
  47. package/contracts/offchain-helpers/PendleGovernanceProxy.sol +84 -0
  48. package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +12 -4
  49. package/contracts/router/ActionMiscV3.sol +140 -167
  50. package/contracts/router/Reflector.sol +61 -0
  51. package/contracts/router/base/ActionBase.sol +0 -16
  52. package/deployments/1-markets/EZETH-MAINNET-SEP2024.json +11 -0
  53. package/deployments/1-markets/PUFETH-MAINNET-SEP2024.json +11 -0
  54. package/deployments/1-markets/RSETH-MAINNET-SEP2024.json +11 -0
  55. package/deployments/1-markets/RSWETH-SWELL-STAKING-MAINNET-JUL2024.json +11 -0
  56. package/deployments/1-markets/SUSDE-MAINNET-SEP2024.json +13 -0
  57. package/deployments/1-markets/UNIETH-MAINNET-SEP2024.json +13 -0
  58. package/deployments/1-markets/WEETH-MAINNET-SEP2024.json +11 -0
  59. package/deployments/42161-core.json +1 -1
  60. package/deployments/42161-markets/EZETH-ARB-SEP2024.json +11 -0
  61. package/deployments/42161-markets/RSETH-ARBITRUM-SEP2024.json +11 -0
  62. package/deployments/42161-markets/SILO-PTEETH-ARBITRUM-JUNE2024.json +11 -0
  63. package/deployments/42161-markets/SILO-PTEZETH-ARBITRUM-JUNE2024.json +11 -0
  64. package/deployments/42161-markets/WEETH-ARB-SEP2024.json +11 -0
  65. package/deployments/56-markets/WEETH-BSC-SEP2024.json +11 -0
  66. package/package.json +2 -2
  67. package/typechain-types/ActionMiscV3.ts +358 -120
  68. package/typechain-types/BoringPYUsdChainlinkAssetOracle.ts +244 -0
  69. package/typechain-types/BoringPYUsdChainlinkSYOracle.ts +243 -0
  70. package/typechain-types/IPActionMiscV3.ts +408 -40
  71. package/typechain-types/IPAllActionV3.ts +408 -40
  72. package/typechain-types/IPGovernanceProxy.ts +142 -0
  73. package/typechain-types/IPPYLpOracle.ts +379 -0
  74. package/typechain-types/IPPausingInterface.ts +112 -0
  75. package/typechain-types/IPossibleSupplyCapInterface.ts +142 -0
  76. package/typechain-types/PendleGovernanceProxy.ts +603 -0
  77. package/typechain-types/PendlePYLpOracle.ts +612 -0
  78. package/typechain-types/Reflector.ts +98 -0
  79. package/typechain-types/SupplyCapReader.ts +105 -0
  80. package/typechain-types/factories/ActionAddRemoveLiqV3__factory.ts +1 -1
  81. package/typechain-types/factories/ActionMarketAuxStatic__factory.ts +1 -1
  82. package/typechain-types/factories/ActionMiscV3__factory.ts +705 -138
  83. package/typechain-types/factories/ActionSwapPTV3__factory.ts +1 -1
  84. package/typechain-types/factories/ActionSwapYTV3__factory.ts +1 -1
  85. package/typechain-types/factories/BoringPYUsdChainlinkAssetOracle__factory.ts +269 -0
  86. package/typechain-types/factories/BoringPYUsdChainlinkSYOracle__factory.ts +267 -0
  87. package/typechain-types/factories/IPActionMiscV3__factory.ts +805 -80
  88. package/typechain-types/factories/IPAllActionV3__factory.ts +958 -233
  89. package/typechain-types/factories/IPGovernanceProxy__factory.ts +75 -0
  90. package/typechain-types/factories/IPPYLpOracle__factory.ts +214 -0
  91. package/typechain-types/factories/IPPausingInterface__factory.ts +40 -0
  92. package/typechain-types/factories/IPossibleSupplyCapInterface__factory.ts +82 -0
  93. package/typechain-types/factories/PendleERC20WithSupplyCapSY__factory.ts +1 -1
  94. package/typechain-types/factories/PendleGovernanceProxy__factory.ts +458 -0
  95. package/typechain-types/factories/PendlePYLpOracle__factory.ts +487 -0
  96. package/typechain-types/factories/PendlePoolDeployHelper__factory.ts +1 -1
  97. package/typechain-types/factories/PendleSwellRswETHStakingSY__factory.ts +1 -1
  98. package/typechain-types/factories/Reflector__factory.ts +89 -0
  99. package/typechain-types/factories/SupplyCapReader__factory.ts +88 -0
  100. package/typechain-types/hardhat.d.ts +54 -0
  101. package/typechain-types/index.ts +12 -0
  102. /package/deployments/1-markets/{EZETH-JUNE2024.json → EZETH-APR2024.json} +0 -0
  103. /package/deployments/42161-markets/{RSETH-MAY2024.json → RSETH-JUNE2024.json} +0 -0
  104. /package/deployments/42161-markets/{WEETH-MAY2024.json → WEETH-JUNE2024.json} +0 -0
@@ -0,0 +1,111 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity ^0.8.17;
3
+
4
+ import "../../SYBase.sol";
5
+ import "../../../../interfaces/Swell/ISwellSimpleStakingERC20.sol";
6
+
7
+ contract PendleSwellStakingERC20SY is SYBase {
8
+ using ArrayLib for address[];
9
+
10
+ address public constant SWELL_STAKING = 0x38D43a6Cb8DA0E855A42fB6b0733A0498531d774;
11
+
12
+ // solhint-disable immutable-vars-naming
13
+ address public immutable stakeToken;
14
+
15
+ constructor(string memory _name, string memory _symbol, address _stakeToken) SYBase(_name, _symbol, _stakeToken) {
16
+ stakeToken = _stakeToken;
17
+ _safeApproveInf(_stakeToken, SWELL_STAKING);
18
+ }
19
+
20
+ /*///////////////////////////////////////////////////////////////
21
+ DEPOSIT/REDEEM USING BASE TOKENS
22
+ //////////////////////////////////////////////////////////////*/
23
+
24
+ function _deposit(
25
+ address tokenIn,
26
+ uint256 amountDeposited
27
+ ) internal virtual override returns (uint256 /*amountSharesOut*/) {
28
+ if (tokenIn != stakeToken) {
29
+ amountDeposited = _wrapToStakeToken(tokenIn, amountDeposited);
30
+ }
31
+ ISwellSimpleStakingERC20(SWELL_STAKING).deposit(stakeToken, amountDeposited, address(this));
32
+ return amountDeposited;
33
+ }
34
+
35
+ function _redeem(
36
+ address receiver,
37
+ address /*tokenOut*/,
38
+ uint256 amountSharesToRedeem
39
+ ) internal virtual override returns (uint256 /*amountTokenOut*/) {
40
+ ISwellSimpleStakingERC20(SWELL_STAKING).withdraw(stakeToken, amountSharesToRedeem, receiver);
41
+ return amountSharesToRedeem;
42
+ }
43
+
44
+ /*///////////////////////////////////////////////////////////////
45
+ EXCHANGE-RATE
46
+ //////////////////////////////////////////////////////////////*/
47
+ function exchangeRate() public view virtual override returns (uint256) {
48
+ return PMath.ONE;
49
+ }
50
+
51
+ /*///////////////////////////////////////////////////////////////
52
+ MISC FUNCTIONS FOR METADATA
53
+ //////////////////////////////////////////////////////////////*/
54
+
55
+ function _previewDeposit(address tokenIn, uint256 amountTokenToDeposit) internal view override returns (uint256) {
56
+ if (tokenIn == stakeToken) {
57
+ return amountTokenToDeposit;
58
+ }
59
+ return _previewToStakeToken(tokenIn, amountTokenToDeposit);
60
+ }
61
+
62
+ function _previewRedeem(
63
+ address /*tokenOut*/,
64
+ uint256 amountSharesToRedeem
65
+ ) internal pure override returns (uint256 /*amountTokenOut*/) {
66
+ return amountSharesToRedeem;
67
+ }
68
+
69
+ function getTokensIn() public view virtual override returns (address[] memory) {
70
+ return ArrayLib.create(stakeToken).merge(_getAdditionalTokens());
71
+ }
72
+
73
+ function getTokensOut() public view virtual override returns (address[] memory) {
74
+ return ArrayLib.create(stakeToken);
75
+ }
76
+
77
+ function isValidTokenIn(address token) public view virtual override returns (bool) {
78
+ return token == stakeToken || _canWrapToStakeToken(token);
79
+ }
80
+
81
+ function isValidTokenOut(address token) public view virtual override returns (bool) {
82
+ return token == stakeToken;
83
+ }
84
+
85
+ function assetInfo()
86
+ external
87
+ view
88
+ virtual
89
+ returns (AssetType assetType, address assetAddress, uint8 assetDecimals)
90
+ {
91
+ return (AssetType.TOKEN, stakeToken, IERC20Metadata(stakeToken).decimals());
92
+ }
93
+
94
+ /*///////////////////////////////////////////////////////////////
95
+ ADDITIONAL TOKEN IN FUNCTIONS
96
+ //////////////////////////////////////////////////////////////*/
97
+
98
+ function _getAdditionalTokens() internal view virtual returns (address[] memory) {}
99
+
100
+ function _previewToStakeToken(address, uint256) internal view virtual returns (uint256) {
101
+ assert(false);
102
+ }
103
+
104
+ function _wrapToStakeToken(address, uint256) internal virtual returns (uint256) {
105
+ assert(false);
106
+ }
107
+
108
+ function _canWrapToStakeToken(address) internal view virtual returns (bool) {
109
+ return false;
110
+ }
111
+ }
@@ -26,6 +26,26 @@ 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
+
29
49
  event MintSyFromToken(
30
50
  address indexed caller,
31
51
  address indexed tokenIn,
@@ -80,6 +100,42 @@ interface IPActionMiscV3 {
80
100
  uint256 netSyInterm
81
101
  );
82
102
 
103
+ event ExitPreExpToToken(
104
+ address indexed caller,
105
+ address indexed market,
106
+ address indexed token,
107
+ address receiver,
108
+ uint256 netLpIn,
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 netLpIn,
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
+
83
139
  function mintSyFromToken(
84
140
  address receiver,
85
141
  address SY,
@@ -143,7 +199,7 @@ interface IPActionMiscV3 {
143
199
  uint256 minTokenOut
144
200
  ) external payable returns (uint256 netTokenOut, uint256 netSyInterm);
145
201
 
146
- function exitMultiplePreExpiry(
202
+ function exitPreExpToToken(
147
203
  address receiver,
148
204
  address market,
149
205
  uint256 netPtIn,
@@ -151,35 +207,39 @@ interface IPActionMiscV3 {
151
207
  uint256 netLpIn,
152
208
  TokenOutput calldata output,
153
209
  LimitOrderData calldata limit
154
- )
155
- external
156
- returns (
157
- uint256 netTokenOut,
158
- uint256 netPtFromRemove,
159
- uint256 netSyFromRemove,
160
- uint256 netPyRedeem,
161
- uint256 netSyFromRedeem,
162
- uint256 netPtSwap,
163
- uint256 netYtSwap,
164
- uint256 netSyFromSwap,
165
- uint256 netSyFee
166
- );
167
-
168
- function exitMultiplePostExpiry(
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(
169
223
  address receiver,
170
224
  address market,
171
225
  uint256 netPtIn,
172
226
  uint256 netLpIn,
173
227
  TokenOutput calldata output
174
- )
175
- external
176
- returns (
177
- uint256 netTokenOut,
178
- uint256 netPtFromRemove,
179
- uint256 netSyFromRemove,
180
- uint256 netPtRedeem,
181
- uint256 netSyFromRedeem
182
- );
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
+ function multicallAlpha(
239
+ address payable reflector,
240
+ bytes calldata selfCall,
241
+ bytes calldata reflectCall
242
+ ) external payable returns (bytes memory selfRes, bytes memory reflectRes);
183
243
 
184
244
  function boostMarkets(address[] memory markets) external;
185
245
 
@@ -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
+ }
@@ -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) {