@gearbox-protocol/sdk 13.4.0 → 13.5.0-next.1

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 (90) hide show
  1. package/dist/cjs/abi/310/iSecuritizeDegenNFT.js +263 -0
  2. package/dist/cjs/abi/310/iSecuritizeKYCFactory.js +278 -0
  3. package/dist/cjs/{sdk/pools/PoolServiceV310.js → abi/iStateSerializer.js} +14 -8
  4. package/dist/cjs/dev/AccountOpener.js +45 -5
  5. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +375 -13
  6. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +16 -5
  7. package/dist/cjs/sdk/base/ChainContractsRegister.js +1 -1
  8. package/dist/cjs/sdk/base/TokensMeta.js +255 -32
  9. package/dist/cjs/sdk/base/index.js +2 -0
  10. package/dist/cjs/sdk/{constants/phantom-tokens.js → base/token-types.js} +9 -3
  11. package/dist/cjs/sdk/chain/chains.js +2 -1
  12. package/dist/cjs/sdk/constants/index.js +0 -2
  13. package/dist/cjs/sdk/market/MarketRegister.js +5 -2
  14. package/dist/cjs/sdk/market/MarketSuite.js +6 -0
  15. package/dist/cjs/{plugins/zappers/extraZappers.js → sdk/market/ZapperRegister.js} +110 -6
  16. package/dist/cjs/sdk/market/index.js +3 -1
  17. package/dist/cjs/sdk/market/pool/PoolSuite.js +3 -0
  18. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +17 -2
  19. package/dist/cjs/sdk/market/pool/SecuritizeKYCFactory.js +97 -0
  20. package/dist/cjs/sdk/market/pool/index.js +4 -0
  21. package/dist/cjs/sdk/pools/PoolService.js +391 -0
  22. package/dist/cjs/sdk/pools/index.js +2 -4
  23. package/dist/esm/abi/310/iSecuritizeDegenNFT.js +239 -0
  24. package/dist/esm/abi/310/iSecuritizeKYCFactory.js +254 -0
  25. package/dist/esm/abi/iStateSerializer.js +12 -0
  26. package/dist/esm/dev/AccountOpener.js +47 -6
  27. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +375 -13
  28. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +16 -5
  29. package/dist/esm/sdk/base/ChainContractsRegister.js +1 -1
  30. package/dist/esm/sdk/base/TokensMeta.js +261 -32
  31. package/dist/esm/sdk/base/index.js +1 -0
  32. package/dist/esm/sdk/{constants/phantom-tokens.js → base/token-types.js} +4 -0
  33. package/dist/esm/sdk/chain/chains.js +2 -1
  34. package/dist/esm/sdk/constants/index.js +0 -1
  35. package/dist/esm/sdk/market/MarketRegister.js +5 -2
  36. package/dist/esm/sdk/market/MarketSuite.js +6 -0
  37. package/dist/esm/{plugins/zappers/extraZappers.js → sdk/market/ZapperRegister.js} +109 -2
  38. package/dist/esm/sdk/market/index.js +1 -0
  39. package/dist/esm/sdk/market/pool/PoolSuite.js +3 -0
  40. package/dist/esm/sdk/market/pool/PoolV310Contract.js +17 -2
  41. package/dist/esm/sdk/market/pool/SecuritizeKYCFactory.js +73 -0
  42. package/dist/esm/sdk/market/pool/index.js +2 -0
  43. package/dist/esm/sdk/pools/PoolService.js +371 -0
  44. package/dist/esm/sdk/pools/index.js +1 -2
  45. package/dist/types/abi/310/iSecuritizeDegenNFT.d.ts +324 -0
  46. package/dist/types/abi/310/iSecuritizeKYCFactory.d.ts +322 -0
  47. package/dist/types/abi/iStateSerializer.d.ts +11 -0
  48. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +114 -3
  49. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
  50. package/dist/types/sdk/accounts/types.d.ts +96 -6
  51. package/dist/types/sdk/base/TokensMeta.d.ts +34 -21
  52. package/dist/types/sdk/base/index.d.ts +1 -0
  53. package/dist/types/sdk/base/token-types.d.ts +33 -0
  54. package/dist/types/sdk/base/types.d.ts +0 -7
  55. package/dist/types/sdk/chain/chains.d.ts +1 -1
  56. package/dist/types/sdk/constants/index.d.ts +0 -1
  57. package/dist/types/sdk/market/MarketRegister.d.ts +2 -2
  58. package/dist/types/sdk/market/MarketSuite.d.ts +3 -0
  59. package/dist/types/sdk/market/ZapperRegister.d.ts +17 -0
  60. package/dist/types/sdk/market/index.d.ts +1 -0
  61. package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -0
  62. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +6 -2
  63. package/dist/types/sdk/market/pool/SecuritizeKYCFactory.d.ts +345 -0
  64. package/dist/types/sdk/market/pool/index.d.ts +2 -0
  65. package/dist/types/sdk/market/types.d.ts +10 -0
  66. package/dist/types/sdk/pools/PoolService.d.ts +14 -0
  67. package/dist/types/sdk/pools/index.d.ts +1 -2
  68. package/dist/types/sdk/pools/types.d.ts +85 -111
  69. package/package.json +1 -1
  70. package/dist/cjs/plugins/zappers/ZappersPlugin.js +0 -144
  71. package/dist/cjs/plugins/zappers/index.js +0 -26
  72. package/dist/cjs/plugins/zappers/package.json +0 -1
  73. package/dist/cjs/sdk/pools/AbstractPoolService.js +0 -143
  74. package/dist/cjs/sdk/pools/createPoolService.js +0 -35
  75. package/dist/esm/plugins/zappers/ZappersPlugin.js +0 -126
  76. package/dist/esm/plugins/zappers/index.js +0 -3
  77. package/dist/esm/plugins/zappers/package.json +0 -1
  78. package/dist/esm/sdk/pools/AbstractPoolService.js +0 -119
  79. package/dist/esm/sdk/pools/PoolServiceV310.js +0 -6
  80. package/dist/esm/sdk/pools/createPoolService.js +0 -11
  81. package/dist/types/plugins/zappers/ZappersPlugin.d.ts +0 -18
  82. package/dist/types/plugins/zappers/extraZappers.d.ts +0 -6
  83. package/dist/types/plugins/zappers/index.d.ts +0 -3
  84. package/dist/types/plugins/zappers/types.d.ts +0 -12
  85. package/dist/types/sdk/constants/phantom-tokens.d.ts +0 -2
  86. package/dist/types/sdk/pools/AbstractPoolService.d.ts +0 -21
  87. package/dist/types/sdk/pools/PoolServiceV310.d.ts +0 -4
  88. package/dist/types/sdk/pools/createPoolService.d.ts +0 -3
  89. /package/dist/cjs/{plugins/zappers → sdk/market}/types.js +0 -0
  90. /package/dist/esm/{plugins/zappers → sdk/market}/types.js +0 -0
@@ -0,0 +1,322 @@
1
+ export declare const iSecuritizeKYCFactoryAbi: readonly [{
2
+ readonly type: "function";
3
+ readonly name: "contractType";
4
+ readonly inputs: readonly [];
5
+ readonly outputs: readonly [{
6
+ readonly name: "";
7
+ readonly type: "bytes32";
8
+ readonly internalType: "bytes32";
9
+ }];
10
+ readonly stateMutability: "view";
11
+ }, {
12
+ readonly type: "function";
13
+ readonly name: "getCreditAccounts";
14
+ readonly inputs: readonly [{
15
+ readonly name: "investor";
16
+ readonly type: "address";
17
+ readonly internalType: "address";
18
+ }];
19
+ readonly outputs: readonly [{
20
+ readonly name: "";
21
+ readonly type: "address[]";
22
+ readonly internalType: "address[]";
23
+ }];
24
+ readonly stateMutability: "view";
25
+ }, {
26
+ readonly type: "function";
27
+ readonly name: "getDegenNFT";
28
+ readonly inputs: readonly [];
29
+ readonly outputs: readonly [{
30
+ readonly name: "";
31
+ readonly type: "address";
32
+ readonly internalType: "address";
33
+ }];
34
+ readonly stateMutability: "view";
35
+ }, {
36
+ readonly type: "function";
37
+ readonly name: "getInvestor";
38
+ readonly inputs: readonly [{
39
+ readonly name: "creditAccount";
40
+ readonly type: "address";
41
+ readonly internalType: "address";
42
+ }];
43
+ readonly outputs: readonly [{
44
+ readonly name: "";
45
+ readonly type: "address";
46
+ readonly internalType: "address";
47
+ }];
48
+ readonly stateMutability: "view";
49
+ }, {
50
+ readonly type: "function";
51
+ readonly name: "getWallet";
52
+ readonly inputs: readonly [{
53
+ readonly name: "creditAccount";
54
+ readonly type: "address";
55
+ readonly internalType: "address";
56
+ }];
57
+ readonly outputs: readonly [{
58
+ readonly name: "";
59
+ readonly type: "address";
60
+ readonly internalType: "address";
61
+ }];
62
+ readonly stateMutability: "view";
63
+ }, {
64
+ readonly type: "function";
65
+ readonly name: "isCreditAccount";
66
+ readonly inputs: readonly [{
67
+ readonly name: "creditAccount";
68
+ readonly type: "address";
69
+ readonly internalType: "address";
70
+ }];
71
+ readonly outputs: readonly [{
72
+ readonly name: "";
73
+ readonly type: "bool";
74
+ readonly internalType: "bool";
75
+ }];
76
+ readonly stateMutability: "view";
77
+ }, {
78
+ readonly type: "function";
79
+ readonly name: "isFrozen";
80
+ readonly inputs: readonly [{
81
+ readonly name: "creditAccount";
82
+ readonly type: "address";
83
+ readonly internalType: "address";
84
+ }];
85
+ readonly outputs: readonly [{
86
+ readonly name: "";
87
+ readonly type: "bool";
88
+ readonly internalType: "bool";
89
+ }];
90
+ readonly stateMutability: "view";
91
+ }, {
92
+ readonly type: "function";
93
+ readonly name: "multicall";
94
+ readonly inputs: readonly [{
95
+ readonly name: "creditAccount";
96
+ readonly type: "address";
97
+ readonly internalType: "address";
98
+ }, {
99
+ readonly name: "calls";
100
+ readonly type: "tuple[]";
101
+ readonly internalType: "struct MultiCall[]";
102
+ readonly components: readonly [{
103
+ readonly name: "target";
104
+ readonly type: "address";
105
+ readonly internalType: "address";
106
+ }, {
107
+ readonly name: "callData";
108
+ readonly type: "bytes";
109
+ readonly internalType: "bytes";
110
+ }];
111
+ }, {
112
+ readonly name: "tokensToRegister";
113
+ readonly type: "address[]";
114
+ readonly internalType: "address[]";
115
+ }];
116
+ readonly outputs: readonly [];
117
+ readonly stateMutability: "nonpayable";
118
+ }, {
119
+ readonly type: "function";
120
+ readonly name: "openCreditAccount";
121
+ readonly inputs: readonly [{
122
+ readonly name: "creditManager";
123
+ readonly type: "address";
124
+ readonly internalType: "address";
125
+ }, {
126
+ readonly name: "calls";
127
+ readonly type: "tuple[]";
128
+ readonly internalType: "struct MultiCall[]";
129
+ readonly components: readonly [{
130
+ readonly name: "target";
131
+ readonly type: "address";
132
+ readonly internalType: "address";
133
+ }, {
134
+ readonly name: "callData";
135
+ readonly type: "bytes";
136
+ readonly internalType: "bytes";
137
+ }];
138
+ }, {
139
+ readonly name: "tokensToRegister";
140
+ readonly type: "address[]";
141
+ readonly internalType: "address[]";
142
+ }];
143
+ readonly outputs: readonly [{
144
+ readonly name: "creditAccount";
145
+ readonly type: "address";
146
+ readonly internalType: "address";
147
+ }, {
148
+ readonly name: "wallet";
149
+ readonly type: "address";
150
+ readonly internalType: "address";
151
+ }];
152
+ readonly stateMutability: "nonpayable";
153
+ }, {
154
+ readonly type: "function";
155
+ readonly name: "precomputeWalletAddress";
156
+ readonly inputs: readonly [{
157
+ readonly name: "creditManager";
158
+ readonly type: "address";
159
+ readonly internalType: "address";
160
+ }, {
161
+ readonly name: "investor";
162
+ readonly type: "address";
163
+ readonly internalType: "address";
164
+ }];
165
+ readonly outputs: readonly [{
166
+ readonly name: "";
167
+ readonly type: "address";
168
+ readonly internalType: "address";
169
+ }];
170
+ readonly stateMutability: "view";
171
+ }, {
172
+ readonly type: "function";
173
+ readonly name: "serialize";
174
+ readonly inputs: readonly [];
175
+ readonly outputs: readonly [{
176
+ readonly name: "serializedData";
177
+ readonly type: "bytes";
178
+ readonly internalType: "bytes";
179
+ }];
180
+ readonly stateMutability: "view";
181
+ }, {
182
+ readonly type: "function";
183
+ readonly name: "setFrozenStatus";
184
+ readonly inputs: readonly [{
185
+ readonly name: "creditAccount";
186
+ readonly type: "address";
187
+ readonly internalType: "address";
188
+ }, {
189
+ readonly name: "frozen";
190
+ readonly type: "bool";
191
+ readonly internalType: "bool";
192
+ }];
193
+ readonly outputs: readonly [];
194
+ readonly stateMutability: "nonpayable";
195
+ }, {
196
+ readonly type: "function";
197
+ readonly name: "setInvestor";
198
+ readonly inputs: readonly [{
199
+ readonly name: "creditAccount";
200
+ readonly type: "address";
201
+ readonly internalType: "address";
202
+ }, {
203
+ readonly name: "investor";
204
+ readonly type: "address";
205
+ readonly internalType: "address";
206
+ }];
207
+ readonly outputs: readonly [];
208
+ readonly stateMutability: "nonpayable";
209
+ }, {
210
+ readonly type: "function";
211
+ readonly name: "version";
212
+ readonly inputs: readonly [];
213
+ readonly outputs: readonly [{
214
+ readonly name: "";
215
+ readonly type: "uint256";
216
+ readonly internalType: "uint256";
217
+ }];
218
+ readonly stateMutability: "view";
219
+ }, {
220
+ readonly type: "event";
221
+ readonly name: "CreateWallet";
222
+ readonly inputs: readonly [{
223
+ readonly name: "creditAccount";
224
+ readonly type: "address";
225
+ readonly indexed: true;
226
+ readonly internalType: "address";
227
+ }, {
228
+ readonly name: "wallet";
229
+ readonly type: "address";
230
+ readonly indexed: true;
231
+ readonly internalType: "address";
232
+ }, {
233
+ readonly name: "investor";
234
+ readonly type: "address";
235
+ readonly indexed: true;
236
+ readonly internalType: "address";
237
+ }];
238
+ readonly anonymous: false;
239
+ }, {
240
+ readonly type: "event";
241
+ readonly name: "SetFrozenStatus";
242
+ readonly inputs: readonly [{
243
+ readonly name: "creditAccount";
244
+ readonly type: "address";
245
+ readonly indexed: true;
246
+ readonly internalType: "address";
247
+ }, {
248
+ readonly name: "frozen";
249
+ readonly type: "bool";
250
+ readonly indexed: false;
251
+ readonly internalType: "bool";
252
+ }];
253
+ readonly anonymous: false;
254
+ }, {
255
+ readonly type: "event";
256
+ readonly name: "SetInvestor";
257
+ readonly inputs: readonly [{
258
+ readonly name: "creditAccount";
259
+ readonly type: "address";
260
+ readonly indexed: true;
261
+ readonly internalType: "address";
262
+ }, {
263
+ readonly name: "oldInvestor";
264
+ readonly type: "address";
265
+ readonly indexed: true;
266
+ readonly internalType: "address";
267
+ }, {
268
+ readonly name: "newInvestor";
269
+ readonly type: "address";
270
+ readonly indexed: true;
271
+ readonly internalType: "address";
272
+ }];
273
+ readonly anonymous: false;
274
+ }, {
275
+ readonly type: "error";
276
+ readonly name: "CallerIsNotInvestorException";
277
+ readonly inputs: readonly [{
278
+ readonly name: "caller";
279
+ readonly type: "address";
280
+ readonly internalType: "address";
281
+ }, {
282
+ readonly name: "creditAccount";
283
+ readonly type: "address";
284
+ readonly internalType: "address";
285
+ }];
286
+ }, {
287
+ readonly type: "error";
288
+ readonly name: "FrozenCreditAccountException";
289
+ readonly inputs: readonly [{
290
+ readonly name: "creditAccount";
291
+ readonly type: "address";
292
+ readonly internalType: "address";
293
+ }];
294
+ }, {
295
+ readonly type: "error";
296
+ readonly name: "InvalidCreditManagerException";
297
+ readonly inputs: readonly [{
298
+ readonly name: "creditManager";
299
+ readonly type: "address";
300
+ readonly internalType: "address";
301
+ }];
302
+ }, {
303
+ readonly type: "error";
304
+ readonly name: "InvalidUnderlyingTokenException";
305
+ readonly inputs: readonly [{
306
+ readonly name: "underlying";
307
+ readonly type: "address";
308
+ readonly internalType: "address";
309
+ }];
310
+ }, {
311
+ readonly type: "error";
312
+ readonly name: "UnknownCreditAccountException";
313
+ readonly inputs: readonly [{
314
+ readonly name: "creditAccount";
315
+ readonly type: "address";
316
+ readonly internalType: "address";
317
+ }];
318
+ }, {
319
+ readonly type: "error";
320
+ readonly name: "ZeroAddressException";
321
+ readonly inputs: readonly [];
322
+ }];
@@ -0,0 +1,11 @@
1
+ export declare const iStateSerializerAbi: readonly [{
2
+ readonly type: "function";
3
+ readonly inputs: readonly [];
4
+ readonly name: "serialize";
5
+ readonly outputs: readonly [{
6
+ readonly name: "serializedData";
7
+ readonly internalType: "bytes";
8
+ readonly type: "bytes";
9
+ }];
10
+ readonly stateMutability: "view";
11
+ }];
@@ -2,10 +2,11 @@ import type { Address } from "viem";
2
2
  import type { CreditAccountData } from "../base/index.js";
3
3
  import { SDKConstruct } from "../base/index.js";
4
4
  import type { GearboxSDK } from "../GearboxSDK.js";
5
+ import type { CreditSuite, MarketSuite } from "../market/index.js";
5
6
  import { type PriceUpdate, type UpdatePriceFeedsResult } from "../market/index.js";
6
7
  import { type Asset, type RouterCASlice } from "../router/index.js";
7
- import type { MultiCall, RawTx } from "../types/index.js";
8
- import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
8
+ import type { IPriceUpdateTx, MultiCall, RawTx } from "../types/index.js";
9
+ import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CloseOptions, CreditAccountDataWithInvestor, CreditAccountOperationResult, CreditAccountTokensSlice, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
9
10
  /**
10
11
  * Options for configuring the credit account service.
11
12
  **/
@@ -32,10 +33,42 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
32
33
  * {@inheritDoc ICreditAccountsService.getCreditAccountData}
33
34
  **/
34
35
  getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData | undefined>;
36
+ /**
37
+ * Returns credit account data for a single account with the investor address resolved.
38
+ * Loads CA via getCreditAccountData; for KYC underlyings fetches the investor from the KYC factory's getInvestor(creditAccount), otherwise uses the account owner.
39
+ * @param account - Credit account address
40
+ * @param blockNumber - Optional block number for the read
41
+ * @returns CreditAccountDataWithInvestor (CA data + investor address), or undefined if the account is not found
42
+ */
43
+ getCreditAccountDataWithInvestor(account: Address, blockNumber?: bigint): Promise<CreditAccountDataWithInvestor | undefined>;
35
44
  /**
36
45
  * {@inheritDoc ICreditAccountsService.getCreditAccounts}
37
46
  **/
38
47
  getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
48
+ /**
49
+ * Returns all credit accounts matching the filter, with investor set on each item.
50
+ * Delegates to getCreditAccounts; when options.owner is set, also loads KYC credit accounts for that owner and merges them into the list. Result is sorted by health factor ascending.
51
+ * @param options - Filter options (owner, creditManager, health factor, etc.)
52
+ * @param blockNumber - Optional block number for the read
53
+ * @returns Array of credit accounts (with investor field), sorted by health factor ascending
54
+ */
55
+ getCreditAccountsWithInvestor(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountDataWithInvestor>>;
56
+ protected getKYCCreditAccountsOfOwner(owner: Address, priceUpdateTxs: IPriceUpdateTx<{
57
+ priceFeed: `0x${string}`;
58
+ timestamp: number;
59
+ }>[], blockNumber?: bigint): Promise<Array<CreditAccountDataWithInvestor>>;
60
+ /**
61
+ * Loads credit account data for the given addresses using simulateWithPriceUpdates.
62
+ * Applies the provided price update txs before reading, so returned data is consistent with up-to-date prices.
63
+ * @param accounts - Credit account addresses to load
64
+ * @param priceUpdateTxs - Price feed update txs to simulate before the read (e.g. from generatePriceFeedsUpdateTxs)
65
+ * @param blockNumber - Optional block number for the read
66
+ * @returns Array of CreditAccountData in the same order as accounts (throws if any getCreditAccountData call reverts)
67
+ */
68
+ loadSpecifiedAccounts(accounts: Address[], priceUpdateTxs: IPriceUpdateTx<{
69
+ priceFeed: `0x${string}`;
70
+ timestamp: number;
71
+ }>[], blockNumber?: bigint): Promise<Array<CreditAccountData>>;
39
72
  /**
40
73
  * {@inheritDoc ICreditAccountsService.getRewards}
41
74
  **/
@@ -69,7 +102,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
69
102
  /**
70
103
  * {@inheritDoc ICreditAccountsService.changeDebt}
71
104
  **/
72
- changeDebt({ creditAccount, amount, addCollateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
105
+ changeDebt({ creditAccount, amount, collateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
73
106
  /**
74
107
  * {@inheritDoc ICreditAccountsService.executeSwap}
75
108
  **/
@@ -90,6 +123,13 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
90
123
  * {@inheritDoc ICreditAccountsService.claimDelayed}
91
124
  **/
92
125
  claimDelayed({ creditAccount, minQuota, averageQuota, claimableNow, }: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
126
+ /**
127
+ * Returns address to which approval should be given on collateral token
128
+ * It's credit manager for classical markets and special wallet for KYC markets
129
+ * @param options - {@link GetApprovalAddressProps}
130
+ * @returns
131
+ **/
132
+ getApprovalAddress(options: GetApprovalAddressProps): Promise<Address>;
93
133
  /**
94
134
  * {@inheritDoc ICreditAccountsService.openCA}
95
135
  **/
@@ -103,6 +143,43 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
103
143
  **/
104
144
  getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
105
145
  /**
146
+ * Returns multicall entries to redeem (unwrap) KYC ERC-4626 vault shares into underlying for the given credit manager.
147
+ * Used when withdrawing debt from a KYC market: redeems adapter vault shares so the underlying can be withdrawn.
148
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
149
+ * @param amount - Number of vault shares (adapter tokens) to redeem
150
+ * @param creditManager - Credit manager address
151
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
152
+ */
153
+ getKYCUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
154
+ /**
155
+ * Returns multicall entries to deposit (wrap) underlying into KYC ERC-4626 vault shares for the given credit manager.
156
+ * Used when adding debt on a KYC market: deposits underlying into the adapter vault so shares are minted on the account.
157
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
158
+ * @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
159
+ * @param creditManager - Credit manager address
160
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
161
+ */
162
+ getKYCWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
163
+ /**
164
+ * Returns multicall entries to call redeemDiff on the KYC ERC-4626 adapter for the given credit manager.
165
+ * Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess KYC vault tokens.
166
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
167
+ * @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
168
+ * @param creditManager - Credit manager address
169
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
170
+ */
171
+ getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
172
+ /**
173
+ * Returns multicall entries to call depositDiff on the KYC ERC-4626 adapter for the given credit manager.
174
+ * Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
175
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
176
+ * @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
177
+ * @param creditManager - Credit manager address
178
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
179
+ */
180
+ getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
181
+ /**
182
+ * Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
106
183
  * {@inheritDoc ICreditAccountsService.getOnDemandPriceUpdates}
107
184
  **/
108
185
  getOnDemandPriceUpdates(account: CreditAccountTokensSlice, ignoreReservePrices?: boolean): Promise<PriceUpdate[]>;
@@ -157,4 +234,38 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
157
234
  private get marketConfigurators();
158
235
  private get rewardCompressor();
159
236
  private get peripheryCompressor();
237
+ /**
238
+ * Wrapper that selects between credit facade and KYC factory
239
+ * @param suite
240
+ * @param to
241
+ * @param calls
242
+ * @param referralCode
243
+ * @returns
244
+ */
245
+ protected openCreditAccountTx(suite: CreditSuite, to: Address, calls: MultiCall[], referralCode?: bigint): Promise<RawTx>;
246
+ /**
247
+ * Wrapper that selects between credit facade and KYC factory
248
+ * @param suite
249
+ * @param creditAccount
250
+ * @param calls
251
+ * @returns
252
+ */
253
+ protected multicallTx(suite: CreditSuite, creditAccount: Address, calls: MultiCall[]): Promise<RawTx>;
254
+ /**
255
+ * Wrapper that selects between credit facade and KYC factory
256
+ * @param suite
257
+ * @param creditAccount
258
+ * @param calls
259
+ * @param operation
260
+ * @returns
261
+ */
262
+ protected closeCreditAccountTx(suite: CreditSuite, creditAccount: Address, calls: MultiCall[], operation: CloseOptions): Promise<RawTx>;
263
+ /**
264
+ * Returns all KYC credit account addresses for an investor across the given market suites.
265
+ * Resolves KYC factory per suite, then multicalls each factory's getCreditAccounts(investor).
266
+ * @param investor - Owner address to query
267
+ * @param suites - Market suites (KYC factories are resolved for each; undefined entries are skipped)
268
+ * @returns Flat array of credit account addresses from all KYC markets
269
+ */
270
+ protected getKYCCaOfInvestor(investor: Address, suites: Array<MarketSuite | undefined>): Promise<`0x${string}`[]>;
160
271
  }
@@ -21,7 +21,7 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
21
21
  /**
22
22
  * {@inheritDoc ICreditAccountsService.repayCreditAccount}
23
23
  */
24
- repayCreditAccount({ operation, collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim, }: RepayCreditAccountProps): Promise<CreditAccountOperationResult>;
24
+ repayCreditAccount({ operation, collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim, calls: wrapCalls, }: RepayCreditAccountProps): Promise<CreditAccountOperationResult>;
25
25
  /**
26
26
  * {@inheritDoc ICreditAccountsService.repayAndLiquidateCreditAccount}
27
27
  */
@@ -5,7 +5,7 @@ import type { ConnectedBotData, Construct, CreditAccountData } from "../base/ind
5
5
  import type { GearboxSDK } from "../GearboxSDK.js";
6
6
  import type { CreditSuite, PriceUpdate } from "../market/index.js";
7
7
  import type { Asset, RouterCASlice, RouterCloseResult } from "../router/index.js";
8
- import type { MultiCall, RawTx } from "../types/index.js";
8
+ import type { IPriceUpdateTx, MultiCall, RawTx } from "../types/index.js";
9
9
  /**
10
10
  * @internal
11
11
  * Arguments tuple for the credit account compressor's `getCreditAccounts` view method.
@@ -182,6 +182,10 @@ export interface CloseCreditAccountProps {
182
182
  closePath?: RouterCloseResult;
183
183
  }
184
184
  export interface RepayCreditAccountProps extends RepayAndLiquidateCreditAccountProps {
185
+ /**
186
+ * Swap calls for repay
187
+ */
188
+ calls?: Array<MultiCall>;
185
189
  /**
186
190
  * close or zeroDebt
187
191
  */
@@ -436,9 +440,13 @@ export interface ChangeDeptProps {
436
440
  */
437
441
  amount: bigint;
438
442
  /**
439
- * If true, will add collateral to the credit account
443
+ * Assets to add as collateral
444
+ */
445
+ collateral?: [Asset];
446
+ /**
447
+ * Assets to wrap
440
448
  */
441
- addCollateral: boolean;
449
+ wrapAsset?: [Asset];
442
450
  }
443
451
  export interface FullyLiquidateProps {
444
452
  /**
@@ -614,6 +622,19 @@ export interface LlamathenaProportionalWithdrawProps extends PrepareUpdateQuotas
614
622
  */
615
623
  creditAccount: RouterCASlice;
616
624
  }
625
+ /**
626
+ * Options to get approval address for collateral token
627
+ */
628
+ export type GetApprovalAddressProps = {
629
+ creditManager: Address;
630
+ borrower: Address;
631
+ } | {
632
+ creditManager: Address;
633
+ creditAccount: Address;
634
+ };
635
+ export type CreditAccountDataWithInvestor = CreditAccountData & {
636
+ investor: Address;
637
+ };
617
638
  export interface ICreditAccountsService extends Construct {
618
639
  sdk: GearboxSDK;
619
640
  /**
@@ -624,15 +645,41 @@ export interface ICreditAccountsService extends Construct {
624
645
  * @returns
625
646
  */
626
647
  getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData | undefined>;
648
+ /**
649
+ * Returns credit account data for a single account with the investor address resolved (from KYC factory when applicable).
650
+ * @param account - Credit account address
651
+ * @param blockNumber - Optional block number for the read
652
+ * @returns CreditAccountDataWithInvestor, or undefined if the account is not found
653
+ */
654
+ getCreditAccountDataWithInvestor(account: Address, blockNumber?: bigint): Promise<CreditAccountDataWithInvestor | undefined>;
627
655
  /**
628
656
  * Methods to get all credit accounts with some optional filtering
629
657
  * Performs all necessary price feed updates under the hood
630
658
  *
631
659
  * @param options
632
660
  * @param blockNumber
633
- * @returns returned credit accounts are sorted by health factor in ascending order
661
+ * @param priceUpdate - Optional pre-computed price feed update (e.g. from generatePriceFeedsUpdateTxs)
662
+ * @returns Credit accounts sorted by health factor ascending
634
663
  */
635
664
  getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
665
+ /**
666
+ * Returns all credit accounts matching the filter with investor set on each; when options.owner is set, includes KYC CAs for that owner.
667
+ * @param options - Filter options (owner, creditManager, health factor, etc.)
668
+ * @param blockNumber - Optional block number for the read
669
+ * @returns Credit accounts (with investor) sorted by health factor ascending
670
+ */
671
+ getCreditAccountsWithInvestor(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountDataWithInvestor>>;
672
+ /**
673
+ * Loads credit account data for the given addresses using simulateWithPriceUpdates (with price updates applied before the read).
674
+ * @param accounts - Credit account addresses to load
675
+ * @param priceUpdateTxs - Price feed update txs to simulate before the read (e.g. from generatePriceFeedsUpdateTxs)
676
+ * @param blockNumber - Optional block number for the read
677
+ * @returns Array of CreditAccountData in the same order as accounts
678
+ */
679
+ loadSpecifiedAccounts(accounts: Address[], priceUpdateTxs: IPriceUpdateTx<{
680
+ priceFeed: `0x${string}`;
681
+ timestamp: number;
682
+ }>[], blockNumber?: bigint): Promise<Array<CreditAccountData>>;
636
683
  /**
637
684
  * Method to get all claimable rewards for credit account (ex. stkUSDS SKY rewards).
638
685
  * Associates rewards by adapter + stakedPhantomToken.
@@ -661,9 +708,9 @@ export interface ICreditAccountsService extends Construct {
661
708
  /**
662
709
  * Generates transaction to liquidate credit account
663
710
  * @param props - {@link FullyLiquidateProps}
664
- * @returns
711
+ * @returns Transaction data and optional loss policy data
665
712
  */
666
- fullyLiquidate(props: FullyLiquidateProps): Promise<CloseCreditAccountResult>;
713
+ fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
667
714
  /**
668
715
  * Closes credit account or closes credit account and keeps it open with zero debt.
669
716
  * - Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
@@ -726,6 +773,13 @@ export interface ICreditAccountsService extends Construct {
726
773
  * @returns
727
774
  */
728
775
  claimDelayed(props: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
776
+ /**
777
+ * Returns address to which approval should be given on collateral token
778
+ * It's credit manager for classical markets and special wallet for KYC markets
779
+ * @param props - {@link GetApprovalAddressProps}
780
+ * @returns
781
+ */
782
+ getApprovalAddress(props: GetApprovalAddressProps): Promise<Address>;
729
783
  /**
730
784
  * Executes swap specified by given calls, update quotas of affected tokens
731
785
  * - Open credit account is executed in the following order: price update -> increase debt -> add collateral ->
@@ -781,6 +835,42 @@ export interface ICreditAccountsService extends Construct {
781
835
  botMulticall(creditAccount: RouterCASlice, calls: Array<MultiCall>, options?: {
782
836
  ignoreReservePrices?: boolean;
783
837
  }): Promise<RawTx>;
838
+ /**
839
+ * Returns multicall entries to redeem (unwrap) KYC ERC-4626 vault shares into underlying for the given credit manager.
840
+ * Used when withdrawing debt from a KYC market: redeems adapter vault shares so the underlying can be withdrawn.
841
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
842
+ * @param amount - Number of vault shares (adapter tokens) to redeem
843
+ * @param creditManager - Credit manager address
844
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
845
+ */
846
+ getKYCUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
847
+ /**
848
+ * Returns multicall entries to deposit (wrap) underlying into KYC ERC-4626 vault shares for the given credit manager.
849
+ * Used when adding debt on a KYC market: deposits underlying into the adapter vault so shares are minted on the account.
850
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
851
+ * @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
852
+ * @param creditManager - Credit manager address
853
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
854
+ */
855
+ getKYCWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
856
+ /**
857
+ * Returns multicall entries to call redeemDiff on the KYC ERC-4626 adapter for the given credit manager.
858
+ * Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess KYC vault tokens.
859
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
860
+ * @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
861
+ * @param creditManager - Credit manager address
862
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
863
+ */
864
+ getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
865
+ /**
866
+ * Returns multicall entries to call depositDiff on the KYC ERC-4626 adapter for the given credit manager.
867
+ * Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
868
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
869
+ * @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
870
+ * @param creditManager - Credit manager address
871
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
872
+ */
873
+ getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
784
874
  /**
785
875
  * Withdraws a single collateral from credit account to wallet to and updates quotas;
786
876
  * technically can withdraw several tokens at once