@pendle/core-v2 4.5.1-beta-1 → 4.5.1-beta-2
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/interfaces/IPActionMiscV3.sol/IPActionMiscV3.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.json +771 -80
- package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.json +821 -130
- 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/router/ActionMiscV3.sol/ActionMiscV3.dbg.json +1 -1
- package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.json +662 -129
- package/contracts/interfaces/IPActionMiscV3.sol +79 -25
- package/contracts/router/ActionMiscV3.sol +99 -165
- package/package.json +1 -1
- package/typechain-types/ActionMiscV3.ts +309 -115
- package/typechain-types/IPActionMiscV3.ts +364 -40
- package/typechain-types/IPAllActionV3.ts +364 -40
- package/typechain-types/factories/ActionMiscV3__factory.ts +662 -129
- package/typechain-types/factories/IPActionMiscV3__factory.ts +771 -80
- package/typechain-types/factories/IPAllActionV3__factory.ts +821 -130
- package/typechain-types/factories/PendlePoolDeployHelper__factory.ts +1 -1
- package/typechain-types/hardhat.d.ts +0 -27
- package/typechain-types/index.ts +0 -6
|
@@ -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 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
|
+
|
|
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,33 @@ 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);
|
|
183
237
|
|
|
184
238
|
function boostMarkets(address[] memory markets) external;
|
|
185
239
|
|
|
@@ -116,206 +116,140 @@ contract ActionMiscV3 is IPActionMiscV3, ActionBase {
|
|
|
116
116
|
netTokenOut = IStandardizedYield(SY).redeem(receiver, netSyInterm, tokenRedeemSy, minTokenOut, true);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
uint256 netLpToRemove,
|
|
125
|
-
uint256 netPtFromRemove,
|
|
126
|
-
uint256 netSyFromRemove,
|
|
127
|
-
uint256 netPyRedeem,
|
|
128
|
-
uint256 netSyFromRedeem,
|
|
129
|
-
uint256 netPtSwap,
|
|
130
|
-
uint256 netYtSwap,
|
|
131
|
-
uint256 netSyFromSwap,
|
|
132
|
-
uint256 netSyFee,
|
|
133
|
-
uint256 netTokenOut
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
event ExitMultiplePostExpiry(
|
|
137
|
-
address indexed caller,
|
|
138
|
-
address indexed market,
|
|
139
|
-
address indexed token,
|
|
119
|
+
// TODO: need to allow exit to SY as well
|
|
120
|
+
// TODO: check against minOut
|
|
121
|
+
// double check event orders
|
|
122
|
+
|
|
123
|
+
function exitPreExpToToken(
|
|
140
124
|
address receiver,
|
|
141
|
-
|
|
142
|
-
uint256
|
|
143
|
-
uint256
|
|
144
|
-
uint256
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
)
|
|
125
|
+
address market,
|
|
126
|
+
uint256 netPtIn,
|
|
127
|
+
uint256 netYtIn,
|
|
128
|
+
uint256 netLpIn,
|
|
129
|
+
TokenOutput calldata output,
|
|
130
|
+
LimitOrderData calldata limit
|
|
131
|
+
) external returns (uint256 totalTokenOut, ExitPreExpReturnParams memory params) {
|
|
132
|
+
IStandardizedYield SY;
|
|
148
133
|
|
|
149
|
-
|
|
134
|
+
(SY, params) = _exitPreExpToSy(true, address(0), market, netPtIn, netYtIn, netLpIn, limit);
|
|
135
|
+
totalTokenOut = _redeemSyToToken(receiver, address(SY), params.totalSyOut, output, false);
|
|
150
136
|
|
|
151
|
-
|
|
152
|
-
address receiver;
|
|
153
|
-
address market;
|
|
154
|
-
uint256 netPtIn;
|
|
155
|
-
uint256 netYtIn;
|
|
156
|
-
uint256 netLpIn;
|
|
157
|
-
TokenOutput output;
|
|
158
|
-
LimitOrderData limit;
|
|
137
|
+
emit ExitPreExpToToken(msg.sender, market, output.tokenOut, receiver, netLpIn, totalTokenOut, params);
|
|
159
138
|
}
|
|
160
139
|
|
|
161
|
-
function
|
|
140
|
+
function exitPreExpToSy(
|
|
162
141
|
address receiver,
|
|
163
142
|
address market,
|
|
164
143
|
uint256 netPtIn,
|
|
165
144
|
uint256 netYtIn,
|
|
166
145
|
uint256 netLpIn,
|
|
167
|
-
|
|
146
|
+
uint256 minSyOut,
|
|
168
147
|
LimitOrderData calldata limit
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
uint256 netSyFromRemove,
|
|
175
|
-
uint256 netPyRedeem,
|
|
176
|
-
uint256 netSyFromRedeem,
|
|
177
|
-
uint256 netPtSwap,
|
|
178
|
-
uint256 netYtSwap,
|
|
179
|
-
uint256 netSyFromSwap,
|
|
180
|
-
uint256 netSyFee
|
|
181
|
-
)
|
|
182
|
-
{
|
|
183
|
-
(
|
|
184
|
-
netTokenOut,
|
|
185
|
-
netPtFromRemove,
|
|
186
|
-
netSyFromRemove,
|
|
187
|
-
netPyRedeem,
|
|
188
|
-
netSyFromRedeem,
|
|
189
|
-
netPtSwap,
|
|
190
|
-
netYtSwap,
|
|
191
|
-
netSyFromSwap,
|
|
192
|
-
netSyFee
|
|
193
|
-
) = exitMultiplePreExpiryInner(receiver, market, netPtIn, netYtIn, netLpIn, output, limit);
|
|
194
|
-
|
|
195
|
-
emit ExitMultiplePreExpiry(
|
|
196
|
-
msg.sender,
|
|
197
|
-
market,
|
|
198
|
-
output.tokenOut,
|
|
199
|
-
receiver,
|
|
200
|
-
netLpIn,
|
|
201
|
-
netPtFromRemove,
|
|
202
|
-
netSyFromRemove,
|
|
203
|
-
netPyRedeem,
|
|
204
|
-
netSyFromRedeem,
|
|
205
|
-
netPtSwap,
|
|
206
|
-
netYtSwap,
|
|
207
|
-
netSyFromSwap,
|
|
208
|
-
netSyFee,
|
|
209
|
-
netTokenOut
|
|
210
|
-
);
|
|
148
|
+
) external returns (ExitPreExpReturnParams memory params) {
|
|
149
|
+
(, params) = _exitPreExpToSy(false, receiver, market, netPtIn, netYtIn, netLpIn, limit);
|
|
150
|
+
require(params.totalSyOut >= minSyOut, "Slippage: INSUFFICIENT_SY_OUT");
|
|
151
|
+
|
|
152
|
+
emit ExitPreExpToSy(msg.sender, market, receiver, netLpIn, params);
|
|
211
153
|
}
|
|
212
154
|
|
|
213
|
-
function
|
|
155
|
+
function _exitPreExpToSy(
|
|
156
|
+
bool setReceiverToSy,
|
|
214
157
|
address receiver,
|
|
215
158
|
address market,
|
|
216
159
|
uint256 netPtIn,
|
|
217
160
|
uint256 netYtIn,
|
|
218
161
|
uint256 netLpIn,
|
|
219
|
-
TokenOutput calldata output,
|
|
220
162
|
LimitOrderData calldata limit
|
|
221
|
-
)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
// }
|
|
259
|
-
// uint256 netSyRedeem = netSyFromRemove + netSyFromRedeem + netSyFromSwap;
|
|
260
|
-
// netTokenOut = _redeemSyToToken(receiver, address(SY), netSyRedeem, output, false);
|
|
163
|
+
) internal returns (IStandardizedYield SY, ExitPreExpReturnParams memory p) {
|
|
164
|
+
IPPrincipalToken PT;
|
|
165
|
+
IPYieldToken YT;
|
|
166
|
+
(SY, PT, YT) = IPMarket(market).readTokens();
|
|
167
|
+
|
|
168
|
+
if (setReceiverToSy) receiver = address(SY);
|
|
169
|
+
|
|
170
|
+
if (netLpIn > 0) {
|
|
171
|
+
_transferFrom(IERC20(market), msg.sender, market, netLpIn);
|
|
172
|
+
(p.netSyFromRemove, p.netPtFromRemove) = IPMarket(market).burn(receiver, address(this), netLpIn);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (netPtIn > 0) {
|
|
176
|
+
_transferIn(address(PT), address(this), netPtIn);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
p.netPyRedeem = PMath.min(p.netPtFromRemove + netPtIn, netYtIn);
|
|
180
|
+
|
|
181
|
+
if (p.netPyRedeem > 0) {
|
|
182
|
+
_transferOut(address(PT), address(YT), p.netPyRedeem);
|
|
183
|
+
_transferFrom(YT, msg.sender, address(YT), p.netPyRedeem);
|
|
184
|
+
p.netSyFromRedeem = IPYieldToken(YT).redeemPY(receiver);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
p.netPtSwap = p.netPtFromRemove + netPtIn - p.netPyRedeem;
|
|
188
|
+
p.netYtSwap = netYtIn - p.netPyRedeem;
|
|
189
|
+
|
|
190
|
+
if (p.netPtSwap > 0) {
|
|
191
|
+
address ptEntry = _entry_swapExactPtForSy(market, limit);
|
|
192
|
+
if (ptEntry != address(this)) _transferOut(address(PT), ptEntry, p.netPtSwap);
|
|
193
|
+
(p.netSyFromSwap, p.netSyFee) = _swapExactPtForSy(receiver, market, p.netPtSwap, 0, limit);
|
|
194
|
+
} else if (p.netYtSwap > 0) {
|
|
195
|
+
_transferFrom(YT, msg.sender, _entry_swapExactYtForSy(YT, limit), p.netYtSwap);
|
|
196
|
+
(p.netSyFromSwap, p.netSyFee) = _swapExactYtForSy(receiver, market, SY, YT, p.netYtSwap, 0, limit);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
p.totalSyOut = p.netSyFromRemove + p.netSyFromRedeem + p.netSyFromSwap;
|
|
261
200
|
}
|
|
262
201
|
|
|
263
|
-
|
|
264
|
-
// TODO: compare interface against existing functions, to see if it makes sense
|
|
265
|
-
function exitMultiplePostExpiry(
|
|
202
|
+
function exitPostExpToToken(
|
|
266
203
|
address receiver,
|
|
267
204
|
address market,
|
|
268
205
|
uint256 netPtIn,
|
|
269
206
|
uint256 netLpIn,
|
|
270
207
|
TokenOutput calldata output
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
208
|
+
) external returns (uint256 totalTokenOut, ExitPostExpReturnParams memory params) {
|
|
209
|
+
IStandardizedYield SY;
|
|
210
|
+
|
|
211
|
+
(SY, params) = _exitPostExpToSy(receiver, market, netPtIn, netLpIn);
|
|
212
|
+
totalTokenOut = _redeemSyToToken(receiver, address(SY), params.totalSyOut, output, false);
|
|
213
|
+
|
|
214
|
+
emit ExitPostExpToToken(msg.sender, market, output.tokenOut, receiver, netLpIn, totalTokenOut, params);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function exitPostExpToSy(
|
|
218
|
+
address receiver,
|
|
219
|
+
address market,
|
|
220
|
+
uint256 netPtIn,
|
|
221
|
+
uint256 netLpIn,
|
|
222
|
+
uint256 minSyOut
|
|
223
|
+
) external returns (ExitPostExpReturnParams memory params) {
|
|
224
|
+
(, params) = _exitPostExpToSy(receiver, market, netPtIn, netLpIn);
|
|
225
|
+
require(params.totalSyOut >= minSyOut, "Slippage: INSUFFICIENT_SY_OUT");
|
|
226
|
+
|
|
227
|
+
emit ExitPostExpToSy(msg.sender, market, receiver, netLpIn, params);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function _exitPostExpToSy(
|
|
231
|
+
address receiver,
|
|
232
|
+
address market,
|
|
233
|
+
uint256 netPtIn,
|
|
234
|
+
uint256 netLpIn
|
|
235
|
+
) internal returns (IStandardizedYield SY, ExitPostExpReturnParams memory p) {
|
|
236
|
+
IPPrincipalToken PT;
|
|
237
|
+
IPYieldToken YT;
|
|
238
|
+
(SY, PT, YT) = IPMarket(market).readTokens();
|
|
291
239
|
|
|
292
240
|
if (netLpIn > 0) {
|
|
293
241
|
_transferFrom(IERC20(market), msg.sender, market, netLpIn);
|
|
294
|
-
(netSyFromRemove, netPtFromRemove) = IPMarket(market).burn(
|
|
242
|
+
(p.netSyFromRemove, p.netPtFromRemove) = IPMarket(market).burn(receiver, address(YT), netLpIn);
|
|
295
243
|
}
|
|
296
244
|
|
|
297
245
|
if (netPtIn > 0) {
|
|
298
246
|
_transferFrom(PT, msg.sender, address(YT), netPtIn);
|
|
299
247
|
}
|
|
300
248
|
|
|
301
|
-
netPtRedeem = netPtFromRemove + netPtIn;
|
|
302
|
-
netSyFromRedeem = IPYieldToken(YT).redeemPY(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
netTokenOut = _redeemSyToToken(receiver, address(SY), netSyRedeem, output, false);
|
|
306
|
-
|
|
307
|
-
emit ExitMultiplePostExpiry(
|
|
308
|
-
msg.sender,
|
|
309
|
-
market,
|
|
310
|
-
output.tokenOut,
|
|
311
|
-
receiver,
|
|
312
|
-
netLpIn,
|
|
313
|
-
netPtFromRemove,
|
|
314
|
-
netSyFromRemove,
|
|
315
|
-
netPtRedeem,
|
|
316
|
-
netSyFromRedeem,
|
|
317
|
-
netTokenOut
|
|
318
|
-
);
|
|
249
|
+
p.netPtRedeem = p.netPtFromRemove + netPtIn;
|
|
250
|
+
p.netSyFromRedeem = IPYieldToken(YT).redeemPY(receiver);
|
|
251
|
+
|
|
252
|
+
p.totalSyOut = p.netSyFromRemove + p.netSyFromRedeem;
|
|
319
253
|
}
|
|
320
254
|
|
|
321
255
|
// ----------------- MISC FUNCTIONS -----------------
|
package/package.json
CHANGED