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

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 (47) hide show
  1. package/dist/cjs/abi/iRedemptionLoggerV310.js +119 -0
  2. package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +12 -0
  3. package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +12 -0
  4. package/dist/cjs/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +16 -0
  5. package/dist/cjs/preview/preview/detectDelayedClaim.js +53 -0
  6. package/dist/cjs/preview/preview/detectDelayedOperation.js +1 -2
  7. package/dist/cjs/preview/preview/errors.js +0 -17
  8. package/dist/cjs/preview/preview/index.js +2 -0
  9. package/dist/cjs/preview/preview/previewOperation.js +18 -1
  10. package/dist/cjs/sdk/OnchainSDK.js +11 -0
  11. package/dist/cjs/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +72 -0
  12. package/dist/cjs/sdk/accounts/withdrawal-compressor/createRedemptionLogger.js +43 -0
  13. package/dist/cjs/sdk/accounts/withdrawal-compressor/errors.js +38 -0
  14. package/dist/cjs/sdk/accounts/withdrawal-compressor/index.js +6 -0
  15. package/dist/cjs/sdk/constants/address-provider.js +3 -0
  16. package/dist/esm/abi/iRedemptionLoggerV310.js +95 -0
  17. package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +12 -0
  18. package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +12 -0
  19. package/dist/esm/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +16 -0
  20. package/dist/esm/preview/preview/detectDelayedClaim.js +30 -0
  21. package/dist/esm/preview/preview/detectDelayedOperation.js +3 -3
  22. package/dist/esm/preview/preview/errors.js +0 -16
  23. package/dist/esm/preview/preview/index.js +1 -0
  24. package/dist/esm/preview/preview/previewOperation.js +18 -1
  25. package/dist/esm/sdk/OnchainSDK.js +12 -0
  26. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +48 -0
  27. package/dist/esm/sdk/accounts/withdrawal-compressor/createRedemptionLogger.js +23 -0
  28. package/dist/esm/sdk/accounts/withdrawal-compressor/errors.js +14 -0
  29. package/dist/esm/sdk/accounts/withdrawal-compressor/index.js +3 -0
  30. package/dist/esm/sdk/constants/address-provider.js +2 -0
  31. package/dist/types/abi/iRedemptionLoggerV310.d.ts +122 -0
  32. package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +11 -1
  33. package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +6 -1
  34. package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +7 -1
  35. package/dist/types/plugins/adapters/types.d.ts +11 -0
  36. package/dist/types/preview/preview/detectDelayedClaim.d.ts +45 -0
  37. package/dist/types/preview/preview/errors.d.ts +0 -15
  38. package/dist/types/preview/preview/index.d.ts +1 -0
  39. package/dist/types/preview/preview/types.d.ts +15 -0
  40. package/dist/types/sdk/OnchainSDK.d.ts +8 -1
  41. package/dist/types/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +149 -0
  42. package/dist/types/sdk/accounts/withdrawal-compressor/createRedemptionLogger.d.ts +10 -0
  43. package/dist/types/sdk/accounts/withdrawal-compressor/errors.d.ts +13 -0
  44. package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +3 -0
  45. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +43 -1
  46. package/dist/types/sdk/constants/address-provider.d.ts +1 -0
  47. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import type { Address } from "viem";
2
2
  import { type PublicClient, type Transport } from "viem";
3
3
  import type { HttpRpcClientOptions } from "viem/utils";
4
- import { type ICreditAccountsService, type ILiquidationsService, type IWithdrawalCompressorContract } from "./accounts/index.js";
4
+ import { type ICreditAccountsService, type ILiquidationsService, type IRedemptionLoggerContract, type IWithdrawalCompressorContract } from "./accounts/index.js";
5
5
  import type { BaseState, IBaseContract } from "./base/index.js";
6
6
  import { ChainContractsRegister } from "./base/index.js";
7
7
  import type { GearboxChain, NetworkType } from "./chain/chains.js";
@@ -295,4 +295,11 @@ export declare class OnchainSDK<const Plugins extends PluginsMap = {}> extends C
295
295
  * when no withdrawal compressor is supported on it.
296
296
  **/
297
297
  get withdrawalCompressor(): IWithdrawalCompressorContract | undefined;
298
+ /**
299
+ * `RedemptionLogger` contract for the current chain, or `undefined` when
300
+ * it is not deployed on it. Created lazily on first access: the contract
301
+ * is resolved from the address provider, which is only available after
302
+ * the SDK is attached or hydrated.
303
+ **/
304
+ get redemptionLogger(): IRedemptionLoggerContract | undefined;
298
305
  }
@@ -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 {};
@@ -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
  /**
@@ -393,3 +393,45 @@ export interface IWithdrawalCompressorContract extends IBaseContract {
393
393
  **/
394
394
  readonly state: WithdrawalsState | undefined;
395
395
  }
396
+ /**
397
+ * Redemption data logged by a delayed-withdrawal gateway (Securitize, Midas)
398
+ * when a redemption is requested, keyed by the redeemer contract address.
399
+ **/
400
+ export interface RedemptionLog {
401
+ /**
402
+ * Credit account the redemption was requested for
403
+ */
404
+ creditAccount: Address;
405
+ /**
406
+ * Redeemer contract address
407
+ */
408
+ redeemer: Address;
409
+ /**
410
+ * Additional redemption data; carries the abi-encoded `DelayedIntent`
411
+ * when the request had one, `0x` otherwise
412
+ */
413
+ extraData: Hex;
414
+ }
415
+ /**
416
+ * Version-agnostic interface of the RedemptionLogger contract that stores
417
+ * redemption data logged by delayed-withdrawal gateways for off-chain
418
+ * indexing.
419
+ **/
420
+ export interface IRedemptionLoggerContract extends IBaseContract {
421
+ /**
422
+ * Returns the redemption data logged for a redeemer; all-zero fields when
423
+ * nothing was logged for it.
424
+ **/
425
+ getRedemptionLog(redeemer: Address, blockNumber?: bigint): Promise<RedemptionLog>;
426
+ /**
427
+ * Reads the redemption log of a redeemer and decodes the recorded intent.
428
+ *
429
+ * @param redeemer - Redeemer contract the withdrawal is claimed from.
430
+ * @param blockNumber - Optional block number to read the log at.
431
+ * @returns The decoded intent, or `undefined` when the log carries none
432
+ * (including when nothing was logged for the redeemer).
433
+ * @throws InvalidDelayedIntentError when the logged `extraData` is
434
+ * non-empty but cannot be decoded as a `DelayedIntent`.
435
+ **/
436
+ getDelayedIntent(redeemer: Address, blockNumber?: bigint): Promise<DelayedIntent | undefined>;
437
+ }
@@ -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.37",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {