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

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 (59) hide show
  1. package/dist/cjs/abi/IWithdrawalCompressorV313.js +136 -0
  2. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +24 -33
  3. package/dist/cjs/preview/prerequisites/buildCollateralPrerequisites.js +39 -3
  4. package/dist/cjs/preview/prerequisites/checkPrerequisites.js +2 -1
  5. package/dist/cjs/preview/preview/buildDelayedPreview.js +6 -5
  6. package/dist/cjs/preview/preview/previewOperation.js +4 -1
  7. package/dist/cjs/sdk/MultichainSDK.js +7 -0
  8. package/dist/cjs/sdk/OnchainSDK.js +14 -4
  9. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +16 -3
  10. package/dist/cjs/sdk/accounts/index.js +2 -0
  11. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +207 -0
  12. package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +65 -0
  13. package/dist/cjs/sdk/accounts/liquidations/helpers.js +63 -0
  14. package/dist/cjs/sdk/accounts/liquidations/index.js +28 -0
  15. package/dist/cjs/sdk/accounts/liquidations/types.js +16 -0
  16. package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +142 -74
  17. package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +97 -0
  18. package/dist/cjs/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +1 -7
  19. package/dist/cjs/sdk/accounts/withdrawal-compressor/types.js +20 -0
  20. package/dist/esm/abi/IWithdrawalCompressorV313.js +136 -0
  21. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +24 -33
  22. package/dist/esm/preview/prerequisites/buildCollateralPrerequisites.js +43 -4
  23. package/dist/esm/preview/prerequisites/checkPrerequisites.js +2 -1
  24. package/dist/esm/preview/preview/buildDelayedPreview.js +6 -5
  25. package/dist/esm/preview/preview/previewOperation.js +4 -1
  26. package/dist/esm/sdk/MultichainSDK.js +7 -0
  27. package/dist/esm/sdk/OnchainSDK.js +16 -5
  28. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +16 -3
  29. package/dist/esm/sdk/accounts/index.js +1 -0
  30. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +188 -0
  31. package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +41 -0
  32. package/dist/esm/sdk/accounts/liquidations/helpers.js +36 -0
  33. package/dist/esm/sdk/accounts/liquidations/index.js +4 -0
  34. package/dist/esm/sdk/accounts/liquidations/types.js +0 -0
  35. package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +138 -74
  36. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +104 -1
  37. package/dist/esm/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +1 -7
  38. package/dist/esm/sdk/accounts/withdrawal-compressor/types.js +12 -0
  39. package/dist/types/abi/IWithdrawalCompressorV313.d.ts +200 -0
  40. package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +7 -7
  41. package/dist/types/preview/prerequisites/buildCollateralPrerequisites.d.ts +1 -0
  42. package/dist/types/preview/prerequisites/types.d.ts +10 -2
  43. package/dist/types/preview/preview/buildDelayedPreview.d.ts +7 -2
  44. package/dist/types/sdk/MultichainSDK.d.ts +6 -0
  45. package/dist/types/sdk/OnchainSDK.d.ts +8 -5
  46. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
  47. package/dist/types/sdk/accounts/index.d.ts +1 -0
  48. package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +20 -0
  49. package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +23 -0
  50. package/dist/types/sdk/accounts/liquidations/helpers.d.ts +34 -0
  51. package/dist/types/sdk/accounts/liquidations/index.d.ts +4 -0
  52. package/dist/types/sdk/accounts/liquidations/types.d.ts +172 -0
  53. package/dist/types/sdk/accounts/types.d.ts +6 -0
  54. package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +80 -6
  55. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +222 -0
  56. package/dist/types/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.d.ts +5 -4
  57. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +106 -7
  58. package/dist/types/sdk/types/state.d.ts +8 -0
  59. package/package.json +1 -1
@@ -18,11 +18,16 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var AbstractWithdrawalCompressorContract_exports = {};
20
20
  __export(AbstractWithdrawalCompressorContract_exports, {
21
- AbstractWithdrawalCompressorContract: () => AbstractWithdrawalCompressorContract
21
+ AbstractWithdrawalCompressorContract: () => AbstractWithdrawalCompressorContract,
22
+ iCreditAccountAbi: () => iCreditAccountAbi,
23
+ toClaimableWithdrawal: () => toClaimableWithdrawal,
24
+ toPendingWithdrawal: () => toPendingWithdrawal,
25
+ toRequestableWithdrawal: () => toRequestableWithdrawal
22
26
  });
23
27
  module.exports = __toCommonJS(AbstractWithdrawalCompressorContract_exports);
24
28
  var import_viem = require("viem");
25
29
  var import_base = require("../../base/index.js");
30
+ var import_utils = require("../../utils/index.js");
26
31
  var import_intent_codec = require("./intent-codec.js");
27
32
  const iCreditAccountAbi = [
28
33
  {
@@ -33,12 +38,23 @@ const iCreditAccountAbi = [
33
38
  stateMutability: "view"
34
39
  }
35
40
  ];
41
+ const MAP_LABEL = "withdrawableAssets";
36
42
  class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
37
43
  #sdk;
44
+ #withdrawableAssets;
38
45
  constructor(sdk, args) {
39
46
  super(sdk, args);
40
47
  this.#sdk = sdk;
41
48
  }
49
+ /**
50
+ * {@inheritDoc IWithdrawalCompressorContract.hydrate}
51
+ **/
52
+ hydrate(state) {
53
+ this.#withdrawableAssets = new import_utils.AddressMap(
54
+ Object.entries(state.withdrawableAssets),
55
+ MAP_LABEL
56
+ );
57
+ }
42
58
  /**
43
59
  * The contract is instantiated with the actual versioned ABI,
44
60
  * this cast is type-level only (see {@link CommonAbi}).
@@ -46,18 +62,35 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
46
62
  get common() {
47
63
  return this.contract;
48
64
  }
65
+ /**
66
+ * {@inheritDoc IWithdrawalCompressorContract.state}
67
+ **/
68
+ get state() {
69
+ return this.#withdrawableAssets ? { withdrawableAssets: this.#withdrawableAssets.asRecord() } : void 0;
70
+ }
49
71
  /**
50
72
  * {@inheritDoc IWithdrawalCompressorContract.getWithdrawableAssets}
51
73
  **/
52
- async getWithdrawableAssets(creditManager) {
53
- const resp = await this.common.read.getWithdrawableAssets([creditManager]);
54
- return resp.map((a) => toWithdrawableAsset(a, creditManager));
74
+ getWithdrawableAssets(...creditManagers) {
75
+ const cache = this.#withdrawableAssets;
76
+ if (!cache) {
77
+ throw new Error(
78
+ "withdrawable assets are not loaded, call loadWithdrawableAssets first"
79
+ );
80
+ }
81
+ if (creditManagers.length === 0) {
82
+ return cache.values().flat();
83
+ }
84
+ return creditManagers.flatMap((cm) => cache.get(cm) ?? []);
55
85
  }
56
86
  /**
57
- * {@inheritDoc IWithdrawalCompressorContract.getWithdrawableAssetsBatch}
87
+ * {@inheritDoc IWithdrawalCompressorContract.loadWithdrawableAssets}
58
88
  **/
59
- async getWithdrawableAssetsBatch(creditManagers) {
60
- const cms = creditManagers ?? this.#sdk.marketRegister.creditManagers.map(
89
+ async loadWithdrawableAssets(force) {
90
+ if (this.#withdrawableAssets && !force) {
91
+ return this.getWithdrawableAssets();
92
+ }
93
+ const cms = this.#sdk.marketRegister.creditManagers.map(
61
94
  (cm) => cm.creditManager.address
62
95
  );
63
96
  const resp = await this.client.multicall({
@@ -72,22 +105,48 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
72
105
  allowFailure: true,
73
106
  batchSize: 0
74
107
  });
75
- return resp.flatMap((r, i) => {
108
+ const cache = new import_utils.AddressMap(void 0, MAP_LABEL);
109
+ for (let i = 0; i < resp.length; i++) {
110
+ const r = resp[i];
76
111
  if (r.status !== "success") {
77
112
  this.logger?.warn(
78
113
  `failed to get withdrawable assets of credit manager ${cms[i]}: ${r.error}`
79
114
  );
80
- return [];
115
+ continue;
81
116
  }
82
- return r.result.map((a) => toWithdrawableAsset(a, cms[i]));
83
- });
117
+ if (r.result.length > 0) {
118
+ cache.upsert(
119
+ cms[i],
120
+ r.result.map((a) => toWithdrawableAsset(a, cms[i]))
121
+ );
122
+ }
123
+ }
124
+ this.#withdrawableAssets = cache;
125
+ return this.getWithdrawableAssets();
126
+ }
127
+ /**
128
+ * {@inheritDoc IWithdrawalCompressorContract.findWithdrawableAssets}
129
+ **/
130
+ async findWithdrawableAssets(creditManager, token) {
131
+ await this.loadWithdrawableAssets();
132
+ return this.getWithdrawableAssets(creditManager).filter(
133
+ (a) => (0, import_viem.isAddressEqual)(a.token, token)
134
+ );
135
+ }
136
+ /**
137
+ * {@inheritDoc IWithdrawalCompressorContract.findWithdrawableAssetsByPhantomToken}
138
+ **/
139
+ async findWithdrawableAssetsByPhantomToken(withdrawalPhantomToken) {
140
+ await this.loadWithdrawableAssets();
141
+ return this.getWithdrawableAssets().filter(
142
+ (a) => (0, import_viem.isAddressEqual)(a.withdrawalPhantomToken, withdrawalPhantomToken)
143
+ );
84
144
  }
85
145
  /**
86
146
  * {@inheritDoc IWithdrawalCompressorContract.getWithdrawalPhantomToken}
87
147
  **/
88
148
  async getWithdrawalPhantomToken(creditManager, token) {
89
- const assets = await this.getWithdrawableAssets(creditManager);
90
- const asset = assets.find((a) => (0, import_viem.isAddressEqual)(a.token, token));
149
+ const [asset] = await this.findWithdrawableAssets(creditManager, token);
91
150
  if (!asset) {
92
151
  throw new Error(
93
152
  `token ${token} is not withdrawable from credit manager ${creditManager}`
@@ -95,6 +154,14 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
95
154
  }
96
155
  return asset.withdrawalPhantomToken;
97
156
  }
157
+ /**
158
+ * {@inheritDoc IWithdrawalCompressorContract.getWithdrawalSourceToken}
159
+ **/
160
+ getWithdrawalSourceToken(withdrawalPhantomToken) {
161
+ return this.getWithdrawableAssets().find(
162
+ (a) => (0, import_viem.isAddressEqual)(a.withdrawalPhantomToken, withdrawalPhantomToken)
163
+ )?.token;
164
+ }
98
165
  /**
99
166
  * {@inheritDoc IWithdrawalCompressorContract.getCurrentWithdrawals}
100
167
  **/
@@ -117,83 +184,80 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
117
184
  batchSize: 0
118
185
  });
119
186
  return {
120
- claimable: claimable.map(
121
- (w) => toClaimableWithdrawal(w, creditManager, this.version >= 313)
122
- ),
123
- pending: pending.map((w) => toPendingWithdrawal(w, creditManager, this.version >= 313)).sort((a, b) => a.claimableAt < b.claimableAt ? -1 : 1)
187
+ claimable: claimable.map((w) => toClaimableWithdrawal(w, creditManager)),
188
+ pending: pending.map((w) => toPendingWithdrawal(w, creditManager)).sort((a, b) => a.claimableAt < b.claimableAt ? -1 : 1)
124
189
  };
125
190
  }
191
+ /**
192
+ * {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
193
+ **/
194
+ async getExternalAccountCurrentWithdrawals(_withdrawalToken, _account) {
195
+ this.#reportUnsupported("external account withdrawals");
196
+ return { claimable: [], pending: [] };
197
+ }
198
+ /**
199
+ * {@inheritDoc IWithdrawalCompressorContract.getWithdrawalStatus}
200
+ **/
201
+ async getWithdrawalStatus(...redeemers) {
202
+ if (redeemers.length === 0) {
203
+ return [];
204
+ }
205
+ this.#reportUnsupported("withdrawal status");
206
+ return redeemers.map(() => "NULL");
207
+ }
126
208
  /**
127
209
  * {@inheritDoc IWithdrawalCompressorContract.getWithdrawalRequestResult}
210
+ *
211
+ * Legacy compressors only support the 3-arg overload: `intent` and
212
+ * `withdrawalPhantomToken` are reported as unsupported (in non-strict mode
213
+ * the request is previewed without them).
128
214
  **/
129
- async getWithdrawalRequestResult(creditAccount, token, amount, intent) {
130
- const resp = intent ? await this.#getWithdrawalRequestResultWithIntent(
131
- creditAccount,
132
- token,
133
- amount,
134
- intent
135
- ) : await this.common.read.getWithdrawalRequestResult([
215
+ async getWithdrawalRequestResult({
216
+ creditAccount,
217
+ token,
218
+ amount,
219
+ withdrawalPhantomToken,
220
+ intent
221
+ }) {
222
+ if (intent) {
223
+ this.#reportUnsupported("withdrawal intents");
224
+ } else if (withdrawalPhantomToken) {
225
+ this.#reportUnsupported("withdrawal config selection");
226
+ }
227
+ const resp = await this.common.read.getWithdrawalRequestResult([
136
228
  creditAccount,
137
229
  token,
138
230
  amount
139
231
  ]);
140
- return {
141
- token: resp.token,
142
- amountIn: resp.amountIn,
143
- outputs: [...resp.outputs],
144
- requestCalls: [...resp.requestCalls],
145
- claimableAt: resp.claimableAt
146
- };
232
+ return toRequestableWithdrawal(resp);
147
233
  }
148
234
  /**
149
- * Previews a delayed withdrawal request with an intent attached as
150
- * `extraData`. Only supported on v313+ compressors; on older versions,
151
- * throws if `sdk.strictContractTypes` is `true`, otherwise logs a warning
152
- * and previews the request without the intent.
153
- *
154
- * The contract overload accepting `extraData` also requires the withdrawal
155
- * phantom token, which is resolved here the same way the 3-arg overload
156
- * does it internally: via `getWithdrawableAssets` of the account's credit
157
- * manager.
235
+ * Reports that a feature is not supported by this compressor version:
236
+ * throws if `sdk.strictContractTypes` is `true`, otherwise logs a warning.
158
237
  **/
159
- async #getWithdrawalRequestResultWithIntent(creditAccount, token, amount, intent) {
160
- if (this.version < 313) {
161
- const message = `withdrawal intents are not supported by ${this.name} v${this.version}`;
162
- if (this.#sdk.strictContractTypes) {
163
- throw new Error(message);
164
- }
165
- this.logger?.warn(`${message}, requesting withdrawal without intent`);
166
- return this.common.read.getWithdrawalRequestResult([
167
- creditAccount,
168
- token,
169
- amount
170
- ]);
238
+ #reportUnsupported(feature) {
239
+ const message = `${feature} is not supported by ${this.name} v${this.version}`;
240
+ if (this.#sdk.strictContractTypes) {
241
+ throw new Error(message);
171
242
  }
172
- const extraData = (0, import_intent_codec.encodeDelayedIntent)(intent);
173
- const creditManager = await this.client.readContract({
174
- address: creditAccount,
175
- abi: iCreditAccountAbi,
176
- functionName: "creditManager"
177
- });
178
- const withdrawalPhantomToken = await this.getWithdrawalPhantomToken(
179
- creditManager,
180
- token
181
- );
182
- return this.common.read.getWithdrawalRequestResult([
183
- creditAccount,
184
- token,
185
- withdrawalPhantomToken,
186
- amount,
187
- extraData
188
- ]);
243
+ this.logger?.warn(message);
189
244
  }
190
245
  }
191
246
  function toWithdrawableAsset(a, creditManager) {
192
247
  return { creditManager, ...a };
193
248
  }
194
- function toClaimableWithdrawal(w, creditManager, decodeIntent) {
249
+ function toRequestableWithdrawal(resp) {
250
+ return {
251
+ token: resp.token,
252
+ amountIn: resp.amountIn,
253
+ outputs: [...resp.outputs],
254
+ requestCalls: [...resp.requestCalls],
255
+ claimableAt: resp.claimableAt
256
+ };
257
+ }
258
+ function toClaimableWithdrawal(w, creditManager) {
195
259
  let intent;
196
- if (decodeIntent && w.extraData && w.extraData !== "0x") {
260
+ if (creditManager && w.extraData && w.extraData !== "0x") {
197
261
  intent = { ...(0, import_intent_codec.decodeDelayedIntent)(w.extraData), creditManager };
198
262
  }
199
263
  return {
@@ -205,9 +269,9 @@ function toClaimableWithdrawal(w, creditManager, decodeIntent) {
205
269
  intent
206
270
  };
207
271
  }
208
- function toPendingWithdrawal(w, creditManager, decodeIntent) {
272
+ function toPendingWithdrawal(w, creditManager) {
209
273
  let intent;
210
- if (decodeIntent && w.extraData && w.extraData !== "0x") {
274
+ if (creditManager && w.extraData && w.extraData !== "0x") {
211
275
  intent = { ...(0, import_intent_codec.decodeDelayedIntent)(w.extraData), creditManager };
212
276
  }
213
277
  return {
@@ -220,5 +284,9 @@ function toPendingWithdrawal(w, creditManager, decodeIntent) {
220
284
  }
221
285
  // Annotate the CommonJS export names for ESM import in node:
222
286
  0 && (module.exports = {
223
- AbstractWithdrawalCompressorContract
287
+ AbstractWithdrawalCompressorContract,
288
+ iCreditAccountAbi,
289
+ toClaimableWithdrawal,
290
+ toPendingWithdrawal,
291
+ toRequestableWithdrawal
224
292
  });
@@ -23,7 +23,22 @@ __export(WithdrawalCompressorV313Contract_exports, {
23
23
  module.exports = __toCommonJS(WithdrawalCompressorV313Contract_exports);
24
24
  var import_IWithdrawalCompressorV313 = require("../../../abi/IWithdrawalCompressorV313.js");
25
25
  var import_AbstractWithdrawalCompressorContract = require("./AbstractWithdrawalCompressorContract.js");
26
+ var import_intent_codec = require("./intent-codec.js");
27
+ var import_types = require("./types.js");
26
28
  const abi = import_IWithdrawalCompressorV313.iWithdrawalCompressorV313Abi;
29
+ const iWithdrawalStatusBatchAbi = [
30
+ {
31
+ type: "function",
32
+ name: "getWithdrawalStatus",
33
+ inputs: [
34
+ { name: "redeemers", type: "address[]", internalType: "address[]" }
35
+ ],
36
+ outputs: [
37
+ { name: "", type: "uint8[]", internalType: "enum WithdrawalStatus[]" }
38
+ ],
39
+ stateMutability: "view"
40
+ }
41
+ ];
27
42
  class WithdrawalCompressorV313Contract extends import_AbstractWithdrawalCompressorContract.AbstractWithdrawalCompressorContract {
28
43
  constructor(sdk, address) {
29
44
  super(sdk, {
@@ -33,6 +48,88 @@ class WithdrawalCompressorV313Contract extends import_AbstractWithdrawalCompress
33
48
  version: 313
34
49
  });
35
50
  }
51
+ /**
52
+ * {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
53
+ **/
54
+ async getExternalAccountCurrentWithdrawals(withdrawalToken, account) {
55
+ const [claimable, pending] = await this.contract.read.getExternalAccountCurrentWithdrawals([
56
+ withdrawalToken,
57
+ account
58
+ ]);
59
+ return {
60
+ claimable: claimable.map((w) => (0, import_AbstractWithdrawalCompressorContract.toClaimableWithdrawal)(w, void 0)),
61
+ pending: pending.map((w) => (0, import_AbstractWithdrawalCompressorContract.toPendingWithdrawal)(w, void 0)).sort((a, b) => a.claimableAt < b.claimableAt ? -1 : 1)
62
+ };
63
+ }
64
+ /**
65
+ * {@inheritDoc IWithdrawalCompressorContract.getWithdrawalStatus}
66
+ **/
67
+ async getWithdrawalStatus(...redeemers) {
68
+ if (redeemers.length === 0) {
69
+ return [];
70
+ }
71
+ const resp = await this.client.readContract({
72
+ address: this.address,
73
+ abi: iWithdrawalStatusBatchAbi,
74
+ functionName: "getWithdrawalStatus",
75
+ args: [redeemers]
76
+ });
77
+ return resp.map((s) => (0, import_types.toWithdrawalStatus)(s));
78
+ }
79
+ /**
80
+ * {@inheritDoc IWithdrawalCompressorContract.getWithdrawalRequestResult}
81
+ *
82
+ * When an intent is provided, it is abi-encoded and attached to the request
83
+ * as `extraData`. The contract overload accepting `extraData` also requires
84
+ * the withdrawal phantom token; when not provided by the caller, it is
85
+ * resolved the same way the 3-arg overload does it internally: via the
86
+ * withdrawable assets of the account's credit manager.
87
+ **/
88
+ async getWithdrawalRequestResult({
89
+ creditAccount,
90
+ token,
91
+ amount,
92
+ withdrawalPhantomToken,
93
+ intent
94
+ }) {
95
+ let resp;
96
+ if (intent) {
97
+ const extraData = (0, import_intent_codec.encodeDelayedIntent)(intent);
98
+ let phantomToken = withdrawalPhantomToken;
99
+ if (!phantomToken) {
100
+ const creditManager = await this.client.readContract({
101
+ address: creditAccount,
102
+ abi: import_AbstractWithdrawalCompressorContract.iCreditAccountAbi,
103
+ functionName: "creditManager"
104
+ });
105
+ phantomToken = await this.getWithdrawalPhantomToken(
106
+ creditManager,
107
+ token
108
+ );
109
+ }
110
+ resp = await this.contract.read.getWithdrawalRequestResult([
111
+ creditAccount,
112
+ token,
113
+ phantomToken,
114
+ amount,
115
+ extraData
116
+ ]);
117
+ } else if (withdrawalPhantomToken) {
118
+ resp = await this.contract.read.getWithdrawalRequestResult([
119
+ creditAccount,
120
+ token,
121
+ withdrawalPhantomToken,
122
+ amount
123
+ ]);
124
+ } else {
125
+ resp = await this.contract.read.getWithdrawalRequestResult([
126
+ creditAccount,
127
+ token,
128
+ amount
129
+ ]);
130
+ }
131
+ return (0, import_AbstractWithdrawalCompressorContract.toRequestableWithdrawal)(resp);
132
+ }
36
133
  }
37
134
  // Annotate the CommonJS export names for ESM import in node:
38
135
  0 && (module.exports = {
@@ -28,13 +28,7 @@ var import_WithdrawalCompressorV313Contract = require("./WithdrawalCompressorV31
28
28
  function createWithdrawalCompressor(sdk) {
29
29
  const location = (0, import_addresses.getWithdrawalCompressorAddress)(sdk.networkType);
30
30
  if (!location) {
31
- throw new Error(`no withdrawal compressor on ${sdk.networkType}`);
32
- }
33
- const cached = sdk.getContract(
34
- location.address
35
- );
36
- if (cached) {
37
- return cached;
31
+ return void 0;
38
32
  }
39
33
  switch (location.version) {
40
34
  case 310:
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -13,4 +17,20 @@ var __copyProps = (to, from, except, desc) => {
13
17
  };
14
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
19
  var types_exports = {};
20
+ __export(types_exports, {
21
+ toWithdrawalStatus: () => toWithdrawalStatus
22
+ });
16
23
  module.exports = __toCommonJS(types_exports);
24
+ const WITHDRAWAL_STATUSES = [
25
+ "NULL",
26
+ "PENDING",
27
+ "CLAIMABLE",
28
+ "CLAIMED"
29
+ ];
30
+ function toWithdrawalStatus(status) {
31
+ return WITHDRAWAL_STATUSES[status] ?? "NULL";
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ toWithdrawalStatus
36
+ });
@@ -79,6 +79,100 @@ const iWithdrawalCompressorV313Abi = [
79
79
  ],
80
80
  stateMutability: "view"
81
81
  },
82
+ {
83
+ type: "function",
84
+ name: "getExternalAccountCurrentWithdrawals",
85
+ inputs: [
86
+ { name: "withdrawalToken", type: "address", internalType: "address" },
87
+ { name: "account", type: "address", internalType: "address" }
88
+ ],
89
+ outputs: [
90
+ {
91
+ name: "",
92
+ type: "tuple[]",
93
+ internalType: "struct ClaimableWithdrawal[]",
94
+ components: [
95
+ { name: "token", type: "address", internalType: "address" },
96
+ {
97
+ name: "withdrawalPhantomToken",
98
+ type: "address",
99
+ internalType: "address"
100
+ },
101
+ {
102
+ name: "withdrawalTokenSpent",
103
+ type: "uint256",
104
+ internalType: "uint256"
105
+ },
106
+ {
107
+ name: "outputs",
108
+ type: "tuple[]",
109
+ internalType: "struct WithdrawalOutput[]",
110
+ components: [
111
+ { name: "token", type: "address", internalType: "address" },
112
+ { name: "isDelayed", type: "bool", internalType: "bool" },
113
+ { name: "amount", type: "uint256", internalType: "uint256" }
114
+ ]
115
+ },
116
+ {
117
+ name: "claimCalls",
118
+ type: "tuple[]",
119
+ internalType: "struct MultiCall[]",
120
+ components: [
121
+ { name: "target", type: "address", internalType: "address" },
122
+ { name: "callData", type: "bytes", internalType: "bytes" }
123
+ ]
124
+ },
125
+ { name: "extraData", type: "bytes", internalType: "bytes" }
126
+ ]
127
+ },
128
+ {
129
+ name: "",
130
+ type: "tuple[]",
131
+ internalType: "struct PendingWithdrawal[]",
132
+ components: [
133
+ { name: "token", type: "address", internalType: "address" },
134
+ {
135
+ name: "withdrawalPhantomToken",
136
+ type: "address",
137
+ internalType: "address"
138
+ },
139
+ {
140
+ name: "expectedOutputs",
141
+ type: "tuple[]",
142
+ internalType: "struct WithdrawalOutput[]",
143
+ components: [
144
+ { name: "token", type: "address", internalType: "address" },
145
+ { name: "isDelayed", type: "bool", internalType: "bool" },
146
+ { name: "amount", type: "uint256", internalType: "uint256" }
147
+ ]
148
+ },
149
+ { name: "claimableAt", type: "uint256", internalType: "uint256" },
150
+ { name: "extraData", type: "bytes", internalType: "bytes" }
151
+ ]
152
+ }
153
+ ],
154
+ stateMutability: "view"
155
+ },
156
+ {
157
+ type: "function",
158
+ name: "getWithdrawalStatus",
159
+ inputs: [{ name: "redeemer", type: "address", internalType: "address" }],
160
+ outputs: [
161
+ { name: "", type: "uint8", internalType: "enum WithdrawalStatus" }
162
+ ],
163
+ stateMutability: "view"
164
+ },
165
+ {
166
+ type: "function",
167
+ name: "getWithdrawalStatus",
168
+ inputs: [
169
+ { name: "redeemers", type: "address[]", internalType: "address[]" }
170
+ ],
171
+ outputs: [
172
+ { name: "", type: "uint8[]", internalType: "enum WithdrawalStatus[]" }
173
+ ],
174
+ stateMutability: "view"
175
+ },
82
176
  {
83
177
  type: "function",
84
178
  name: "getWithdrawableAssets",
@@ -152,6 +246,48 @@ const iWithdrawalCompressorV313Abi = [
152
246
  ],
153
247
  stateMutability: "view"
154
248
  },
249
+ {
250
+ type: "function",
251
+ name: "getWithdrawalRequestResult",
252
+ inputs: [
253
+ { name: "creditAccount", type: "address", internalType: "address" },
254
+ { name: "token", type: "address", internalType: "address" },
255
+ { name: "withdrawalToken", type: "address", internalType: "address" },
256
+ { name: "amount", type: "uint256", internalType: "uint256" }
257
+ ],
258
+ outputs: [
259
+ {
260
+ name: "",
261
+ type: "tuple",
262
+ internalType: "struct RequestableWithdrawal",
263
+ components: [
264
+ { name: "token", type: "address", internalType: "address" },
265
+ { name: "amountIn", type: "uint256", internalType: "uint256" },
266
+ {
267
+ name: "outputs",
268
+ type: "tuple[]",
269
+ internalType: "struct WithdrawalOutput[]",
270
+ components: [
271
+ { name: "token", type: "address", internalType: "address" },
272
+ { name: "isDelayed", type: "bool", internalType: "bool" },
273
+ { name: "amount", type: "uint256", internalType: "uint256" }
274
+ ]
275
+ },
276
+ {
277
+ name: "requestCalls",
278
+ type: "tuple[]",
279
+ internalType: "struct MultiCall[]",
280
+ components: [
281
+ { name: "target", type: "address", internalType: "address" },
282
+ { name: "callData", type: "bytes", internalType: "bytes" }
283
+ ]
284
+ },
285
+ { name: "claimableAt", type: "uint256", internalType: "uint256" }
286
+ ]
287
+ }
288
+ ],
289
+ stateMutability: "view"
290
+ },
155
291
  {
156
292
  type: "function",
157
293
  name: "getWithdrawalRequestResult",