@pendle/core-v2 2.22.0 → 2.22.1

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 (70) hide show
  1. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ankr/PendleAnkrBNBSY.sol/PendleAnkrBNBSY.dbg.json +4 -0
  2. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ankr/PendleAnkrBNBSY.sol/PendleAnkrBNBSY.json +1027 -0
  3. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWstethAnkreth.sol/PendleAuraWstethAnkreth.dbg.json +4 -0
  4. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWstethAnkreth.sol/PendleAuraWstethAnkreth.json +1171 -0
  5. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwETH.sol/SwETHSY.dbg.json +4 -0
  6. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwETH.sol/SwETHSY.json +961 -0
  7. package/build/artifacts/contracts/interfaces/Ankr/IAnkrBNB.sol/IAnkrBNB.dbg.json +4 -0
  8. package/build/artifacts/contracts/interfaces/Ankr/IAnkrBNB.sol/IAnkrBNB.json +62 -0
  9. package/build/artifacts/contracts/interfaces/Ankr/IAnkrLiquidStaking.sol/IAnkrLiquidStaking.dbg.json +4 -0
  10. package/build/artifacts/contracts/interfaces/Ankr/IAnkrLiquidStaking.sol/IAnkrLiquidStaking.json +108 -0
  11. package/build/artifacts/contracts/interfaces/ISwETH.sol/ISwETH.dbg.json +4 -0
  12. package/build/artifacts/contracts/interfaces/ISwETH.sol/ISwETH.json +44 -0
  13. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
  14. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.json +2 -2
  15. package/build/artifacts/contracts/oracles/PendlePtOracle.sol/PendlePtOracle.dbg.json +1 -1
  16. package/build/artifacts/contracts/oracles/PendlePtOracle.sol/PendlePtOracle.json +2 -2
  17. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +1 -1
  18. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.json +2 -2
  19. package/build/artifacts/contracts/oracles/samples/PendleLpGlpOracle.sol/PendleLpGlpOracle.dbg.json +1 -1
  20. package/build/artifacts/contracts/oracles/samples/PendleLpGlpOracle.sol/PendleLpGlpOracle.json +2 -2
  21. package/build/artifacts/contracts/oracles/samples/PendlePtGlpOracle.sol/PendlePtGlpOracle.dbg.json +1 -1
  22. package/build/artifacts/contracts/oracles/samples/PendlePtGlpOracle.sol/PendlePtGlpOracle.json +2 -2
  23. package/build/artifacts/contracts/router/swap-aggregator/1inch/I1inchAggregationRouterV5.sol/I1inchAggregationRouterV5.dbg.json +4 -0
  24. package/build/artifacts/contracts/router/swap-aggregator/1inch/I1inchAggregationRouterV5.sol/I1inchAggregationRouterV5.json +160 -0
  25. package/build/artifacts/contracts/router/swap-aggregator/1inch/OneInchAggregationRouterHelper.sol/OneInchAggregationRouterHelper.dbg.json +4 -0
  26. package/build/artifacts/contracts/router/swap-aggregator/1inch/OneInchAggregationRouterHelper.sol/OneInchAggregationRouterHelper.json +10 -0
  27. package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/PendleSwap.dbg.json +1 -1
  28. package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/PendleSwap.json +18 -2
  29. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IExecutorHelper.sol/IExecutorHelper.dbg.json +1 -1
  30. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IExecutorHelper.sol/IExecutorHelper.json +76 -118
  31. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/KyberInputScalingHelper.sol/KyberInputScalingHelper.dbg.json +1 -1
  32. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ScalingDataLib.sol/ScalingDataLib.dbg.json +1 -1
  33. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/ScalingDataLib.sol/ScalingDataLib.json +2 -2
  34. package/contracts/core/StandardizedYield/implementations/Swell/PendleSwETH.sol +1 -9
  35. package/contracts/oracles/PendleLpOracleLib.sol +21 -40
  36. package/contracts/oracles/PendlePtOracleLib.sol +33 -28
  37. package/contracts/router/swap-aggregator/kyberswap/IExecutorHelper.sol +110 -118
  38. package/contracts/router/swap-aggregator/kyberswap/KyberInputScalingHelper.sol +22 -21
  39. package/contracts/router/swap-aggregator/kyberswap/ScalingDataLib.sol +22 -2
  40. package/deployments/1-core.json +4 -3
  41. package/deployments/1-markets/SWETH-DEC2024.json +12 -0
  42. package/deployments/42161-core.json +4 -3
  43. package/deployments/42161-markets/WSTETH-ARBITRUM-DEC2023.json +10 -0
  44. package/deployments/56-core.json +2 -2
  45. package/package.json +1 -1
  46. package/typechain-types/IAnkrBNB.ts +150 -0
  47. package/typechain-types/IAnkrLiquidStaking.ts +253 -0
  48. package/typechain-types/IExecutorHelper.ts +310 -331
  49. package/typechain-types/ISwETH.ts +123 -0
  50. package/typechain-types/PendleAnkrBNBSY.ts +1235 -0
  51. package/typechain-types/PendleAuraWstethAnkreth.ts +1511 -0
  52. package/typechain-types/SwETHSY.ts +1216 -0
  53. package/typechain-types/factories/IAnkrBNB__factory.ts +74 -0
  54. package/typechain-types/factories/IAnkrLiquidStaking__factory.ts +123 -0
  55. package/typechain-types/factories/IExecutorHelper__factory.ts +74 -116
  56. package/typechain-types/factories/ISwETH__factory.ts +53 -0
  57. package/typechain-types/factories/PendleAnkrBNBSY__factory.ts +1100 -0
  58. package/typechain-types/factories/PendleAuraWstethAnkreth__factory.ts +1244 -0
  59. package/typechain-types/factories/PendleLpGlpOracle__factory.ts +1 -1
  60. package/typechain-types/factories/PendlePtGlpOracle__factory.ts +1 -1
  61. package/typechain-types/factories/PendlePtOracle__factory.ts +1 -1
  62. package/typechain-types/factories/PendleSwap__factory.ts +17 -1
  63. package/typechain-types/factories/SwETHSY__factory.ts +1022 -0
  64. package/typechain-types/hardhat.d.ts +63 -0
  65. package/typechain-types/index.ts +14 -0
  66. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IHashflow.sol/IHashflow.dbg.json +0 -4
  67. package/build/artifacts/contracts/router/swap-aggregator/kyberswap/IHashflow.sol/IHashflow.json +0 -101
  68. package/contracts/router/swap-aggregator/kyberswap/IHashflow.sol +0 -30
  69. /package/deployments/1-markets/{APE-JUNE-29.json → deprecated/APE-JUNE-29.json} +0 -0
  70. /package/deployments/1-markets/{STETH-JUNE29.json → deprecated/STETH-JUNE29.json} +0 -0
@@ -5,11 +5,6 @@
5
5
  "abi": [
6
6
  {
7
7
  "inputs": [
8
- {
9
- "internalType": "uint256",
10
- "name": "index",
11
- "type": "uint256"
12
- },
13
8
  {
14
9
  "internalType": "bytes",
15
10
  "name": "data",
@@ -17,11 +12,11 @@
17
12
  },
18
13
  {
19
14
  "internalType": "uint256",
20
- "name": "previousAmountOut",
15
+ "name": "flagsAndPrevAmountOut",
21
16
  "type": "uint256"
22
17
  }
23
18
  ],
24
- "name": "executeBalV2Swap",
19
+ "name": "executeBalV2",
25
20
  "outputs": [
26
21
  {
27
22
  "internalType": "uint256",
@@ -34,11 +29,6 @@
34
29
  },
35
30
  {
36
31
  "inputs": [
37
- {
38
- "internalType": "uint256",
39
- "name": "index",
40
- "type": "uint256"
41
- },
42
32
  {
43
33
  "internalType": "bytes",
44
34
  "name": "data",
@@ -46,11 +36,11 @@
46
36
  },
47
37
  {
48
38
  "internalType": "uint256",
49
- "name": "previousAmountOut",
39
+ "name": "flagsAndPrevAmountOut",
50
40
  "type": "uint256"
51
41
  }
52
42
  ],
53
- "name": "executeCamelotSwap",
43
+ "name": "executeCamelot",
54
44
  "outputs": [
55
45
  {
56
46
  "internalType": "uint256",
@@ -63,11 +53,6 @@
63
53
  },
64
54
  {
65
55
  "inputs": [
66
- {
67
- "internalType": "uint256",
68
- "name": "index",
69
- "type": "uint256"
70
- },
71
56
  {
72
57
  "internalType": "bytes",
73
58
  "name": "data",
@@ -75,11 +60,11 @@
75
60
  },
76
61
  {
77
62
  "internalType": "uint256",
78
- "name": "previousAmountOut",
63
+ "name": "flagsAndPrevAmountOut",
79
64
  "type": "uint256"
80
65
  }
81
66
  ],
82
- "name": "executeCurveSwap",
67
+ "name": "executeCurve",
83
68
  "outputs": [
84
69
  {
85
70
  "internalType": "uint256",
@@ -92,11 +77,6 @@
92
77
  },
93
78
  {
94
79
  "inputs": [
95
- {
96
- "internalType": "uint256",
97
- "name": "index",
98
- "type": "uint256"
99
- },
100
80
  {
101
81
  "internalType": "bytes",
102
82
  "name": "data",
@@ -104,11 +84,11 @@
104
84
  },
105
85
  {
106
86
  "internalType": "uint256",
107
- "name": "previousAmountOut",
87
+ "name": "flagsAndPrevAmountOut",
108
88
  "type": "uint256"
109
89
  }
110
90
  ],
111
- "name": "executeDODOSwap",
91
+ "name": "executeDODO",
112
92
  "outputs": [
113
93
  {
114
94
  "internalType": "uint256",
@@ -121,11 +101,6 @@
121
101
  },
122
102
  {
123
103
  "inputs": [
124
- {
125
- "internalType": "uint256",
126
- "name": "index",
127
- "type": "uint256"
128
- },
129
104
  {
130
105
  "internalType": "bytes",
131
106
  "name": "data",
@@ -133,11 +108,11 @@
133
108
  },
134
109
  {
135
110
  "internalType": "uint256",
136
- "name": "previousAmountOut",
111
+ "name": "flagsAndPrevAmountOut",
137
112
  "type": "uint256"
138
113
  }
139
114
  ],
140
- "name": "executeFraxSwap",
115
+ "name": "executeFrax",
141
116
  "outputs": [
142
117
  {
143
118
  "internalType": "uint256",
@@ -150,11 +125,6 @@
150
125
  },
151
126
  {
152
127
  "inputs": [
153
- {
154
- "internalType": "uint256",
155
- "name": "index",
156
- "type": "uint256"
157
- },
158
128
  {
159
129
  "internalType": "bytes",
160
130
  "name": "data",
@@ -162,11 +132,11 @@
162
132
  },
163
133
  {
164
134
  "internalType": "uint256",
165
- "name": "previousAmountOut",
135
+ "name": "flagsAndPrevAmountOut",
166
136
  "type": "uint256"
167
137
  }
168
138
  ],
169
- "name": "executeGMXSwap",
139
+ "name": "executeGMX",
170
140
  "outputs": [
171
141
  {
172
142
  "internalType": "uint256",
@@ -179,11 +149,6 @@
179
149
  },
180
150
  {
181
151
  "inputs": [
182
- {
183
- "internalType": "uint256",
184
- "name": "index",
185
- "type": "uint256"
186
- },
187
152
  {
188
153
  "internalType": "bytes",
189
154
  "name": "data",
@@ -191,11 +156,11 @@
191
156
  },
192
157
  {
193
158
  "internalType": "uint256",
194
- "name": "previousAmountOut",
159
+ "name": "flagsAndPrevAmountOut",
195
160
  "type": "uint256"
196
161
  }
197
162
  ],
198
- "name": "executeHashflowSwap",
163
+ "name": "executeHashflow",
199
164
  "outputs": [
200
165
  {
201
166
  "internalType": "uint256",
@@ -208,11 +173,6 @@
208
173
  },
209
174
  {
210
175
  "inputs": [
211
- {
212
- "internalType": "uint256",
213
- "name": "index",
214
- "type": "uint256"
215
- },
216
176
  {
217
177
  "internalType": "bytes",
218
178
  "name": "data",
@@ -220,11 +180,11 @@
220
180
  },
221
181
  {
222
182
  "internalType": "uint256",
223
- "name": "previousAmountOut",
183
+ "name": "flagsAndPrevAmountOut",
224
184
  "type": "uint256"
225
185
  }
226
186
  ],
227
- "name": "executeKyberDMMSwap",
187
+ "name": "executeKSClassic",
228
188
  "outputs": [
229
189
  {
230
190
  "internalType": "uint256",
@@ -237,11 +197,6 @@
237
197
  },
238
198
  {
239
199
  "inputs": [
240
- {
241
- "internalType": "uint256",
242
- "name": "index",
243
- "type": "uint256"
244
- },
245
200
  {
246
201
  "internalType": "bytes",
247
202
  "name": "data",
@@ -249,7 +204,7 @@
249
204
  },
250
205
  {
251
206
  "internalType": "uint256",
252
- "name": "previousAmountOut",
207
+ "name": "flagsAndPrevAmountOut",
253
208
  "type": "uint256"
254
209
  }
255
210
  ],
@@ -266,11 +221,6 @@
266
221
  },
267
222
  {
268
223
  "inputs": [
269
- {
270
- "internalType": "uint256",
271
- "name": "index",
272
- "type": "uint256"
273
- },
274
224
  {
275
225
  "internalType": "bytes",
276
226
  "name": "data",
@@ -278,11 +228,11 @@
278
228
  },
279
229
  {
280
230
  "internalType": "uint256",
281
- "name": "previousAmountOut",
231
+ "name": "flagsAndPrevAmountOut",
282
232
  "type": "uint256"
283
233
  }
284
234
  ],
285
- "name": "executePSMSwap",
235
+ "name": "executeMaverick",
286
236
  "outputs": [
287
237
  {
288
238
  "internalType": "uint256",
@@ -295,11 +245,6 @@
295
245
  },
296
246
  {
297
247
  "inputs": [
298
- {
299
- "internalType": "uint256",
300
- "name": "index",
301
- "type": "uint256"
302
- },
303
248
  {
304
249
  "internalType": "bytes",
305
250
  "name": "data",
@@ -307,11 +252,11 @@
307
252
  },
308
253
  {
309
254
  "internalType": "uint256",
310
- "name": "previousAmountOut",
255
+ "name": "flagsAndPrevAmountOut",
311
256
  "type": "uint256"
312
257
  }
313
258
  ],
314
- "name": "executePlatypusSwap",
259
+ "name": "executePSM",
315
260
  "outputs": [
316
261
  {
317
262
  "internalType": "uint256",
@@ -324,11 +269,30 @@
324
269
  },
325
270
  {
326
271
  "inputs": [
272
+ {
273
+ "internalType": "bytes",
274
+ "name": "data",
275
+ "type": "bytes"
276
+ },
327
277
  {
328
278
  "internalType": "uint256",
329
- "name": "index",
279
+ "name": "flagsAndPrevAmountOut",
330
280
  "type": "uint256"
331
- },
281
+ }
282
+ ],
283
+ "name": "executePlatypus",
284
+ "outputs": [
285
+ {
286
+ "internalType": "uint256",
287
+ "name": "",
288
+ "type": "uint256"
289
+ }
290
+ ],
291
+ "stateMutability": "payable",
292
+ "type": "function"
293
+ },
294
+ {
295
+ "inputs": [
332
296
  {
333
297
  "internalType": "bytes",
334
298
  "name": "data",
@@ -336,11 +300,11 @@
336
300
  },
337
301
  {
338
302
  "internalType": "uint256",
339
- "name": "previousAmountOut",
303
+ "name": "flagsAndPrevAmountOut",
340
304
  "type": "uint256"
341
305
  }
342
306
  ],
343
- "name": "executeRfqSwap",
307
+ "name": "executeRfq",
344
308
  "outputs": [
345
309
  {
346
310
  "internalType": "uint256",
@@ -353,11 +317,30 @@
353
317
  },
354
318
  {
355
319
  "inputs": [
320
+ {
321
+ "internalType": "bytes",
322
+ "name": "data",
323
+ "type": "bytes"
324
+ },
356
325
  {
357
326
  "internalType": "uint256",
358
- "name": "index",
327
+ "name": "flagsAndPrevAmountOut",
359
328
  "type": "uint256"
360
- },
329
+ }
330
+ ],
331
+ "name": "executeStEth",
332
+ "outputs": [
333
+ {
334
+ "internalType": "uint256",
335
+ "name": "",
336
+ "type": "uint256"
337
+ }
338
+ ],
339
+ "stateMutability": "payable",
340
+ "type": "function"
341
+ },
342
+ {
343
+ "inputs": [
361
344
  {
362
345
  "internalType": "bytes",
363
346
  "name": "data",
@@ -365,7 +348,7 @@
365
348
  },
366
349
  {
367
350
  "internalType": "uint256",
368
- "name": "previousAmountOut",
351
+ "name": "flagsAndPrevAmountOut",
369
352
  "type": "uint256"
370
353
  }
371
354
  ],
@@ -382,11 +365,6 @@
382
365
  },
383
366
  {
384
367
  "inputs": [
385
- {
386
- "internalType": "uint256",
387
- "name": "index",
388
- "type": "uint256"
389
- },
390
368
  {
391
369
  "internalType": "bytes",
392
370
  "name": "data",
@@ -394,11 +372,11 @@
394
372
  },
395
373
  {
396
374
  "internalType": "uint256",
397
- "name": "previousAmountOut",
375
+ "name": "flagsAndPrevAmountOut",
398
376
  "type": "uint256"
399
377
  }
400
378
  ],
401
- "name": "executeSynthetixSwap",
379
+ "name": "executeSynthetix",
402
380
  "outputs": [
403
381
  {
404
382
  "internalType": "uint256",
@@ -411,11 +389,6 @@
411
389
  },
412
390
  {
413
391
  "inputs": [
414
- {
415
- "internalType": "uint256",
416
- "name": "index",
417
- "type": "uint256"
418
- },
419
392
  {
420
393
  "internalType": "bytes",
421
394
  "name": "data",
@@ -423,11 +396,11 @@
423
396
  },
424
397
  {
425
398
  "internalType": "uint256",
426
- "name": "previousAmountOut",
399
+ "name": "flagsAndPrevAmountOut",
427
400
  "type": "uint256"
428
401
  }
429
402
  ],
430
- "name": "executeUniSwap",
403
+ "name": "executeUniV3KSElastic",
431
404
  "outputs": [
432
405
  {
433
406
  "internalType": "uint256",
@@ -440,11 +413,6 @@
440
413
  },
441
414
  {
442
415
  "inputs": [
443
- {
444
- "internalType": "uint256",
445
- "name": "index",
446
- "type": "uint256"
447
- },
448
416
  {
449
417
  "internalType": "bytes",
450
418
  "name": "data",
@@ -452,11 +420,11 @@
452
420
  },
453
421
  {
454
422
  "internalType": "uint256",
455
- "name": "previousAmountOut",
423
+ "name": "flagsAndPrevAmountOut",
456
424
  "type": "uint256"
457
425
  }
458
426
  ],
459
- "name": "executeUniV3ProMMSwap",
427
+ "name": "executeUniswap",
460
428
  "outputs": [
461
429
  {
462
430
  "internalType": "uint256",
@@ -469,11 +437,6 @@
469
437
  },
470
438
  {
471
439
  "inputs": [
472
- {
473
- "internalType": "uint256",
474
- "name": "index",
475
- "type": "uint256"
476
- },
477
440
  {
478
441
  "internalType": "bytes",
479
442
  "name": "data",
@@ -481,11 +444,11 @@
481
444
  },
482
445
  {
483
446
  "internalType": "uint256",
484
- "name": "previousAmountOut",
447
+ "name": "flagsAndPrevAmountOut",
485
448
  "type": "uint256"
486
449
  }
487
450
  ],
488
- "name": "executeVelodromeSwap",
451
+ "name": "executeVelodrome",
489
452
  "outputs": [
490
453
  {
491
454
  "internalType": "uint256",
@@ -498,11 +461,6 @@
498
461
  },
499
462
  {
500
463
  "inputs": [
501
- {
502
- "internalType": "uint256",
503
- "name": "index",
504
- "type": "uint256"
505
- },
506
464
  {
507
465
  "internalType": "bytes",
508
466
  "name": "data",
@@ -510,11 +468,11 @@
510
468
  },
511
469
  {
512
470
  "internalType": "uint256",
513
- "name": "previousAmountOut",
471
+ "name": "flagsAndPrevAmountOut",
514
472
  "type": "uint256"
515
473
  }
516
474
  ],
517
- "name": "executeWrappedstETHSwap",
475
+ "name": "executeWrappedstETH",
518
476
  "outputs": [
519
477
  {
520
478
  "internalType": "uint256",
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/594ca8730c6d9878319615f9b9938cd2.json"
3
+ "buildInfo": "../../../../../build-info/dcbed5fed64e93b93634433a5cec9a09.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/594ca8730c6d9878319615f9b9938cd2.json"
3
+ "buildInfo": "../../../../../build-info/dcbed5fed64e93b93634433a5cec9a09.json"
4
4
  }
@@ -3,8 +3,8 @@
3
3
  "contractName": "ScalingDataLib",
4
4
  "sourceName": "contracts/router/swap-aggregator/kyberswap/ScalingDataLib.sol",
5
5
  "abi": [],
6
- "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220cfba1793d0bf2005e9ec0047b2572c3062305c74344dcf37d39ad9fc7600e96b64736f6c63430008110033",
7
- "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220cfba1793d0bf2005e9ec0047b2572c3062305c74344dcf37d39ad9fc7600e96b64736f6c63430008110033",
6
+ "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203f5b8e7755d6600a60d4536d4ab8981573bb3aa21de1e490fe4057922f61db1264736f6c63430008110033",
7
+ "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203f5b8e7755d6600a60d4536d4ab8981573bb3aa21de1e490fe4057922f61db1264736f6c63430008110033",
8
8
  "linkReferences": {},
9
9
  "deployedLinkReferences": {}
10
10
  }
@@ -3,7 +3,7 @@ pragma solidity 0.8.17;
3
3
  import "../../SYBase.sol";
4
4
  import "../../../../interfaces/ISwETH.sol";
5
5
 
6
- contract PendleSwETH is SYBase {
6
+ contract SwETHSY is SYBase {
7
7
  using Math for uint256;
8
8
 
9
9
  address public immutable swETH;
@@ -34,10 +34,6 @@ contract PendleSwETH is SYBase {
34
34
  }
35
35
  }
36
36
 
37
- /**
38
- * Withdrawal to sfrxETH and frxETH is done normally as other ERC4626.
39
- * Withdrawal to ETH is on the other hand not possible
40
- */
41
37
  function _redeem(
42
38
  address receiver,
43
39
  address /*tokenOut*/,
@@ -51,10 +47,6 @@ contract PendleSwETH is SYBase {
51
47
  EXCHANGE-RATE
52
48
  //////////////////////////////////////////////////////////////*/
53
49
 
54
- /**
55
- * @notice Calculates and updates the exchange rate of shares to underlying asset token
56
- * @dev It is the exchange rate of sfrxETH to frxETH
57
- */
58
50
  function exchangeRate() public view virtual override returns (uint256) {
59
51
  return ISwETH(swETH).getRate();
60
52
  }
@@ -3,34 +3,42 @@ pragma solidity 0.8.17;
3
3
 
4
4
  import "./PendlePtOracleLib.sol";
5
5
 
6
- // Reference: https://file.notion.so/f/s/15d1406b-0d81-41a4-8ac3-9b56e30fdf50/LP_Oracle_Doc.pdf?id=201fc56f-959b-4836-9511-73852e166816&table=block&spaceId=33abd05a-56a2-4ce6-8673-929c5984a0fd&expirationTimestamp=1683863581610&signature=IY3jlxvXkWRJZhsccYpQdQaKlm1_NUIb1ypDmuaR7hI&downloadName=LP_Oracle_Doc.pdf
7
-
8
6
  library PendleLpOracleLib {
9
7
  using PendlePtOracleLib for IPMarket;
10
- using PYIndexLib for PYIndex;
11
8
  using Math for uint256;
12
9
  using Math for int256;
13
10
  using MarketMathCore for MarketState;
14
11
 
15
12
  /**
16
- * This function returns the approximated twap rate LP/Asset on market
13
+ * This function returns the approximated twap rate LP/asset on market, but take into account the current rate of SY
14
+ This is to account for special cases where underlying asset becomes insolvent and has decreasing exchangeRate
17
15
  * @param market market to get rate from
18
16
  * @param duration twap duration
19
- *
20
17
  */
21
- function getLpToAssetRate(
18
+ function getLpToAssetRate(IPMarket market, uint32 duration) internal view returns (uint256) {
19
+ (uint256 syIndex, uint256 pyIndex) = PendlePtOracleLib.getSYandPYIndexCurrent(market);
20
+ uint256 lpToAssetRateRaw = _getLpToAssetRateRaw(market, duration, pyIndex);
21
+ return (lpToAssetRateRaw * syIndex) / pyIndex;
22
+ }
23
+
24
+ function _getLpToAssetRateRaw(
22
25
  IPMarket market,
23
- uint32 duration
24
- ) internal view returns (uint256 lpToAssetRate) {
26
+ uint32 duration,
27
+ uint256 pyIndex
28
+ ) private view returns (uint256 lpToAssetRateRaw) {
25
29
  MarketState memory state = market.readState(address(0));
26
- MarketPreCompute memory comp = _getMarketPreCompute(market, state);
30
+
31
+ MarketPreCompute memory comp = state.getMarketPreCompute(
32
+ PYIndex.wrap(pyIndex),
33
+ block.timestamp
34
+ );
27
35
 
28
36
  int256 totalHypotheticalAsset;
29
37
  if (state.expiry <= block.timestamp) {
30
38
  // 1 PT = 1 Asset post-expiry
31
39
  totalHypotheticalAsset = state.totalPt + comp.totalAsset;
32
40
  } else {
33
- (int256 rateOracle, int256 rateHypTrade) = _getPtRates(market, state, duration);
41
+ (int256 rateOracle, int256 rateHypTrade) = _getPtRatesRaw(market, state, duration);
34
42
  int256 cParam = LogExpMath.exp(
35
43
  comp.rateScalar.mulDown((rateOracle - comp.rateAnchor))
36
44
  );
@@ -45,46 +53,19 @@ library PendleLpOracleLib {
45
53
  (state.totalPt + tradeSize).divDown(rateOracle);
46
54
  }
47
55
 
48
- lpToAssetRate = _calcLpPrice(totalHypotheticalAsset, state.totalLp).Uint();
56
+ lpToAssetRateRaw = totalHypotheticalAsset.divDown(state.totalLp).Uint();
49
57
  }
50
58
 
51
- function _getMarketPreCompute(
52
- IPMarket market,
53
- MarketState memory state
54
- ) private view returns (MarketPreCompute memory) {
55
- return state.getMarketPreCompute(_getPYIndexCurrent(market), block.timestamp);
56
- }
57
-
58
- function _getPYIndexCurrent(IPMarket market) private view returns (PYIndex) {
59
- (IStandardizedYield SY, , IPYieldToken YT) = market.readTokens();
60
- uint256 ytIndex = YT.pyIndexStored();
61
- uint256 pyIndexCurrent;
62
- if (YT.doCacheIndexSameBlock() && YT.pyIndexLastUpdatedBlock() == block.number) {
63
- pyIndexCurrent = ytIndex;
64
- } else {
65
- uint256 syIndex = SY.exchangeRate();
66
- pyIndexCurrent = Math.max(syIndex, ytIndex);
67
- }
68
- return PYIndex.wrap(pyIndexCurrent);
69
- }
70
-
71
- function _getPtRates(
59
+ function _getPtRatesRaw(
72
60
  IPMarket market,
73
61
  MarketState memory state,
74
62
  uint32 duration
75
63
  ) private view returns (int256 rateOracle, int256 rateHypTrade) {
76
- rateOracle = Math.IONE.divDown(market.getPtToAssetRate(duration).Int());
64
+ rateOracle = Math.IONE.divDown(market.getPtToAssetRateRaw(duration).Int());
77
65
  int256 rateLastTrade = MarketMathCore._getExchangeRateFromImpliedRate(
78
66
  state.lastLnImpliedRate,
79
67
  state.expiry - block.timestamp
80
68
  );
81
69
  rateHypTrade = (rateLastTrade + rateOracle) / 2;
82
70
  }
83
-
84
- function _calcLpPrice(
85
- int256 totalHypotheticalAsset,
86
- int256 totalLp
87
- ) private pure returns (int256) {
88
- return totalHypotheticalAsset.divDown(totalLp);
89
- }
90
71
  }