@gearbox-protocol/sdk 14.12.0-next.36 → 14.12.0-next.38

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 (56) hide show
  1. package/dist/cjs/abi/IWithdrawalCompressorV313.js +78 -0
  2. package/dist/cjs/abi/iRedemptionLoggerV310.js +119 -0
  3. package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +12 -0
  4. package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +12 -0
  5. package/dist/cjs/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +16 -0
  6. package/dist/cjs/preview/preview/detectDelayedClaim.js +53 -0
  7. package/dist/cjs/preview/preview/detectDelayedOperation.js +1 -2
  8. package/dist/cjs/preview/preview/errors.js +0 -17
  9. package/dist/cjs/preview/preview/index.js +2 -0
  10. package/dist/cjs/preview/preview/previewOperation.js +18 -1
  11. package/dist/cjs/sdk/OnchainSDK.js +11 -0
  12. package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +1 -1
  13. package/dist/cjs/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +72 -0
  14. package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +90 -5
  15. package/dist/cjs/sdk/accounts/withdrawal-compressor/createRedemptionLogger.js +43 -0
  16. package/dist/cjs/sdk/accounts/withdrawal-compressor/errors.js +38 -0
  17. package/dist/cjs/sdk/accounts/withdrawal-compressor/index.js +6 -0
  18. package/dist/cjs/sdk/constants/address-provider.js +3 -0
  19. package/dist/esm/abi/IWithdrawalCompressorV313.js +78 -0
  20. package/dist/esm/abi/iRedemptionLoggerV310.js +95 -0
  21. package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +12 -0
  22. package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +12 -0
  23. package/dist/esm/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +16 -0
  24. package/dist/esm/preview/preview/detectDelayedClaim.js +30 -0
  25. package/dist/esm/preview/preview/detectDelayedOperation.js +3 -3
  26. package/dist/esm/preview/preview/errors.js +0 -16
  27. package/dist/esm/preview/preview/index.js +1 -0
  28. package/dist/esm/preview/preview/previewOperation.js +18 -1
  29. package/dist/esm/sdk/OnchainSDK.js +12 -0
  30. package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +1 -1
  31. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +48 -0
  32. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +90 -5
  33. package/dist/esm/sdk/accounts/withdrawal-compressor/createRedemptionLogger.js +23 -0
  34. package/dist/esm/sdk/accounts/withdrawal-compressor/errors.js +14 -0
  35. package/dist/esm/sdk/accounts/withdrawal-compressor/index.js +3 -0
  36. package/dist/esm/sdk/constants/address-provider.js +2 -0
  37. package/dist/types/abi/IWithdrawalCompressorV313.d.ts +103 -0
  38. package/dist/types/abi/iRedemptionLoggerV310.d.ts +122 -0
  39. package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +11 -1
  40. package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +6 -1
  41. package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +7 -1
  42. package/dist/types/plugins/adapters/types.d.ts +11 -0
  43. package/dist/types/preview/preview/detectDelayedClaim.d.ts +45 -0
  44. package/dist/types/preview/preview/errors.d.ts +0 -15
  45. package/dist/types/preview/preview/index.d.ts +1 -0
  46. package/dist/types/preview/preview/types.d.ts +15 -0
  47. package/dist/types/sdk/OnchainSDK.d.ts +8 -1
  48. package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +1 -1
  49. package/dist/types/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +149 -0
  50. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +104 -1
  51. package/dist/types/sdk/accounts/withdrawal-compressor/createRedemptionLogger.d.ts +10 -0
  52. package/dist/types/sdk/accounts/withdrawal-compressor/errors.d.ts +13 -0
  53. package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +3 -0
  54. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +46 -3
  55. package/dist/types/sdk/constants/address-provider.d.ts +1 -0
  56. package/package.json +1 -1
@@ -0,0 +1,149 @@
1
+ import type { Address } from "viem";
2
+ import { BaseContract } from "../../base/index.js";
3
+ import type { OnchainSDK } from "../../OnchainSDK.js";
4
+ import type { DelayedIntent, IRedemptionLoggerContract, RedemptionLog } from "./types.js";
5
+ declare const abi: readonly [{
6
+ readonly type: "function";
7
+ readonly name: "allowedGateways";
8
+ readonly inputs: readonly [{
9
+ readonly name: "gateway";
10
+ readonly type: "address";
11
+ readonly internalType: "address";
12
+ }];
13
+ readonly outputs: readonly [{
14
+ readonly name: "";
15
+ readonly type: "bool";
16
+ readonly internalType: "bool";
17
+ }];
18
+ readonly stateMutability: "view";
19
+ }, {
20
+ readonly type: "function";
21
+ readonly name: "contractType";
22
+ readonly inputs: readonly [];
23
+ readonly outputs: readonly [{
24
+ readonly name: "";
25
+ readonly type: "bytes32";
26
+ readonly internalType: "bytes32";
27
+ }];
28
+ readonly stateMutability: "view";
29
+ }, {
30
+ readonly type: "function";
31
+ readonly name: "logRedemption";
32
+ readonly inputs: readonly [{
33
+ readonly name: "creditAccount";
34
+ readonly type: "address";
35
+ readonly internalType: "address";
36
+ }, {
37
+ readonly name: "redeemer";
38
+ readonly type: "address";
39
+ readonly internalType: "address";
40
+ }, {
41
+ readonly name: "extraData";
42
+ readonly type: "bytes";
43
+ readonly internalType: "bytes";
44
+ }];
45
+ readonly outputs: readonly [];
46
+ readonly stateMutability: "nonpayable";
47
+ }, {
48
+ readonly type: "function";
49
+ readonly name: "redemptionLogs";
50
+ readonly inputs: readonly [{
51
+ readonly name: "redeemer";
52
+ readonly type: "address";
53
+ readonly internalType: "address";
54
+ }];
55
+ readonly outputs: readonly [{
56
+ readonly name: "";
57
+ readonly type: "tuple";
58
+ readonly internalType: "struct IRedemptionLogger.RedemptionLog";
59
+ readonly components: readonly [{
60
+ readonly name: "creditAccount";
61
+ readonly type: "address";
62
+ readonly internalType: "address";
63
+ }, {
64
+ readonly name: "redeemer";
65
+ readonly type: "address";
66
+ readonly internalType: "address";
67
+ }, {
68
+ readonly name: "extraData";
69
+ readonly type: "bytes";
70
+ readonly internalType: "bytes";
71
+ }];
72
+ }];
73
+ readonly stateMutability: "view";
74
+ }, {
75
+ readonly type: "function";
76
+ readonly name: "setGatewayAllowed";
77
+ readonly inputs: readonly [{
78
+ readonly name: "gateway";
79
+ readonly type: "address";
80
+ readonly internalType: "address";
81
+ }, {
82
+ readonly name: "allowed";
83
+ readonly type: "bool";
84
+ readonly internalType: "bool";
85
+ }];
86
+ readonly outputs: readonly [];
87
+ readonly stateMutability: "nonpayable";
88
+ }, {
89
+ readonly type: "function";
90
+ readonly name: "version";
91
+ readonly inputs: readonly [];
92
+ readonly outputs: readonly [{
93
+ readonly name: "";
94
+ readonly type: "uint256";
95
+ readonly internalType: "uint256";
96
+ }];
97
+ readonly stateMutability: "view";
98
+ }, {
99
+ readonly type: "event";
100
+ readonly name: "RedemptionLogged";
101
+ readonly inputs: readonly [{
102
+ readonly name: "creditAccount";
103
+ readonly type: "address";
104
+ readonly indexed: true;
105
+ readonly internalType: "address";
106
+ }, {
107
+ readonly name: "redeemer";
108
+ readonly type: "address";
109
+ readonly indexed: true;
110
+ readonly internalType: "address";
111
+ }, {
112
+ readonly name: "extraData";
113
+ readonly type: "bytes";
114
+ readonly indexed: false;
115
+ readonly internalType: "bytes";
116
+ }];
117
+ readonly anonymous: false;
118
+ }, {
119
+ readonly type: "error";
120
+ readonly name: "GatewayNotAllowedException";
121
+ readonly inputs: readonly [];
122
+ }];
123
+ type abi = typeof abi;
124
+ /**
125
+ * Wrapper around the v310 `RedemptionLogger` helper contract that stores
126
+ * redemption data logged by delayed-withdrawal gateways for off-chain
127
+ * indexing. Resolved from the address provider by the
128
+ * `LOCAL::REDEMPTION_LOGGER` key.
129
+ **/
130
+ export declare class RedemptionLoggerV310Contract extends BaseContract<abi> implements IRedemptionLoggerContract {
131
+ constructor(sdk: OnchainSDK, address: Address, version: number);
132
+ /**
133
+ * Returns the redemption data logged for a redeemer; all-zero fields when
134
+ * nothing was logged for it.
135
+ **/
136
+ getRedemptionLog(redeemer: Address, blockNumber?: bigint): Promise<RedemptionLog>;
137
+ /**
138
+ * Reads the redemption log of a redeemer and decodes the recorded intent.
139
+ *
140
+ * @param redeemer - Redeemer contract the withdrawal is claimed from.
141
+ * @param blockNumber - Optional block number to read the log at.
142
+ * @returns The decoded intent, or `undefined` when the log carries none
143
+ * (including when nothing was logged for the redeemer).
144
+ * @throws InvalidDelayedIntentError when the logged `extraData` is
145
+ * non-empty but cannot be decoded as a `DelayedIntent`.
146
+ **/
147
+ getDelayedIntent(redeemer: Address, blockNumber?: bigint): Promise<DelayedIntent | undefined>;
148
+ }
149
+ export {};
@@ -214,6 +214,109 @@ declare const abi: readonly [{
214
214
  }];
215
215
  }];
216
216
  readonly stateMutability: "view";
217
+ }, {
218
+ readonly type: "function";
219
+ readonly name: "getExternalAccountCurrentWithdrawals";
220
+ readonly inputs: readonly [{
221
+ readonly name: "withdrawalTokens";
222
+ readonly type: "address[]";
223
+ readonly internalType: "address[]";
224
+ }, {
225
+ readonly name: "account";
226
+ readonly type: "address";
227
+ readonly internalType: "address";
228
+ }];
229
+ readonly outputs: readonly [{
230
+ readonly name: "";
231
+ readonly type: "tuple[]";
232
+ readonly internalType: "struct ClaimableWithdrawal[]";
233
+ readonly components: readonly [{
234
+ readonly name: "token";
235
+ readonly type: "address";
236
+ readonly internalType: "address";
237
+ }, {
238
+ readonly name: "withdrawalPhantomToken";
239
+ readonly type: "address";
240
+ readonly internalType: "address";
241
+ }, {
242
+ readonly name: "withdrawalTokenSpent";
243
+ readonly type: "uint256";
244
+ readonly internalType: "uint256";
245
+ }, {
246
+ readonly name: "outputs";
247
+ readonly type: "tuple[]";
248
+ readonly internalType: "struct WithdrawalOutput[]";
249
+ readonly components: readonly [{
250
+ readonly name: "token";
251
+ readonly type: "address";
252
+ readonly internalType: "address";
253
+ }, {
254
+ readonly name: "isDelayed";
255
+ readonly type: "bool";
256
+ readonly internalType: "bool";
257
+ }, {
258
+ readonly name: "amount";
259
+ readonly type: "uint256";
260
+ readonly internalType: "uint256";
261
+ }];
262
+ }, {
263
+ readonly name: "claimCalls";
264
+ readonly type: "tuple[]";
265
+ readonly internalType: "struct MultiCall[]";
266
+ readonly components: readonly [{
267
+ readonly name: "target";
268
+ readonly type: "address";
269
+ readonly internalType: "address";
270
+ }, {
271
+ readonly name: "callData";
272
+ readonly type: "bytes";
273
+ readonly internalType: "bytes";
274
+ }];
275
+ }, {
276
+ readonly name: "extraData";
277
+ readonly type: "bytes";
278
+ readonly internalType: "bytes";
279
+ }];
280
+ }, {
281
+ readonly name: "";
282
+ readonly type: "tuple[]";
283
+ readonly internalType: "struct PendingWithdrawal[]";
284
+ readonly components: readonly [{
285
+ readonly name: "token";
286
+ readonly type: "address";
287
+ readonly internalType: "address";
288
+ }, {
289
+ readonly name: "withdrawalPhantomToken";
290
+ readonly type: "address";
291
+ readonly internalType: "address";
292
+ }, {
293
+ readonly name: "expectedOutputs";
294
+ readonly type: "tuple[]";
295
+ readonly internalType: "struct WithdrawalOutput[]";
296
+ readonly components: readonly [{
297
+ readonly name: "token";
298
+ readonly type: "address";
299
+ readonly internalType: "address";
300
+ }, {
301
+ readonly name: "isDelayed";
302
+ readonly type: "bool";
303
+ readonly internalType: "bool";
304
+ }, {
305
+ readonly name: "amount";
306
+ readonly type: "uint256";
307
+ readonly internalType: "uint256";
308
+ }];
309
+ }, {
310
+ readonly name: "claimableAt";
311
+ readonly type: "uint256";
312
+ readonly internalType: "uint256";
313
+ }, {
314
+ readonly name: "extraData";
315
+ readonly type: "bytes";
316
+ readonly internalType: "bytes";
317
+ }];
318
+ }];
319
+ readonly stateMutability: "view";
217
320
  }, {
218
321
  readonly type: "function";
219
322
  readonly name: "getWithdrawalStatus";
@@ -507,7 +610,7 @@ export declare class WithdrawalCompressorV313Contract extends AbstractWithdrawal
507
610
  /**
508
611
  * {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
509
612
  **/
510
- getExternalAccountCurrentWithdrawals(withdrawalToken: Address, account: Address): Promise<CurrentWithdrawals>;
613
+ getExternalAccountCurrentWithdrawals(account: Address, ...withdrawalTokens: Address[]): Promise<CurrentWithdrawals>;
511
614
  /**
512
615
  * {@inheritDoc IWithdrawalCompressorContract.getWithdrawalStatus}
513
616
  **/
@@ -0,0 +1,10 @@
1
+ import type { OnchainSDK } from "../../OnchainSDK.js";
2
+ import type { IRedemptionLoggerContract } from "./types.js";
3
+ /**
4
+ * Creates a redemption logger contract for the current chain, resolving its
5
+ * address from the address provider, or returns `undefined` when it is not
6
+ * deployed on it. Consumers should access the instance via
7
+ * `sdk.redemptionLogger`.
8
+ * @param sdk
9
+ **/
10
+ export declare function createRedemptionLogger(sdk: OnchainSDK): IRedemptionLoggerContract | undefined;
@@ -0,0 +1,13 @@
1
+ import type { Hex } from "viem";
2
+ /**
3
+ * Thrown when a delayed-withdrawal request or redemption log carries
4
+ * non-empty `extraData` that cannot be decoded as a `DelayedIntent`.
5
+ * Requests produced by our stack always encode a valid intent, so garbage
6
+ * here means a malformed/foreign transaction that must not be previewed as
7
+ * if it were fine.
8
+ */
9
+ export declare class InvalidDelayedIntentError extends Error {
10
+ /** Raw `extraData` that failed to decode. */
11
+ readonly extraData: Hex;
12
+ constructor(extraData: Hex, cause?: unknown);
13
+ }
@@ -1,7 +1,10 @@
1
1
  export * from "./AbstractWithdrawalCompressorContract.js";
2
2
  export * from "./addresses.js";
3
+ export * from "./createRedemptionLogger.js";
3
4
  export * from "./createWithdrawalCompressor.js";
5
+ export * from "./errors.js";
4
6
  export * from "./intent-codec.js";
7
+ export * from "./RedemptionLoggerV310Contract.js";
5
8
  export * from "./types.js";
6
9
  export * from "./WithdrawalCompressorV310Contract.js";
7
10
  export * from "./WithdrawalCompressorV311Contract.js";
@@ -1,4 +1,4 @@
1
- import type { Address } from "viem";
1
+ import type { Address, Hex } from "viem";
2
2
  import type { IBaseContract } from "../../base/index.js";
3
3
  import type { MultiCall } from "../../types/index.js";
4
4
  /**
@@ -361,12 +361,13 @@ export interface IWithdrawalCompressorContract extends IBaseContract {
361
361
  getCurrentWithdrawals(creditAccount: Address): Promise<CurrentWithdrawals>;
362
362
  /**
363
363
  * Returns claimable and pending delayed withdrawals of an external address
364
- * (non-credit-account, e.g. liquidator EOA) in the given withdrawal phantom token.
364
+ * (non-credit-account, e.g. liquidator EOA) in the given withdrawal phantom
365
+ * tokens. With no tokens given, returns empty lists.
365
366
  * Only supported on v313+ compressors; on older versions throws if
366
367
  * `sdk.strictContractTypes` is `true`, otherwise logs a warning and
367
368
  * returns empty lists.
368
369
  **/
369
- getExternalAccountCurrentWithdrawals(withdrawalToken: Address, account: Address): Promise<CurrentWithdrawals>;
370
+ getExternalAccountCurrentWithdrawals(account: Address, ...withdrawalTokens: Address[]): Promise<CurrentWithdrawals>;
370
371
  /**
371
372
  * Returns statuses of the given redeemer contracts.
372
373
  * Only supported on v313+ compressors; on older versions throws if
@@ -393,3 +394,45 @@ export interface IWithdrawalCompressorContract extends IBaseContract {
393
394
  **/
394
395
  readonly state: WithdrawalsState | undefined;
395
396
  }
397
+ /**
398
+ * Redemption data logged by a delayed-withdrawal gateway (Securitize, Midas)
399
+ * when a redemption is requested, keyed by the redeemer contract address.
400
+ **/
401
+ export interface RedemptionLog {
402
+ /**
403
+ * Credit account the redemption was requested for
404
+ */
405
+ creditAccount: Address;
406
+ /**
407
+ * Redeemer contract address
408
+ */
409
+ redeemer: Address;
410
+ /**
411
+ * Additional redemption data; carries the abi-encoded `DelayedIntent`
412
+ * when the request had one, `0x` otherwise
413
+ */
414
+ extraData: Hex;
415
+ }
416
+ /**
417
+ * Version-agnostic interface of the RedemptionLogger contract that stores
418
+ * redemption data logged by delayed-withdrawal gateways for off-chain
419
+ * indexing.
420
+ **/
421
+ export interface IRedemptionLoggerContract extends IBaseContract {
422
+ /**
423
+ * Returns the redemption data logged for a redeemer; all-zero fields when
424
+ * nothing was logged for it.
425
+ **/
426
+ getRedemptionLog(redeemer: Address, blockNumber?: bigint): Promise<RedemptionLog>;
427
+ /**
428
+ * Reads the redemption log of a redeemer and decodes the recorded intent.
429
+ *
430
+ * @param redeemer - Redeemer contract the withdrawal is claimed from.
431
+ * @param blockNumber - Optional block number to read the log at.
432
+ * @returns The decoded intent, or `undefined` when the log carries none
433
+ * (including when nothing was logged for the redeemer).
434
+ * @throws InvalidDelayedIntentError when the logged `extraData` is
435
+ * non-empty but cannot be decoded as a `DelayedIntent`.
436
+ **/
437
+ getDelayedIntent(redeemer: Address, blockNumber?: bigint): Promise<DelayedIntent | undefined>;
438
+ }
@@ -32,6 +32,7 @@ export declare const AP_WETH_TOKEN = "WETH_TOKEN";
32
32
  export declare const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
33
33
  export declare const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
34
34
  export declare const AP_RWA_COMPRESSOR = "GLOBAL::RWA_COMPRESSOR";
35
+ export declare const AP_REDEMPTION_LOGGER = "LOCAL::REDEMPTION_LOGGER";
35
36
  /**
36
37
  * Default address provider address for v3.1.0
37
38
  * Is determenistic and does not depend on the network type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.36",
3
+ "version": "14.12.0-next.38",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {