@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.
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol/PendleERC20WithSupplyCapSY.dbg.json +1 -1
- package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol/PendleERC20WithSupplyCapSY.json +2 -2
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol/PendleSwellRswETHStakingSY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol/PendleSwellRswETHStakingSY.json +1049 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol/PendleSwellStakingERC20SY.dbg.json +4 -0
- package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol/PendleSwellStakingERC20SY.json +1039 -0
- package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.json +805 -80
- package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.json +958 -233
- package/build/artifacts/contracts/interfaces/IPGovernanceProxy.sol/IPGovernanceProxy.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPGovernanceProxy.sol/IPGovernanceProxy.json +60 -0
- package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.json +25 -0
- package/build/artifacts/contracts/interfaces/IPPtLpOracle.sol/IPPtLpOracle.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.dbg.json +4 -0
- package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.json +207 -0
- package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.dbg.json +4 -0
- package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.json +401 -0
- package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.json +2 -2
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.json +2 -2
- package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/PendlePtLpOracle.sol/PendlePtLpOracle.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/samples/BoringLpGlpOracle.sol/BoringLpGlpOracle.dbg.json +1 -1
- package/build/artifacts/contracts/oracles/samples/BoringPtUsdChainlinkOracle.sol/BoringPtUsdChainlinkOracle.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.json +2 -2
- package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.json +707 -140
- package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.json +2 -2
- package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.json +2 -2
- package/build/artifacts/contracts/router/Reflector.sol/Reflector.dbg.json +4 -0
- package/build/artifacts/contracts/router/Reflector.sol/Reflector.json +39 -0
- package/build/artifacts/contracts/router/base/ActionBase.sol/ActionBase.dbg.json +1 -1
- package/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol +6 -1
- package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol +56 -0
- package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol +111 -0
- package/contracts/interfaces/IPActionMiscV3.sol +85 -25
- package/contracts/interfaces/IPGovernanceProxy.sol +14 -0
- package/contracts/interfaces/IPPausingInterface.sol +8 -0
- package/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol +66 -0
- package/contracts/offchain-helpers/PendleGovernanceProxy.sol +84 -0
- package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +12 -4
- package/contracts/router/ActionMiscV3.sol +140 -167
- package/contracts/router/Reflector.sol +61 -0
- package/contracts/router/base/ActionBase.sol +0 -16
- package/deployments/1-markets/EZETH-MAINNET-SEP2024.json +11 -0
- package/deployments/1-markets/PUFETH-MAINNET-SEP2024.json +11 -0
- package/deployments/1-markets/RSETH-MAINNET-SEP2024.json +11 -0
- package/deployments/1-markets/RSWETH-SWELL-STAKING-MAINNET-JUL2024.json +11 -0
- package/deployments/1-markets/SUSDE-MAINNET-SEP2024.json +13 -0
- package/deployments/1-markets/UNIETH-MAINNET-SEP2024.json +13 -0
- package/deployments/1-markets/WEETH-MAINNET-SEP2024.json +11 -0
- package/deployments/42161-core.json +1 -1
- package/deployments/42161-markets/EZETH-ARB-SEP2024.json +11 -0
- package/deployments/42161-markets/RSETH-ARBITRUM-SEP2024.json +11 -0
- package/deployments/42161-markets/SILO-PTEETH-ARBITRUM-JUNE2024.json +11 -0
- package/deployments/42161-markets/SILO-PTEZETH-ARBITRUM-JUNE2024.json +11 -0
- package/deployments/42161-markets/WEETH-ARB-SEP2024.json +11 -0
- package/deployments/56-markets/WEETH-BSC-SEP2024.json +11 -0
- package/package.json +2 -2
- package/typechain-types/ActionMiscV3.ts +358 -120
- package/typechain-types/BoringPYUsdChainlinkAssetOracle.ts +244 -0
- package/typechain-types/BoringPYUsdChainlinkSYOracle.ts +243 -0
- package/typechain-types/IPActionMiscV3.ts +408 -40
- package/typechain-types/IPAllActionV3.ts +408 -40
- package/typechain-types/IPGovernanceProxy.ts +142 -0
- package/typechain-types/IPPYLpOracle.ts +379 -0
- package/typechain-types/IPPausingInterface.ts +112 -0
- package/typechain-types/IPossibleSupplyCapInterface.ts +142 -0
- package/typechain-types/PendleGovernanceProxy.ts +603 -0
- package/typechain-types/PendlePYLpOracle.ts +612 -0
- package/typechain-types/Reflector.ts +98 -0
- package/typechain-types/SupplyCapReader.ts +105 -0
- package/typechain-types/factories/ActionAddRemoveLiqV3__factory.ts +1 -1
- package/typechain-types/factories/ActionMarketAuxStatic__factory.ts +1 -1
- package/typechain-types/factories/ActionMiscV3__factory.ts +705 -138
- package/typechain-types/factories/ActionSwapPTV3__factory.ts +1 -1
- package/typechain-types/factories/ActionSwapYTV3__factory.ts +1 -1
- package/typechain-types/factories/BoringPYUsdChainlinkAssetOracle__factory.ts +269 -0
- package/typechain-types/factories/BoringPYUsdChainlinkSYOracle__factory.ts +267 -0
- package/typechain-types/factories/IPActionMiscV3__factory.ts +805 -80
- package/typechain-types/factories/IPAllActionV3__factory.ts +958 -233
- package/typechain-types/factories/IPGovernanceProxy__factory.ts +75 -0
- package/typechain-types/factories/IPPYLpOracle__factory.ts +214 -0
- package/typechain-types/factories/IPPausingInterface__factory.ts +40 -0
- package/typechain-types/factories/IPossibleSupplyCapInterface__factory.ts +82 -0
- package/typechain-types/factories/PendleERC20WithSupplyCapSY__factory.ts +1 -1
- package/typechain-types/factories/PendleGovernanceProxy__factory.ts +458 -0
- package/typechain-types/factories/PendlePYLpOracle__factory.ts +487 -0
- package/typechain-types/factories/PendlePoolDeployHelper__factory.ts +1 -1
- package/typechain-types/factories/PendleSwellRswETHStakingSY__factory.ts +1 -1
- package/typechain-types/factories/Reflector__factory.ts +89 -0
- package/typechain-types/factories/SupplyCapReader__factory.ts +88 -0
- package/typechain-types/hardhat.d.ts +54 -0
- package/typechain-types/index.ts +12 -0
- /package/deployments/1-markets/{EZETH-JUNE2024.json → EZETH-APR2024.json} +0 -0
- /package/deployments/42161-markets/{RSETH-MAY2024.json → RSETH-JUNE2024.json} +0 -0
- /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
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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,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
|
|
120
|
-
|
|
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
|
|
130
|
+
return totalHypotheticalAsset.divDown(state.totalLp).Uint();
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
function getPtToAssetRate(address market) public view returns (uint256) {
|