@gearbox-protocol/sdk 14.12.0-next.31 → 14.12.0-next.33

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 (25) hide show
  1. package/dist/cjs/dev/withdrawalAbi.js +64 -70
  2. package/dist/cjs/dev/withdrawalUtils.js +1 -1
  3. package/dist/cjs/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.js +40 -280
  4. package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +45 -44
  5. package/dist/cjs/preview/preview/buildDelayedPreview.js +5 -1
  6. package/dist/cjs/preview/preview/detectCloseOrRepay.js +2 -2
  7. package/dist/cjs/preview/preview/previewCloseOrRepayCreditAccount.js +17 -2
  8. package/dist/cjs/rewards/rewards/extra-apy.js +8 -4
  9. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +2 -0
  10. package/dist/esm/dev/withdrawalAbi.js +64 -70
  11. package/dist/esm/dev/withdrawalUtils.js +1 -1
  12. package/dist/esm/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.js +40 -280
  13. package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +47 -45
  14. package/dist/esm/preview/preview/buildDelayedPreview.js +5 -1
  15. package/dist/esm/preview/preview/detectCloseOrRepay.js +2 -2
  16. package/dist/esm/preview/preview/previewCloseOrRepayCreditAccount.js +22 -3
  17. package/dist/esm/rewards/rewards/extra-apy.js +8 -4
  18. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -0
  19. package/dist/types/dev/withdrawalAbi.d.ts +53 -57
  20. package/dist/types/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.d.ts +33 -219
  21. package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +44 -232
  22. package/dist/types/preview/preview/detectCloseOrRepay.d.ts +5 -3
  23. package/dist/types/preview/preview/types.d.ts +6 -4
  24. package/dist/types/rewards/rewards/extra-apy.d.ts +3 -1
  25. package/package.json +1 -1
@@ -4,36 +4,6 @@ import type { DelayedWithdrawalRequest } from "../types.js";
4
4
  import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
5
5
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
6
6
  declare const abi: readonly [{
7
- readonly type: "function";
8
- readonly name: "allowedInputTokens";
9
- readonly inputs: readonly [];
10
- readonly outputs: readonly [{
11
- readonly name: "";
12
- readonly type: "address[]";
13
- readonly internalType: "address[]";
14
- }];
15
- readonly stateMutability: "view";
16
- }, {
17
- readonly type: "function";
18
- readonly name: "allowedOutputTokens";
19
- readonly inputs: readonly [];
20
- readonly outputs: readonly [{
21
- readonly name: "";
22
- readonly type: "address[]";
23
- readonly internalType: "address[]";
24
- }];
25
- readonly stateMutability: "view";
26
- }, {
27
- readonly type: "function";
28
- readonly name: "allowedPhantomTokens";
29
- readonly inputs: readonly [];
30
- readonly outputs: readonly [{
31
- readonly name: "";
32
- readonly type: "address[]";
33
- readonly internalType: "address[]";
34
- }];
35
- readonly stateMutability: "view";
36
- }, {
37
7
  readonly type: "function";
38
8
  readonly name: "contractType";
39
9
  readonly inputs: readonly [];
@@ -57,10 +27,6 @@ declare const abi: readonly [{
57
27
  readonly type: "function";
58
28
  readonly name: "depositInstant";
59
29
  readonly inputs: readonly [{
60
- readonly name: "tokenIn";
61
- readonly type: "address";
62
- readonly internalType: "address";
63
- }, {
64
30
  readonly name: "amountToken";
65
31
  readonly type: "uint256";
66
32
  readonly internalType: "uint256";
@@ -83,10 +49,6 @@ declare const abi: readonly [{
83
49
  readonly type: "function";
84
50
  readonly name: "depositInstantDiff";
85
51
  readonly inputs: readonly [{
86
- readonly name: "tokenIn";
87
- readonly type: "address";
88
- readonly internalType: "address";
89
- }, {
90
52
  readonly name: "leftoverAmount";
91
53
  readonly type: "uint256";
92
54
  readonly internalType: "uint256";
@@ -129,34 +91,6 @@ declare const abi: readonly [{
129
91
  readonly internalType: "address";
130
92
  }];
131
93
  readonly stateMutability: "view";
132
- }, {
133
- readonly type: "function";
134
- readonly name: "isInputTokenAllowed";
135
- readonly inputs: readonly [{
136
- readonly name: "token";
137
- readonly type: "address";
138
- readonly internalType: "address";
139
- }];
140
- readonly outputs: readonly [{
141
- readonly name: "";
142
- readonly type: "bool";
143
- readonly internalType: "bool";
144
- }];
145
- readonly stateMutability: "view";
146
- }, {
147
- readonly type: "function";
148
- readonly name: "isOutputTokenAllowed";
149
- readonly inputs: readonly [{
150
- readonly name: "token";
151
- readonly type: "address";
152
- readonly internalType: "address";
153
- }];
154
- readonly outputs: readonly [{
155
- readonly name: "";
156
- readonly type: "bool";
157
- readonly internalType: "bool";
158
- }];
159
- readonly stateMutability: "view";
160
94
  }, {
161
95
  readonly type: "function";
162
96
  readonly name: "mToken";
@@ -169,12 +103,8 @@ declare const abi: readonly [{
169
103
  readonly stateMutability: "view";
170
104
  }, {
171
105
  readonly type: "function";
172
- readonly name: "outputTokenToPhantomToken";
173
- readonly inputs: readonly [{
174
- readonly name: "outputToken";
175
- readonly type: "address";
176
- readonly internalType: "address";
177
- }];
106
+ readonly name: "phantomToken";
107
+ readonly inputs: readonly [];
178
108
  readonly outputs: readonly [{
179
109
  readonly name: "";
180
110
  readonly type: "address";
@@ -183,12 +113,8 @@ declare const abi: readonly [{
183
113
  readonly stateMutability: "view";
184
114
  }, {
185
115
  readonly type: "function";
186
- readonly name: "phantomTokenToOutputToken";
187
- readonly inputs: readonly [{
188
- readonly name: "phantomToken";
189
- readonly type: "address";
190
- readonly internalType: "address";
191
- }];
116
+ readonly name: "quoteToken";
117
+ readonly inputs: readonly [];
192
118
  readonly outputs: readonly [{
193
119
  readonly name: "";
194
120
  readonly type: "address";
@@ -199,10 +125,6 @@ declare const abi: readonly [{
199
125
  readonly type: "function";
200
126
  readonly name: "redeemInstant";
201
127
  readonly inputs: readonly [{
202
- readonly name: "tokenOut";
203
- readonly type: "address";
204
- readonly internalType: "address";
205
- }, {
206
128
  readonly name: "amountMTokenIn";
207
129
  readonly type: "uint256";
208
130
  readonly internalType: "uint256";
@@ -221,10 +143,6 @@ declare const abi: readonly [{
221
143
  readonly type: "function";
222
144
  readonly name: "redeemInstantDiff";
223
145
  readonly inputs: readonly [{
224
- readonly name: "tokenOut";
225
- readonly type: "address";
226
- readonly internalType: "address";
227
- }, {
228
146
  readonly name: "leftoverAmount";
229
147
  readonly type: "uint256";
230
148
  readonly internalType: "uint256";
@@ -243,17 +161,9 @@ declare const abi: readonly [{
243
161
  readonly type: "function";
244
162
  readonly name: "redeemRequest";
245
163
  readonly inputs: readonly [{
246
- readonly name: "tokenOut";
247
- readonly type: "address";
248
- readonly internalType: "address";
249
- }, {
250
164
  readonly name: "amountMTokenIn";
251
165
  readonly type: "uint256";
252
166
  readonly internalType: "uint256";
253
- }, {
254
- readonly name: "extraData";
255
- readonly type: "bytes";
256
- readonly internalType: "bytes";
257
167
  }];
258
168
  readonly outputs: readonly [{
259
169
  readonly name: "";
@@ -265,13 +175,13 @@ declare const abi: readonly [{
265
175
  readonly type: "function";
266
176
  readonly name: "redeemRequest";
267
177
  readonly inputs: readonly [{
268
- readonly name: "tokenOut";
269
- readonly type: "address";
270
- readonly internalType: "address";
271
- }, {
272
178
  readonly name: "amountMTokenIn";
273
179
  readonly type: "uint256";
274
180
  readonly internalType: "uint256";
181
+ }, {
182
+ readonly name: "extraData";
183
+ readonly type: "bytes";
184
+ readonly internalType: "bytes";
275
185
  }];
276
186
  readonly outputs: readonly [{
277
187
  readonly name: "";
@@ -283,10 +193,6 @@ declare const abi: readonly [{
283
193
  readonly type: "function";
284
194
  readonly name: "redeemRequestDiff";
285
195
  readonly inputs: readonly [{
286
- readonly name: "tokenOut";
287
- readonly type: "address";
288
- readonly internalType: "address";
289
- }, {
290
196
  readonly name: "leftoverAmount";
291
197
  readonly type: "uint256";
292
198
  readonly internalType: "uint256";
@@ -301,10 +207,6 @@ declare const abi: readonly [{
301
207
  readonly type: "function";
302
208
  readonly name: "redeemRequestDiff";
303
209
  readonly inputs: readonly [{
304
- readonly name: "tokenOut";
305
- readonly type: "address";
306
- readonly internalType: "address";
307
- }, {
308
210
  readonly name: "leftoverAmount";
309
211
  readonly type: "uint256";
310
212
  readonly internalType: "uint256";
@@ -339,43 +241,6 @@ declare const abi: readonly [{
339
241
  readonly internalType: "bytes";
340
242
  }];
341
243
  readonly stateMutability: "view";
342
- }, {
343
- readonly type: "function";
344
- readonly name: "setInputTokenAllowedStatusBatch";
345
- readonly inputs: readonly [{
346
- readonly name: "tokens";
347
- readonly type: "address[]";
348
- readonly internalType: "address[]";
349
- }, {
350
- readonly name: "allowed";
351
- readonly type: "bool[]";
352
- readonly internalType: "bool[]";
353
- }];
354
- readonly outputs: readonly [];
355
- readonly stateMutability: "nonpayable";
356
- }, {
357
- readonly type: "function";
358
- readonly name: "setOutputTokenAllowedStatusBatch";
359
- readonly inputs: readonly [{
360
- readonly name: "configs";
361
- readonly type: "tuple[]";
362
- readonly internalType: "struct IMidasGatewayAdapter.MidasAllowedTokenStatus[]";
363
- readonly components: readonly [{
364
- readonly name: "token";
365
- readonly type: "address";
366
- readonly internalType: "address";
367
- }, {
368
- readonly name: "phantomToken";
369
- readonly type: "address";
370
- readonly internalType: "address";
371
- }, {
372
- readonly name: "allowed";
373
- readonly type: "bool";
374
- readonly internalType: "bool";
375
- }];
376
- }];
377
- readonly outputs: readonly [];
378
- readonly stateMutability: "nonpayable";
379
244
  }, {
380
245
  readonly type: "function";
381
246
  readonly name: "targetContract";
@@ -418,10 +283,6 @@ declare const abi: readonly [{
418
283
  readonly type: "function";
419
284
  readonly name: "withdraw";
420
285
  readonly inputs: readonly [{
421
- readonly name: "tokenOut";
422
- readonly type: "address";
423
- readonly internalType: "address";
424
- }, {
425
286
  readonly name: "amount";
426
287
  readonly type: "uint256";
427
288
  readonly internalType: "uint256";
@@ -439,10 +300,6 @@ declare const abi: readonly [{
439
300
  readonly name: "redeemer";
440
301
  readonly type: "address";
441
302
  readonly internalType: "address";
442
- }, {
443
- readonly name: "tokenOut";
444
- readonly type: "address";
445
- readonly internalType: "address";
446
303
  }, {
447
304
  readonly name: "amount";
448
305
  readonly type: "uint256";
@@ -472,56 +329,13 @@ declare const abi: readonly [{
472
329
  readonly internalType: "bool";
473
330
  }];
474
331
  readonly stateMutability: "nonpayable";
475
- }, {
476
- readonly type: "event";
477
- readonly name: "SetInputTokenAllowedStatus";
478
- readonly inputs: readonly [{
479
- readonly name: "token";
480
- readonly type: "address";
481
- readonly indexed: true;
482
- readonly internalType: "address";
483
- }, {
484
- readonly name: "allowed";
485
- readonly type: "bool";
486
- readonly indexed: false;
487
- readonly internalType: "bool";
488
- }];
489
- readonly anonymous: false;
490
- }, {
491
- readonly type: "event";
492
- readonly name: "SetOutputTokenAllowedStatus";
493
- readonly inputs: readonly [{
494
- readonly name: "token";
495
- readonly type: "address";
496
- readonly indexed: true;
497
- readonly internalType: "address";
498
- }, {
499
- readonly name: "phantomToken";
500
- readonly type: "address";
501
- readonly indexed: true;
502
- readonly internalType: "address";
503
- }, {
504
- readonly name: "allowed";
505
- readonly type: "bool";
506
- readonly indexed: false;
507
- readonly internalType: "bool";
508
- }];
509
- readonly anonymous: false;
510
- }, {
511
- readonly type: "error";
512
- readonly name: "IncorrectArrayLengthException";
513
- readonly inputs: readonly [];
514
332
  }, {
515
333
  readonly type: "error";
516
334
  readonly name: "IncorrectStakedPhantomTokenException";
517
335
  readonly inputs: readonly [];
518
336
  }, {
519
337
  readonly type: "error";
520
- readonly name: "PhantomTokenTokenOutMismatchException";
521
- readonly inputs: readonly [];
522
- }, {
523
- readonly type: "error";
524
- readonly name: "TokenNotAllowedException";
338
+ readonly name: "PhantomTokenNotSetException";
525
339
  readonly inputs: readonly [];
526
340
  }];
527
341
  type abi = typeof abi;
@@ -549,10 +363,6 @@ declare const protocolAbi: readonly [{
549
363
  readonly type: "function";
550
364
  readonly name: "depositInstant";
551
365
  readonly inputs: readonly [{
552
- readonly name: "tokenIn";
553
- readonly type: "address";
554
- readonly internalType: "address";
555
- }, {
556
366
  readonly name: "amountToken";
557
367
  readonly type: "uint256";
558
368
  readonly internalType: "uint256";
@@ -584,10 +394,6 @@ declare const protocolAbi: readonly [{
584
394
  readonly name: "account";
585
395
  readonly type: "address";
586
396
  readonly internalType: "address";
587
- }, {
588
- readonly name: "tokenOut";
589
- readonly type: "address";
590
- readonly internalType: "address";
591
397
  }];
592
398
  readonly outputs: readonly [{
593
399
  readonly name: "pendingAmount";
@@ -615,12 +421,28 @@ declare const protocolAbi: readonly [{
615
421
  readonly stateMutability: "view";
616
422
  }, {
617
423
  readonly type: "function";
618
- readonly name: "redeemInstant";
619
- readonly inputs: readonly [{
620
- readonly name: "tokenOut";
424
+ readonly name: "phantomToken";
425
+ readonly inputs: readonly [];
426
+ readonly outputs: readonly [{
427
+ readonly name: "";
621
428
  readonly type: "address";
622
429
  readonly internalType: "address";
623
- }, {
430
+ }];
431
+ readonly stateMutability: "view";
432
+ }, {
433
+ readonly type: "function";
434
+ readonly name: "quoteToken";
435
+ readonly inputs: readonly [];
436
+ readonly outputs: readonly [{
437
+ readonly name: "";
438
+ readonly type: "address";
439
+ readonly internalType: "address";
440
+ }];
441
+ readonly stateMutability: "view";
442
+ }, {
443
+ readonly type: "function";
444
+ readonly name: "redeemInstant";
445
+ readonly inputs: readonly [{
624
446
  readonly name: "amountMTokenIn";
625
447
  readonly type: "uint256";
626
448
  readonly internalType: "uint256";
@@ -645,10 +467,6 @@ declare const protocolAbi: readonly [{
645
467
  readonly type: "function";
646
468
  readonly name: "requestRedeem";
647
469
  readonly inputs: readonly [{
648
- readonly name: "tokenOut";
649
- readonly type: "address";
650
- readonly internalType: "address";
651
- }, {
652
470
  readonly name: "amountMTokenIn";
653
471
  readonly type: "uint256";
654
472
  readonly internalType: "uint256";
@@ -697,10 +515,6 @@ declare const protocolAbi: readonly [{
697
515
  readonly type: "function";
698
516
  readonly name: "withdraw";
699
517
  readonly inputs: readonly [{
700
- readonly name: "tokenOut";
701
- readonly type: "address";
702
- readonly internalType: "address";
703
- }, {
704
518
  readonly name: "amount";
705
519
  readonly type: "uint256";
706
520
  readonly internalType: "uint256";
@@ -714,10 +528,6 @@ declare const protocolAbi: readonly [{
714
528
  readonly name: "redeemer";
715
529
  readonly type: "address";
716
530
  readonly internalType: "address";
717
- }, {
718
- readonly name: "tokenOut";
719
- readonly type: "address";
720
- readonly internalType: "address";
721
531
  }, {
722
532
  readonly name: "amount";
723
533
  readonly type: "uint256";
@@ -733,6 +543,10 @@ declare const protocolAbi: readonly [{
733
543
  readonly type: "error";
734
544
  readonly name: "CreditAccountNotEligibleException";
735
545
  readonly inputs: readonly [];
546
+ }, {
547
+ readonly type: "error";
548
+ readonly name: "IncompatibleAccessControlsException";
549
+ readonly inputs: readonly [];
736
550
  }, {
737
551
  readonly type: "error";
738
552
  readonly name: "IncompatibleIssuanceAndRedemptionVaultsException";
@@ -764,12 +578,13 @@ export declare class MidasGatewayAdapterContract extends AbstractAdapterContract
764
578
  constructor(sdk: OnchainSDK, args: ConcreteAdapterContractOptions);
765
579
  get gateway(): Address;
766
580
  get mToken(): Address;
581
+ get quoteToken(): Address;
582
+ /**
583
+ * Redemption phantom token; `zeroAddress` when the gateway was deployed
584
+ * without delayed withdrawals
585
+ */
586
+ get phantomToken(): Address;
767
587
  get referrerId(): string;
768
- get allowedInputTokens(): Address[];
769
- get allowedOutputTokens(): {
770
- token: Address;
771
- phantomToken: Address;
772
- }[];
773
588
  stateHuman(raw?: boolean): {
774
589
  address: string;
775
590
  version: number;
@@ -778,18 +593,15 @@ export declare class MidasGatewayAdapterContract extends AbstractAdapterContract
778
593
  targetContract?: string;
779
594
  gateway: string | undefined;
780
595
  mToken: string | undefined;
596
+ quoteToken: string | undefined;
597
+ phantomToken: string | undefined;
781
598
  referrerId: string | undefined;
782
- allowedInputTokens: string[] | undefined;
783
- allowedOutputTokens: {
784
- token: string;
785
- phantomToken: string;
786
- }[] | undefined;
787
599
  };
788
600
  /**
789
601
  * `redeemRequest` (the only request call the withdrawal compressor emits)
790
- * spends the mToken and mints the phantom token of the requested
791
- * `tokenOut`, which is received when the redemption is claimed. The 3-arg
792
- * overload carries the intent `extraData`.
602
+ * spends the mToken and mints the redemption phantom token; the quote token
603
+ * is received when the redemption is claimed. The 2-arg overload carries
604
+ * the intent `extraData`.
793
605
  */
794
606
  parseDelayedWithdrawalRequest(calldata: Hex): DelayedWithdrawalRequest | undefined;
795
607
  protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
@@ -11,8 +11,10 @@ export declare function isCloseOrRepay(multicall: InnerOperation[]): boolean;
11
11
  /**
12
12
  * Distinguishes a closure from a repayment by how collateral leaves the
13
13
  * account:
14
- * - close swaps all assets into underlying and withdraws only the underlying
14
+ * - close swaps all assets into an exit token and withdraws only exit
15
+ * tokens: the underlying or, on RWA markets, the unwrapped RWA underlying
16
+ * (the ERC4626 vault asset)
15
17
  * - repay returns collateral in-kind: it adds collateral from the wallet to
16
- * cover the debt and/or withdraws non-underlying tokens.
18
+ * cover the debt and/or withdraws non-exit tokens.
17
19
  */
18
- export declare function classifyCloseOrRepay(multicall: InnerOperation[], underlying: Address): "close" | "repay";
20
+ export declare function classifyCloseOrRepay(multicall: InnerOperation[], exitTokens: Address[]): "close" | "repay";
@@ -218,11 +218,13 @@ export interface CloseCreditAccountPreview {
218
218
  */
219
219
  creditAccount: Address;
220
220
  /**
221
- * Underlying withdrawn to the user: minimal guaranteed amount, from the
222
- * multicall replay (all collateral is swapped into underlying before
223
- * withdrawal)
221
+ * Token withdrawn to the user and its minimal guaranteed amount, from the
222
+ * multicall replay (all collateral is swapped into the received token
223
+ * before withdrawal). The token is the market underlying or, on RWA
224
+ * markets, the unwrapped RWA underlying (the ERC4626 vault asset the
225
+ * underlying share converts 1:1 into)
224
226
  */
225
- receivedAmount: bigint;
227
+ receivedAmount: Asset;
226
228
  /**
227
229
  * Set when preview encountered non-fatal errors, all fields are
228
230
  * still computed best-effort, but the
@@ -12,6 +12,7 @@ export interface GetTotalTokensOnProtocolProps {
12
12
  tokensToCheck: Array<Address>;
13
13
  tokensList: Record<Address, TokenData>;
14
14
  network: NetworkType;
15
+ backendUrl?: string;
15
16
  }
16
17
  export type PoolPointsBase = Record<Address, Array<{
17
18
  key: string;
@@ -21,7 +22,8 @@ export type PoolPointsBase = Record<Address, Array<{
21
22
  export declare function getKeyForPoolPointsInfo(i: PoolPointsInfo<string>): string;
22
23
  export declare class PoolPointsAPI {
23
24
  private constructor();
24
- static getTotalTokensOnProtocol({ tokensToCheck, tokensList, network, }: GetTotalTokensOnProtocolProps): Promise<[`0x${string}`, PromiseSettledResult<Asset>][]>;
25
+ private static defaultBackendUrl;
26
+ static getTotalTokensOnProtocol({ tokensToCheck, tokensList, network, backendUrl, }: GetTotalTokensOnProtocolProps): Promise<[`0x${string}`, PromiseSettledResult<Asset>][]>;
25
27
  private static getTokenTotal;
26
28
  static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList, }: GetPointsByPoolProps): PoolPointsBase;
27
29
  private static getPoolTokenPoints;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.31",
3
+ "version": "14.12.0-next.33",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {