@gearbox-protocol/sdk 13.0.0-next.12 → 13.0.0-next.14

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.
@@ -0,0 +1,349 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var iSecuritizeKYCFactory_exports = {};
20
+ __export(iSecuritizeKYCFactory_exports, {
21
+ iSecuritizeKYCFactoryAbi: () => iSecuritizeKYCFactoryAbi
22
+ });
23
+ module.exports = __toCommonJS(iSecuritizeKYCFactory_exports);
24
+ const iSecuritizeKYCFactoryAbi = [
25
+ {
26
+ type: "function",
27
+ name: "addRegistrar",
28
+ inputs: [{ name: "registrar", type: "address", internalType: "address" }],
29
+ outputs: [],
30
+ stateMutability: "nonpayable"
31
+ },
32
+ {
33
+ type: "function",
34
+ name: "contractType",
35
+ inputs: [],
36
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
37
+ stateMutability: "view"
38
+ },
39
+ {
40
+ type: "function",
41
+ name: "degenNFT",
42
+ inputs: [],
43
+ outputs: [{ name: "", type: "address", internalType: "address" }],
44
+ stateMutability: "view"
45
+ },
46
+ {
47
+ type: "function",
48
+ name: "getCreditAccounts",
49
+ inputs: [{ name: "investor", type: "address", internalType: "address" }],
50
+ outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
51
+ stateMutability: "view"
52
+ },
53
+ {
54
+ type: "function",
55
+ name: "getInvestor",
56
+ inputs: [
57
+ { name: "creditAccount", type: "address", internalType: "address" }
58
+ ],
59
+ outputs: [{ name: "", type: "address", internalType: "address" }],
60
+ stateMutability: "view"
61
+ },
62
+ {
63
+ type: "function",
64
+ name: "getRegisteredTokens",
65
+ inputs: [
66
+ { name: "creditAccount", type: "address", internalType: "address" }
67
+ ],
68
+ outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
69
+ stateMutability: "view"
70
+ },
71
+ {
72
+ type: "function",
73
+ name: "getRegistrar",
74
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
75
+ outputs: [{ name: "", type: "address", internalType: "address" }],
76
+ stateMutability: "view"
77
+ },
78
+ {
79
+ type: "function",
80
+ name: "getWallet",
81
+ inputs: [
82
+ { name: "creditAccount", type: "address", internalType: "address" }
83
+ ],
84
+ outputs: [{ name: "", type: "address", internalType: "address" }],
85
+ stateMutability: "view"
86
+ },
87
+ {
88
+ type: "function",
89
+ name: "isActiveCreditAccount",
90
+ inputs: [
91
+ { name: "creditAccount", type: "address", internalType: "address" }
92
+ ],
93
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
94
+ stateMutability: "view"
95
+ },
96
+ {
97
+ type: "function",
98
+ name: "isCreditAccount",
99
+ inputs: [
100
+ { name: "creditAccount", type: "address", internalType: "address" }
101
+ ],
102
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
103
+ stateMutability: "view"
104
+ },
105
+ {
106
+ type: "function",
107
+ name: "isFrozen",
108
+ inputs: [
109
+ { name: "creditAccount", type: "address", internalType: "address" }
110
+ ],
111
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
112
+ stateMutability: "view"
113
+ },
114
+ {
115
+ type: "function",
116
+ name: "isInactiveCreditAccount",
117
+ inputs: [
118
+ { name: "creditAccount", type: "address", internalType: "address" }
119
+ ],
120
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
121
+ stateMutability: "view"
122
+ },
123
+ {
124
+ type: "function",
125
+ name: "multicall",
126
+ inputs: [
127
+ { name: "creditAccount", type: "address", internalType: "address" },
128
+ {
129
+ name: "calls",
130
+ type: "tuple[]",
131
+ internalType: "struct MultiCall[]",
132
+ components: [
133
+ { name: "target", type: "address", internalType: "address" },
134
+ { name: "callData", type: "bytes", internalType: "bytes" }
135
+ ]
136
+ },
137
+ {
138
+ name: "tokensToRegister",
139
+ type: "address[]",
140
+ internalType: "address[]"
141
+ }
142
+ ],
143
+ outputs: [],
144
+ stateMutability: "nonpayable"
145
+ },
146
+ {
147
+ type: "function",
148
+ name: "openCreditAccount",
149
+ inputs: [
150
+ { name: "creditManager", type: "address", internalType: "address" },
151
+ {
152
+ name: "calls",
153
+ type: "tuple[]",
154
+ internalType: "struct MultiCall[]",
155
+ components: [
156
+ { name: "target", type: "address", internalType: "address" },
157
+ { name: "callData", type: "bytes", internalType: "bytes" }
158
+ ]
159
+ },
160
+ {
161
+ name: "tokensToRegister",
162
+ type: "address[]",
163
+ internalType: "address[]"
164
+ }
165
+ ],
166
+ outputs: [
167
+ { name: "creditAccount", type: "address", internalType: "address" },
168
+ { name: "wallet", type: "address", internalType: "address" }
169
+ ],
170
+ stateMutability: "nonpayable"
171
+ },
172
+ {
173
+ type: "function",
174
+ name: "precomputeWalletAddress",
175
+ inputs: [
176
+ { name: "creditManager", type: "address", internalType: "address" },
177
+ { name: "investor", type: "address", internalType: "address" }
178
+ ],
179
+ outputs: [{ name: "", type: "address", internalType: "address" }],
180
+ stateMutability: "view"
181
+ },
182
+ {
183
+ type: "function",
184
+ name: "setFrozenStatus",
185
+ inputs: [
186
+ { name: "creditAccount", type: "address", internalType: "address" },
187
+ { name: "frozen", type: "bool", internalType: "bool" }
188
+ ],
189
+ outputs: [],
190
+ stateMutability: "nonpayable"
191
+ },
192
+ {
193
+ type: "function",
194
+ name: "setInvestor",
195
+ inputs: [
196
+ { name: "creditAccount", type: "address", internalType: "address" },
197
+ { name: "investor", type: "address", internalType: "address" }
198
+ ],
199
+ outputs: [],
200
+ stateMutability: "nonpayable"
201
+ },
202
+ {
203
+ type: "function",
204
+ name: "version",
205
+ inputs: [],
206
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
207
+ stateMutability: "view"
208
+ },
209
+ {
210
+ type: "event",
211
+ name: "CreateWallet",
212
+ inputs: [
213
+ {
214
+ name: "creditAccount",
215
+ type: "address",
216
+ indexed: true,
217
+ internalType: "address"
218
+ },
219
+ {
220
+ name: "wallet",
221
+ type: "address",
222
+ indexed: true,
223
+ internalType: "address"
224
+ },
225
+ {
226
+ name: "investor",
227
+ type: "address",
228
+ indexed: true,
229
+ internalType: "address"
230
+ }
231
+ ],
232
+ anonymous: false
233
+ },
234
+ {
235
+ type: "event",
236
+ name: "SetFrozenStatus",
237
+ inputs: [
238
+ {
239
+ name: "creditAccount",
240
+ type: "address",
241
+ indexed: true,
242
+ internalType: "address"
243
+ },
244
+ { name: "frozen", type: "bool", indexed: false, internalType: "bool" }
245
+ ],
246
+ anonymous: false
247
+ },
248
+ {
249
+ type: "event",
250
+ name: "SetInvestor",
251
+ inputs: [
252
+ {
253
+ name: "creditAccount",
254
+ type: "address",
255
+ indexed: true,
256
+ internalType: "address"
257
+ },
258
+ {
259
+ name: "oldInvestor",
260
+ type: "address",
261
+ indexed: true,
262
+ internalType: "address"
263
+ },
264
+ {
265
+ name: "newInvestor",
266
+ type: "address",
267
+ indexed: true,
268
+ internalType: "address"
269
+ }
270
+ ],
271
+ anonymous: false
272
+ },
273
+ {
274
+ type: "event",
275
+ name: "SetRegistrar",
276
+ inputs: [
277
+ {
278
+ name: "token",
279
+ type: "address",
280
+ indexed: true,
281
+ internalType: "address"
282
+ },
283
+ {
284
+ name: "registrar",
285
+ type: "address",
286
+ indexed: true,
287
+ internalType: "address"
288
+ }
289
+ ],
290
+ anonymous: false
291
+ },
292
+ {
293
+ type: "error",
294
+ name: "CallerIsNotInstanceOwnerException",
295
+ inputs: [{ name: "caller", type: "address", internalType: "address" }]
296
+ },
297
+ {
298
+ type: "error",
299
+ name: "CallerIsNotInvestorException",
300
+ inputs: [
301
+ { name: "caller", type: "address", internalType: "address" },
302
+ { name: "creditAccount", type: "address", internalType: "address" }
303
+ ]
304
+ },
305
+ {
306
+ type: "error",
307
+ name: "FrozenCreditAccountException",
308
+ inputs: [
309
+ { name: "creditAccount", type: "address", internalType: "address" }
310
+ ]
311
+ },
312
+ {
313
+ type: "error",
314
+ name: "InvalidCreditManagerException",
315
+ inputs: [
316
+ { name: "creditManager", type: "address", internalType: "address" }
317
+ ]
318
+ },
319
+ {
320
+ type: "error",
321
+ name: "InvalidUnderlyingTokenException",
322
+ inputs: [{ name: "underlying", type: "address", internalType: "address" }]
323
+ },
324
+ {
325
+ type: "error",
326
+ name: "RegistrarNotSetForTokenException",
327
+ inputs: [{ name: "token", type: "address", internalType: "address" }]
328
+ },
329
+ {
330
+ type: "error",
331
+ name: "UnknownCreditAccountException",
332
+ inputs: [
333
+ { name: "creditAccount", type: "address", internalType: "address" }
334
+ ]
335
+ },
336
+ {
337
+ type: "error",
338
+ name: "WalletCallExecutionFailedException",
339
+ inputs: [
340
+ { name: "index", type: "uint256", internalType: "uint256" },
341
+ { name: "reason", type: "bytes", internalType: "bytes" }
342
+ ]
343
+ },
344
+ { type: "error", name: "ZeroAddressException", inputs: [] }
345
+ ];
346
+ // Annotate the CommonJS export names for ESM import in node:
347
+ 0 && (module.exports = {
348
+ iSecuritizeKYCFactoryAbi
349
+ });
@@ -52,6 +52,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
52
52
  #minDebtMultiplier;
53
53
  #allowMint;
54
54
  #leverageDelta;
55
+ #poolService;
55
56
  constructor(service, options_ = {}) {
56
57
  super(service.sdk);
57
58
  const {
@@ -77,6 +78,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
77
78
  this.#poolDepositMultiplier = BigInt(poolDepositMultiplier);
78
79
  this.#minDebtMultiplier = BigInt(minDebtMultiplier);
79
80
  this.#leverageDelta = BigInt(leverageDelta);
81
+ this.#poolService = new import_sdk.PoolService(service.sdk);
80
82
  this.#logger?.info(
81
83
  {
82
84
  borrower: (0, import_accounts.privateKeyToAccount)(this.borrowerKey).address,
@@ -114,6 +116,10 @@ class AccountOpener extends import_sdk.SDKConstruct {
114
116
  },
115
117
  "opening credit accounts"
116
118
  );
119
+ await Promise.all([
120
+ this.sdk.tokensMeta.loadTokenData(),
121
+ this.sdk.marketRegister.loadZappers()
122
+ ]);
117
123
  let deposits = [];
118
124
  if (depositIntoPools) {
119
125
  try {
@@ -465,9 +471,30 @@ class AccountOpener extends import_sdk.SDKConstruct {
465
471
  this.#logger?.debug(
466
472
  `depositor balance in underlying: ${this.sdk.tokensMeta.formatBN(pool.underlying, allowance, { symbol: true })}`
467
473
  );
474
+ const tokensOut = this.#poolService.getDepositTokensOut(
475
+ address,
476
+ underlying
477
+ );
478
+ if (tokensOut.length === 0) {
479
+ throw new Error(`no tokens out found for pool ${poolName}`);
480
+ }
481
+ const tokenOut = tokensOut[0];
482
+ const metadata = this.#poolService.getDepositMetadata(
483
+ address,
484
+ underlying,
485
+ tokenOut
486
+ );
487
+ this.logger?.debug(
488
+ {
489
+ underlying,
490
+ tokenOut,
491
+ ...metadata
492
+ },
493
+ "pool deposit metadata"
494
+ );
468
495
  txHash = await this.#anvil.writeContract({
469
496
  account: depositor,
470
- address: underlying,
497
+ address: metadata.approveTarget,
471
498
  abi: import_iERC20.ierc20Abi,
472
499
  functionName: "approve",
473
500
  args: [address, allowance],
@@ -484,12 +511,21 @@ class AccountOpener extends import_sdk.SDKConstruct {
484
511
  this.#logger?.debug(
485
512
  `depositor approved underlying for pool ${poolName}: ${txHash}`
486
513
  );
514
+ const depositCall = this.#poolService.addLiquidity({
515
+ collateral: { token: underlying, balance: amount },
516
+ pool: address,
517
+ wallet: depositor.address,
518
+ meta: metadata
519
+ });
520
+ if (!depositCall) {
521
+ throw new Error(`no deposit call could be created for ${poolName}`);
522
+ }
487
523
  txHash = await this.#anvil.writeContract({
488
524
  account: depositor,
489
- address,
490
- abi: import_v300.iPoolV300Abi,
491
- functionName: "deposit",
492
- args: [amount, depositor.address],
525
+ address: depositCall.target,
526
+ abi: depositCall.abi,
527
+ functionName: depositCall.functionName,
528
+ args: depositCall.args,
493
529
  chain: this.#anvil.chain
494
530
  });
495
531
  receipt = await this.#anvil.waitForTransactionReceipt({ hash: txHash });
@@ -33,6 +33,7 @@ var import_v300 = require("../../abi/v300.js");
33
33
  var import_base = require("../base/index.js");
34
34
  var import_chains = require("../chain/chains.js");
35
35
  var import_constants = require("../constants/index.js");
36
+ var import_market = require("../market/index.js");
36
37
  var import_router = require("../router/index.js");
37
38
  var import_sdk_legacy = require("../sdk-legacy/index.js");
38
39
  var import_utils = require("../utils/index.js");
@@ -412,7 +413,12 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
412
413
  (t) => this.prepareWithdrawToken(ca.creditFacade, t, import_constants.MAX_UINT256, to)
413
414
  )
414
415
  ];
415
- const tx = operation === "close" ? cm.creditFacade.closeCreditAccount(ca.creditAccount, calls) : cm.creditFacade.multicall(ca.creditAccount, calls);
416
+ const tx = await this.closeCreditAccountTx(
417
+ cm,
418
+ ca.creditAccount,
419
+ calls,
420
+ operation
421
+ );
416
422
  return { tx, calls, routerCloseResult, creditFacade: cm.creditFacade };
417
423
  }
418
424
  /**
@@ -442,7 +448,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
442
448
  averageQuota
443
449
  })
444
450
  ];
445
- const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
451
+ const tx = await this.multicallTx(cm, creditAccount.creditAccount, calls);
446
452
  return { tx, calls, creditFacade: cm.creditFacade };
447
453
  }
448
454
  /**
@@ -484,7 +490,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
484
490
  averageQuota
485
491
  })
486
492
  ];
487
- const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
493
+ const tx = await this.multicallTx(cm, creditAccount.creditAccount, calls);
488
494
  tx.value = ethAmount.toString(10);
489
495
  return { tx, calls, creditFacade: cm.creditFacade };
490
496
  }
@@ -535,7 +541,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
535
541
  ]) : [],
536
542
  this.#prepareChangeDebt(creditAccount.creditFacade, change, isDecrease)
537
543
  ];
538
- const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
544
+ const tx = await this.multicallTx(cm, creditAccount.creditAccount, calls);
539
545
  return { tx, calls, creditFacade: cm.creditFacade };
540
546
  }
541
547
  /**
@@ -570,7 +576,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
570
576
  averageQuota
571
577
  })
572
578
  ];
573
- const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
579
+ const tx = await this.multicallTx(cm, creditAccount.creditAccount, calls);
574
580
  return { tx, calls, creditFacade: cm.creditFacade };
575
581
  }
576
582
  /**
@@ -686,7 +692,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
686
692
  averageQuota
687
693
  })
688
694
  ];
689
- const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
695
+ const tx = await this.multicallTx(cm, creditAccount.creditAccount, calls);
690
696
  return { tx, calls, creditFacade: cm.creditFacade };
691
697
  }
692
698
  /**
@@ -751,7 +757,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
751
757
  compareBalances,
752
758
  ...quotaCalls
753
759
  ];
754
- const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
760
+ const tx = await this.multicallTx(cm, creditAccount.creditAccount, calls);
755
761
  return { tx, calls, creditFacade: cm.creditFacade };
756
762
  }
757
763
  /**
@@ -778,7 +784,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
778
784
  ),
779
785
  ...this.#prepareEnableTokens(ca.creditFacade, enabledTokens)
780
786
  ];
781
- const tx = cm.creditFacade.multicall(ca.creditAccount, calls);
787
+ const tx = await this.multicallTx(cm, ca.creditAccount, calls);
782
788
  return { tx, calls, creditFacade: cm.creditFacade };
783
789
  }
784
790
  /**
@@ -835,7 +841,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
835
841
  averageQuota
836
842
  })
837
843
  ];
838
- const tx = cmSuite.creditFacade.openCreditAccount(to, calls, referralCode);
844
+ const tx = await this.openCreditAccountTx(cmSuite, to, calls, referralCode);
839
845
  tx.value = ethAmount.toString(10);
840
846
  return { calls, tx, creditFacade: cmSuite.creditFacade };
841
847
  }
@@ -1176,80 +1182,64 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
1176
1182
  import_constants.VERSION_RANGE_310
1177
1183
  )[0];
1178
1184
  }
1179
- }
1180
- const iMellowClaimerAdapterAbi = [
1181
- {
1182
- type: "function",
1183
- name: "getMultiVaultSubvaultIndices",
1184
- inputs: [{ name: "multiVault", type: "address", internalType: "address" }],
1185
- outputs: [
1186
- {
1187
- name: "subvaultIndices",
1188
- type: "uint256[]",
1189
- internalType: "uint256[]"
1190
- },
1191
- {
1192
- name: "withdrawalIndices",
1193
- type: "uint256[][]",
1194
- internalType: "uint256[][]"
1195
- }
1196
- ],
1197
- stateMutability: "view"
1198
- },
1199
- {
1200
- type: "function",
1201
- name: "getUserSubvaultIndices",
1202
- inputs: [
1203
- { name: "multiVault", type: "address", internalType: "address" },
1204
- { name: "user", type: "address", internalType: "address" }
1205
- ],
1206
- outputs: [
1207
- {
1208
- name: "subvaultIndices",
1209
- type: "uint256[]",
1210
- internalType: "uint256[]"
1211
- },
1212
- {
1213
- name: "withdrawalIndices",
1214
- type: "uint256[][]",
1215
- internalType: "uint256[][]"
1216
- }
1217
- ],
1218
- stateMutability: "view"
1219
- },
1220
- {
1221
- type: "function",
1222
- name: "multiAccept",
1223
- inputs: [
1224
- { name: "multiVault", type: "address", internalType: "address" },
1225
- {
1226
- name: "subvaultIndices",
1227
- type: "uint256[]",
1228
- internalType: "uint256[]"
1229
- },
1230
- { name: "indices", type: "uint256[][]", internalType: "uint256[][]" }
1231
- ],
1232
- outputs: [{ name: "", type: "bool", internalType: "bool" }],
1233
- stateMutability: "nonpayable"
1234
- },
1235
- {
1236
- type: "function",
1237
- name: "multiAcceptAndClaim",
1238
- inputs: [
1239
- { name: "multiVault", type: "address", internalType: "address" },
1240
- {
1241
- name: "subvaultIndices",
1242
- type: "uint256[]",
1243
- internalType: "uint256[]"
1244
- },
1245
- { name: "indices", type: "uint256[][]", internalType: "uint256[][]" },
1246
- { name: "", type: "address", internalType: "address" },
1247
- { name: "maxAssets", type: "uint256", internalType: "uint256" }
1248
- ],
1249
- outputs: [{ name: "", type: "bool", internalType: "bool" }],
1250
- stateMutability: "nonpayable"
1185
+ /**
1186
+ * Wrapper that selects between credit facade and KYC factory
1187
+ * @param suite
1188
+ * @param to
1189
+ * @param calls
1190
+ * @param referralCode
1191
+ * @returns
1192
+ */
1193
+ async openCreditAccountTx(suite, to, calls, referralCode) {
1194
+ await this.sdk.tokensMeta.loadTokenData(suite.underlying);
1195
+ const underlying = this.sdk.tokensMeta.mustGet(suite.underlying);
1196
+ if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
1197
+ const tokensToRegister = [];
1198
+ const factory = new import_market.SecuritizeKYCFactory(this.sdk, underlying.kycFactory);
1199
+ return factory.openCreditAccount(
1200
+ suite.creditManager.address,
1201
+ calls,
1202
+ tokensToRegister
1203
+ );
1204
+ }
1205
+ return suite.creditFacade.openCreditAccount(to, calls, referralCode ?? 0n);
1206
+ }
1207
+ /**
1208
+ * Wrapper that selects between credit facade and KYC factory
1209
+ * @param suite
1210
+ * @param creditAccount
1211
+ * @param calls
1212
+ * @returns
1213
+ */
1214
+ async multicallTx(suite, creditAccount, calls) {
1215
+ await this.sdk.tokensMeta.loadTokenData(suite.underlying);
1216
+ const underlying = this.sdk.tokensMeta.mustGet(suite.underlying);
1217
+ if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
1218
+ const tokensToRegister = [];
1219
+ const factory = new import_market.SecuritizeKYCFactory(this.sdk, underlying.kycFactory);
1220
+ return factory.multicall(creditAccount, calls, tokensToRegister);
1221
+ }
1222
+ return suite.creditFacade.multicall(creditAccount, calls);
1251
1223
  }
1252
- ];
1224
+ /**
1225
+ * Wrapper that selects between credit facade and KYC factory
1226
+ * @param suite
1227
+ * @param creditAccount
1228
+ * @param calls
1229
+ * @param operation
1230
+ * @returns
1231
+ */
1232
+ async closeCreditAccountTx(suite, creditAccount, calls, operation) {
1233
+ await this.sdk.tokensMeta.loadTokenData(suite.underlying);
1234
+ const underlying = this.sdk.tokensMeta.mustGet(suite.underlying);
1235
+ if (this.sdk.tokensMeta.isKYCUnderlying(underlying)) {
1236
+ throw new Error(
1237
+ "KYC underlying is not supported for close credit account"
1238
+ );
1239
+ }
1240
+ return operation === "close" ? suite.creditFacade.closeCreditAccount(creditAccount, calls) : suite.creditFacade.multicall(creditAccount, calls);
1241
+ }
1242
+ }
1253
1243
  // Annotate the CommonJS export names for ESM import in node:
1254
1244
  0 && (module.exports = {
1255
1245
  AbstractCreditAccountService,