@gearbox-protocol/sdk 14.12.0-next.73 → 14.12.0-next.75

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 (91) hide show
  1. package/dist/cjs/dev/AccountOpener.js +2 -5
  2. package/dist/cjs/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
  3. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +118 -974
  4. package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +280 -0
  5. package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.js +141 -0
  6. package/dist/cjs/sdk/accounts/credit-account-compressor/index.js +6 -0
  7. package/dist/cjs/sdk/accounts/credit-account-compressor/types.js +1 -0
  8. package/dist/cjs/sdk/accounts/index.js +5 -4
  9. package/dist/cjs/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +1 -1
  10. package/dist/cjs/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +1 -1
  11. package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +2 -2
  12. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +3 -3
  13. package/dist/cjs/sdk/accounts/liquidations/constants.js +0 -2
  14. package/dist/cjs/sdk/accounts/liquidations/index.js +0 -2
  15. package/dist/cjs/sdk/constants/index.js +1 -0
  16. package/dist/cjs/sdk/constants/math.js +5 -0
  17. package/dist/cjs/sdk/index.js +12 -4
  18. package/dist/cjs/sdk/market/MarketRegister.js +10 -0
  19. package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +181 -0
  20. package/dist/cjs/sdk/market/credit/CreditSuite.js +107 -1
  21. package/dist/cjs/sdk/{accounts → market/credit}/dominantCollateral.js +18 -4
  22. package/dist/cjs/sdk/market/credit/index.js +3 -0
  23. package/dist/cjs/sdk/market/index.js +3 -0
  24. package/dist/cjs/sdk/market/math.js +59 -0
  25. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +41 -1
  26. package/dist/cjs/sdk/market/oracle/PriceOracleV310Contract.js +0 -30
  27. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +1 -1
  28. package/dist/cjs/sdk/opportunities/index.js +4 -0
  29. package/dist/esm/dev/AccountOpener.js +2 -5
  30. package/dist/esm/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
  31. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +121 -977
  32. package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +279 -0
  33. package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.js +141 -0
  34. package/dist/esm/sdk/accounts/credit-account-compressor/index.js +4 -0
  35. package/dist/esm/sdk/accounts/credit-account-compressor/types.js +1 -0
  36. package/dist/esm/sdk/accounts/index.js +4 -3
  37. package/dist/esm/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +1 -1
  38. package/dist/esm/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +1 -1
  39. package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +2 -2
  40. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +2 -2
  41. package/dist/esm/sdk/accounts/liquidations/constants.js +1 -2
  42. package/dist/esm/sdk/accounts/liquidations/index.js +1 -2
  43. package/dist/esm/sdk/constants/index.js +2 -2
  44. package/dist/esm/sdk/constants/math.js +5 -1
  45. package/dist/esm/sdk/index.js +6 -5
  46. package/dist/esm/sdk/market/MarketRegister.js +10 -0
  47. package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +181 -0
  48. package/dist/esm/sdk/market/credit/CreditSuite.js +108 -2
  49. package/dist/esm/sdk/{accounts → market/credit}/dominantCollateral.js +18 -5
  50. package/dist/esm/sdk/market/credit/index.js +2 -1
  51. package/dist/esm/sdk/market/index.js +2 -1
  52. package/dist/esm/sdk/market/math.js +56 -1
  53. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +41 -1
  54. package/dist/esm/sdk/market/oracle/PriceOracleV310Contract.js +1 -31
  55. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +1 -1
  56. package/dist/esm/sdk/opportunities/index.js +2 -2
  57. package/dist/types/plugins/accounts/AccountsPlugin.d.ts +1 -1
  58. package/dist/types/sdk/OnchainSDK.d.ts +1 -1
  59. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +23 -124
  60. package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressor.d.ts +60 -0
  61. package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.d.ts +879 -0
  62. package/dist/types/sdk/accounts/credit-account-compressor/index.d.ts +4 -0
  63. package/dist/types/sdk/accounts/credit-account-compressor/types.d.ts +164 -0
  64. package/dist/types/sdk/accounts/index.d.ts +7 -5
  65. package/dist/types/sdk/accounts/liquidations/constants.d.ts +1 -2
  66. package/dist/types/sdk/accounts/liquidations/index.d.ts +1 -2
  67. package/dist/types/sdk/accounts/types.d.ts +46 -457
  68. package/dist/types/sdk/base/index.d.ts +2 -2
  69. package/dist/types/sdk/base/types.d.ts +6 -1
  70. package/dist/types/sdk/constants/index.d.ts +2 -2
  71. package/dist/types/sdk/constants/math.d.ts +5 -1
  72. package/dist/types/sdk/index.d.ts +16 -14
  73. package/dist/types/sdk/market/MarketRegister.d.ts +7 -0
  74. package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +47 -2
  75. package/dist/types/sdk/market/credit/CreditSuite.d.ts +24 -2
  76. package/dist/types/sdk/{accounts → market/credit}/dominantCollateral.d.ts +13 -6
  77. package/dist/types/sdk/market/credit/index.d.ts +3 -2
  78. package/dist/types/sdk/market/credit/types.d.ts +112 -2
  79. package/dist/types/sdk/market/index.d.ts +4 -3
  80. package/dist/types/sdk/market/math.d.ts +60 -1
  81. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +15 -4
  82. package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +0 -10
  83. package/dist/types/sdk/market/oracle/index.d.ts +2 -2
  84. package/dist/types/sdk/market/oracle/types.d.ts +30 -14
  85. package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +1 -1
  86. package/dist/types/sdk/market/rwa/types.d.ts +1 -1
  87. package/dist/types/sdk/opportunities/index.d.ts +2 -2
  88. package/package.json +1 -1
  89. package/dist/cjs/sdk/accounts/constants.js +0 -12
  90. package/dist/esm/sdk/accounts/constants.js +0 -11
  91. package/dist/types/sdk/accounts/constants.d.ts +0 -11
@@ -1,14 +1,16 @@
1
- import { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
2
1
  import { StrategyPosition } from "../../model/positions.js";
3
2
  import "../../model/index.js";
4
3
  import { ClaimableWithdrawal, DelayedIntent, PendingWithdrawal, RequestableWithdrawal } from "./withdrawal-compressor/types.js";
5
- import { Asset, ConnectedBotData, CreditAccountData } from "../base/types.js";
4
+ import { Asset, ConnectedBotData, CreditAccountData, CreditAccountTokensSlice } from "../base/types.js";
5
+ import { RWAOpenAccountRequirements, RWAOperationArgs } from "../market/rwa/types.js";
6
+ import "../market/rwa/index.js";
6
7
  import { RouterCASlice, RouterCloseResult } from "../router/types.js";
7
8
  import "../router/index.js";
9
+ import { GetCreditAccountsOptions, ListStrategyPositionsProps } from "./credit-account-compressor/types.js";
10
+ import "./credit-account-compressor/index.js";
8
11
  import "./withdrawal-compressor/index.js";
9
- import { RWAOpenAccountRequirements, RWAOperationArgs } from "../market/rwa/types.js";
10
- import "../market/rwa/index.js";
11
12
  import { PriceUpdate } from "../market/pricefeeds/types.js";
13
+ import { PartialLiquidationParams } from "../market/credit/types.js";
12
14
  import { CreditSuite } from "../market/credit/CreditSuite.js";
13
15
  import "../market/index.js";
14
16
  import { MultiCall, RawTx } from "../types/transactions.js";
@@ -16,116 +18,8 @@ import { OnchainSDK } from "../OnchainSDK.js";
16
18
  import { Construct } from "../base/Construct.js";
17
19
  import "../types/index.js";
18
20
  import "../base/index.js";
19
- import { Address, ContractFunctionArgs, Hex } from "viem";
21
+ import { Address, Hex } from "viem";
20
22
  //#region src/sdk/accounts/types.d.ts
21
- /**
22
- * @internal
23
- * Arguments tuple for the credit account compressor's `getCreditAccounts` view method.
24
- **/
25
- type GetCreditAccountsArgs = ContractFunctionArgs<typeof creditAccountCompressorAbi, "pure" | "view", "getCreditAccounts">;
26
- /**
27
- * @internal
28
- * Filtering criteria applied to individual credit accounts when querying the compressor.
29
- **/
30
- interface CreditAccountFilter {
31
- /**
32
- * Filter by account owner address.
33
- **/
34
- owner: Address;
35
- /**
36
- * Whether to include accounts with zero outstanding debt.
37
- **/
38
- includeZeroDebt: boolean;
39
- /**
40
- * Minimum health factor threshold (inclusive).
41
- * 18 digits precision (10^18 = 1)
42
- **/
43
- minHealthFactor: bigint;
44
- /**
45
- * Maximum health factor threshold (inclusive).
46
- * 18 digits precision (10^18 = 1)
47
- **/
48
- maxHealthFactor: bigint;
49
- /**
50
- * Whether to return only accounts whose health computation reverts.
51
- **/
52
- reverting: boolean;
53
- }
54
- /**
55
- * @internal
56
- * Filtering criteria to select which credit managers to query.
57
- **/
58
- interface CreditManagerFilter {
59
- /**
60
- * Only include credit managers owned by these market configurators.
61
- **/
62
- configurators: readonly Address[];
63
- /**
64
- * Only include these specific credit manager addresses.
65
- **/
66
- creditManagers: readonly Address[];
67
- /**
68
- * Only include credit managers linked to these pool addresses.
69
- **/
70
- pools: readonly Address[];
71
- /**
72
- * Only include credit managers with this underlying token.
73
- **/
74
- underlying: Address;
75
- }
76
- /**
77
- * Options for fetching credit accounts, allowing filtering by credit manager, owner, and health factor range.
78
- **/
79
- interface GetCreditAccountsOptions {
80
- /**
81
- * If set, only return accounts from this credit manager; otherwise query all attached markets.
82
- **/
83
- creditManager?: Address;
84
- /**
85
- * If set, only return accounts owned by this address.
86
- **/
87
- owner?: Address;
88
- /**
89
- * Whether to include accounts with zero outstanding debt.
90
- * @default false
91
- **/
92
- includeZeroDebt?: boolean;
93
- /**
94
- * Minimum health factor threshold (inclusive).
95
- * 18 digits precision (10^18 = 1)
96
- * @default 0n
97
- **/
98
- minHealthFactor?: bigint;
99
- /**
100
- * Maximum health factor threshold (inclusive).
101
- * 18 digits precision (10^18 = 1)
102
- * @default MAX_UINT256
103
- **/
104
- maxHealthFactor?: bigint;
105
- /**
106
- * If true, exclude reserve price feed updates from the query.
107
- **/
108
- ignoreReservePrices?: boolean;
109
- }
110
- /**
111
- * Props for {@link ICreditAccountsService.listPositions}.
112
- **/
113
- interface ListStrategyPositionsProps {
114
- /**
115
- * Wallet whose credit accounts to describe. RWA accounts are resolved from
116
- * the investor EOA, see {@link ICreditAccountsService.getBorrowerCreditAccounts}.
117
- **/
118
- owner: Address;
119
- /**
120
- * Whether to include accounts that carry no debt.
121
- **/
122
- includeZeroDebt: boolean;
123
- }
124
- /**
125
- * Lightweight slice of credit-account data containing only token
126
- * balances and the enabled-tokens bitmask.
127
- **/
128
- type CreditAccountTokensSlice = Pick<CreditAccountData, "creditManager" | "creditAccount" | "tokens" | "enabledTokensMask">;
129
23
  /**
130
24
  * Result of closing or liquidating a credit account, including the router's optimal close path.
131
25
  **/
@@ -174,39 +68,6 @@ interface CreditManagerOperationResult {
174
68
  **/
175
69
  creditFacade: CreditSuite["creditFacade"];
176
70
  }
177
- /**
178
- * Close operation type: `"close"` fully closes the account, `"zeroDebt"` repays all debt but keeps the account open.
179
- **/
180
- type CloseOptions = "close" | "zeroDebt";
181
- interface CloseCreditAccountProps {
182
- /**
183
- * Close or zeroDebt
184
- */
185
- operation: CloseOptions;
186
- /**
187
- * Minimal credit account data on which operation is performed
188
- */
189
- creditAccount: RouterCASlice;
190
- /**
191
- * Tokens to withdraw from credit account.
192
- * For credit account closing this is the underlying token, because during the closure,
193
- * all tokens on account are swapped into the underlying,
194
- * and only the underlying token will remain on the credit account
195
- */
196
- assetsToWithdraw: Array<Address>;
197
- /**
198
- * Wallet address to withdraw underlying to
199
- */
200
- to: Address;
201
- /**
202
- * Slippage in PERCENTAGE_FORMAT (100% = 10_000) per operation
203
- */
204
- slippage?: bigint;
205
- /**
206
- * Result of findBestClosePath method from router; if omited, calls marketRegister.findCreditManager {@link RouterCloseResult}
207
- */
208
- closePath?: RouterCloseResult;
209
- }
210
71
  /**
211
72
  * Input for {@link ICreditAccountsService.assembleCloseCreditAccountCalls}.
212
73
  */
@@ -228,34 +89,6 @@ type AssembleCloseCreditAccountCallsProps = {
228
89
  */
229
90
  to: Address;
230
91
  };
231
- interface RepayAndLiquidateCreditAccountProps {
232
- /**
233
- * Tokens to repay debt.
234
- * In the current implementation, this is the (debt+interest+fees) * buffer,
235
- * where buffer refers to amount of tokens which will exceed current debt
236
- * in order to cover possible debt increase over tx execution.
237
- */
238
- collateralAssets: Array<Asset>;
239
- /**
240
- * tokens to withdraw from credit account.
241
- Typically all non zero ca assets (including unclaimed rewards)
242
- plus underlying token (to withdraw any exceeding underlying token after repay)
243
- */
244
- assetsToWithdraw: Array<Asset>;
245
- /**
246
- * Minimal credit account data on which operation is performed.
247
- */
248
- creditAccount: RouterCASlice;
249
- /**
250
- * Wallet address to withdraw underlying to
251
- */
252
- to: Address;
253
- /**
254
- * Permits of tokens to withdraw (if any permittable token is present).
255
- */
256
- permits: Record<string, PermitResult>;
257
- tokensToClaim: Asset[];
258
- }
259
92
  /**
260
93
  * Input for {@link ICreditAccountsService.assembleRepayCreditAccountCalls}.
261
94
  */
@@ -271,16 +104,6 @@ type AssembleRepayCreditAccountCallsProps = {
271
104
  */
272
105
  calls?: Array<MultiCall>;
273
106
  };
274
- interface RepayCreditAccountProps extends RepayAndLiquidateCreditAccountProps {
275
- /**
276
- * RWA wrap multicall entries (from getRWAWrapCalls).
277
- */
278
- calls?: Array<MultiCall>;
279
- /**
280
- * close or zeroDebt
281
- */
282
- operation: CloseOptions;
283
- }
284
107
  /**
285
108
  * Quota `Asset.balance` values are denominated in **pool underlying token
286
109
  * units**, not in the quoted token's own units.
@@ -300,44 +123,6 @@ interface PrepareUpdateQuotasProps {
300
123
  */
301
124
  minQuota: Array<Asset>;
302
125
  }
303
- interface UpdateQuotasProps extends PrepareUpdateQuotasProps {
304
- /**
305
- * Minimal credit account data on which operation is performed
306
- */
307
- creditAccount: RouterCASlice;
308
- }
309
- interface AddCollateralProps extends PrepareUpdateQuotasProps {
310
- /**
311
- * Asset to add as collateral
312
- */
313
- asset: Asset;
314
- /**
315
- * Native token amount to attach to tx
316
- */
317
- ethAmount: bigint;
318
- /**
319
- * Permit of collateral asset if it is permittable
320
- */
321
- permit: PermitResult | undefined;
322
- /**
323
- * Minimal credit account data on which operation is performed
324
- */
325
- creditAccount: RouterCASlice;
326
- }
327
- interface WithdrawCollateralProps extends PrepareUpdateQuotasProps {
328
- /**
329
- * list of assets which should be withdrawn
330
- */
331
- assetsToWithdraw: Array<Asset>;
332
- /**
333
- * Wallet address to withdraw token to
334
- */
335
- to: Address;
336
- /**
337
- * minimal credit account data on which operation is performed
338
- */
339
- creditAccount: RouterCASlice;
340
- }
341
126
  /**
342
127
  * Credit account and credit manager address pair, used for batch queries such as connected bot lookups.
343
128
  **/
@@ -351,16 +136,6 @@ type AccountToCheck = {
351
136
  **/
352
137
  creditManager: Address;
353
138
  };
354
- interface ExecuteSwapProps extends PrepareUpdateQuotasProps {
355
- /**
356
- * Array of MultiCall from router methods getSingleSwap or getAllSwaps
357
- */
358
- calls: Array<MultiCall>;
359
- /**
360
- * Minimal credit account data on which operation is performed
361
- */
362
- creditAccount: RouterCASlice;
363
- }
364
139
  interface PreviewDelayedWithdrawalProps {
365
140
  /**
366
141
  * Amount of source token (ex. cp0xlrt)
@@ -430,26 +205,6 @@ type AssembleClaimDelayedCallsProps = {
430
205
  */
431
206
  claimableNow: Pick<ClaimableWithdrawal, "outputs" | "claimCalls" | "withdrawalPhantomToken" | "withdrawalTokenSpent">;
432
207
  };
433
- interface StartDelayedWithdrawalProps extends PrepareUpdateQuotasProps {
434
- /**
435
- * Withdrawal preview
436
- */
437
- preview: RequestableWithdrawal;
438
- /**
439
- * Minimal credit account data on which operation is performed
440
- */
441
- creditAccount: RouterCASlice;
442
- }
443
- interface ClaimDelayedProps extends PrepareUpdateQuotasProps {
444
- /**
445
- * assets claimable now from getPendingWithdrawals
446
- */
447
- claimableNow: GetPendingWithdrawalsResult["claimableNow"][number];
448
- /**
449
- * Minimal credit account data on which operation is performed
450
- */
451
- creditAccount: RouterCASlice;
452
- }
453
208
  interface ClaimFarmRewardsProps extends PrepareUpdateQuotasProps {
454
209
  /**
455
210
  * Legacy property, v3.1 only enables token when quota is bought and when quota is bought token cannot be disabled.
@@ -529,27 +284,6 @@ interface OpenCAProps extends PrepareUpdateQuotasProps {
529
284
  */
530
285
  rwaOptions?: RWAOperationArgs;
531
286
  }
532
- interface ChangeDeptProps {
533
- /**
534
- * Minimal credit account data on which operation is performed
535
- */
536
- creditAccount: RouterCASlice;
537
- /**
538
- * Amount to change debt by
539
- * 0 - prohibited value;
540
- * negative value for debt decrease;
541
- * positive value for debt increase.
542
- */
543
- amount: bigint;
544
- /**
545
- * Assets to add as collateral
546
- */
547
- collateral?: [Asset];
548
- /**
549
- * Assets to wrap
550
- */
551
- wrapAsset?: [Asset];
552
- }
553
287
  interface FullyLiquidateProps {
554
288
  /**
555
289
  * Credit account to liquidate
@@ -580,25 +314,7 @@ interface FullyLiquidateProps {
580
314
  */
581
315
  debtOnly?: boolean;
582
316
  }
583
- interface DefaultPartialLiquidationParams {
584
- /**
585
- * {@link PartiallyLiquidateProps.tokenOut}
586
- */
587
- tokenOut: Address;
588
- /**
589
- * {@link PartiallyLiquidateProps.repaidAmount}
590
- */
591
- repaidAmount: bigint;
592
- /**
593
- * {@link PartiallyLiquidateProps.minSeizedAmount}
594
- */
595
- minSeizedAmount: bigint;
596
- /**
597
- * {@link PartiallyLiquidateProps.optimalHF}
598
- */
599
- optimalHF: bigint;
600
- }
601
- interface PartiallyLiquidateProps {
317
+ interface PartiallyLiquidateProps extends PartialLiquidationParams {
602
318
  /**
603
319
  * Credit account to liquidate
604
320
  */
@@ -607,30 +323,6 @@ interface PartiallyLiquidateProps {
607
323
  * Address to transfer underlying left after liquidation
608
324
  */
609
325
  to: Address;
610
- /**
611
- * Collateral token to seize.
612
- * If omitted, the most valuable enabled non-underlying collateral token
613
- * (by oracle)
614
- */
615
- tokenOut?: Address;
616
- /**
617
- * Amount of underlying token to repay.
618
- * If omitted, computed internally
619
- */
620
- repaidAmount?: bigint;
621
- /**
622
- * Minimum amount of `token` to seize from `creditAccount`.
623
- * If `token` is a phantom token, it's withdrawn first, and its `depositedToken` is then sent to the liquidator.
624
- * In this case, `minSeizedAmount` is denominated in `depositedToken`.
625
- * If omitted, computed internally.
626
- */
627
- minSeizedAmount?: bigint;
628
- /**
629
- * Target health factor for partial liquidation (4 digits precision, 10000 = 100%).
630
- * If omitted, defaults to {@link ICreditAccountsService.getOptimalHFForPartialLiquidation}.
631
- * Only used when `repaidAmount` is not explicitly provided.
632
- */
633
- optimalHF?: bigint;
634
326
  }
635
327
  /**
636
328
  * EIP-2612 permit signature data for a token, enabling gasless approval for credit account operations.
@@ -878,12 +570,6 @@ interface ICreditAccountsService extends Construct {
878
570
  * @returns Transaction data and optional loss policy data
879
571
  */
880
572
  fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
881
- /**
882
- * Calculates default partial liquidation parameters for a credit account
883
- * These parameters are used as defaults for the {@link partiallyLiquidate} method.
884
- * @param ca - Credit account to partially liquidate
885
- */
886
- defaultPartialLiquidationParams(ca: CreditAccountData): DefaultPartialLiquidationParams;
887
573
  /**
888
574
  * Generates transaction to partially liquidate credit account;
889
575
  *
@@ -897,64 +583,19 @@ interface ICreditAccountsService extends Construct {
897
583
  */
898
584
  partiallyLiquidate(props: PartiallyLiquidateProps): Promise<RawTx>;
899
585
  /**
900
- * Builds close multicall calls without price feed updates.
901
- *
902
- * Same operation sequence as {@link closeCreditAccount} (close path swaps,
903
- * disable quotas, decrease debt, withdraw assets), but does not prepend
904
- * price updates and does not build the facade transaction.
586
+ * Builds close multicall calls without price feed updates: close path swaps,
587
+ * disable quotas, decrease debt, withdraw assets. Does not prepend price
588
+ * updates and does not build the facade transaction.
905
589
  *
906
590
  * @param props - {@link AssembleCloseCreditAccountCallsProps}
907
591
  * @returns Raw facade multicall payload for close (before price feed updates)
908
592
  */
909
593
  assembleCloseCreditAccountCalls(props: AssembleCloseCreditAccountCallsProps): Promise<Array<MultiCall>>;
910
- /**
911
- * Closes credit account or closes credit account and keeps it open with zero debt.
912
- * - Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
913
- * -> disable quotas of exiting tokens -> decrease debt -> disable exiting tokens -> withdraw underlying tokens
914
- * @param props - {@link CloseCreditAccountProps}
915
- * @returns All necessary data to execute the transaction (call, credit facade)
916
- */
917
- closeCreditAccount(props: CloseCreditAccountProps): Promise<CloseCreditAccountResult>;
918
- /**
919
- * Updates quota of credit account.
920
- * CA quota updated in the following order: price update -> update quotas
921
- * @param props - {@link UpdateQuotasProps}
922
- * @returns All necessary data to execute the transaction (call, credit facade)
923
- */
924
- updateQuotas(props: UpdateQuotasProps): Promise<CreditAccountOperationResult>;
925
- /**
926
- * Adds a single collateral to credit account and updates quotas
927
- * Collateral is added in the following order: price update -> add collateral (with permit) -> update quotas
928
- * @param props - {@link AddCollateralProps}
929
- * @returns All necessary data to execute the transaction (call, credit facade)
930
- */
931
- addCollateral(props: AddCollateralProps): Promise<CreditAccountOperationResult>;
932
- /**
933
- * Increases or decreases debt of credit account; debt decrease uses token ON CREDIT ACCOUNT
934
- * Debt is changed in the following order: price update -> (enables underlying if it was disabled) -> change debt
935
- * @param props - {@link ChangeDeptProps}
936
- * @returns All necessary data to execute the transaction (call, credit facade)
937
- */
938
- changeDebt(props: ChangeDeptProps): Promise<CreditAccountOperationResult>;
939
- /**
940
- * Executes swap specified by given calls, update quotas of affected tokens
941
- * Swap is executed in the following order: price update -> execute swap path -> update quotas
942
- * @param props - {@link ExecuteSwapProps}
943
- * @returns All necessary data to execute the transaction (call, credit facade)
944
- */
945
- executeSwap(props: ExecuteSwapProps): Promise<CreditAccountOperationResult>;
946
- /**
947
- * Start delayed withdrawal for given token
948
- - Withdrawal is executed in the following order: price update -> execute withdraw calls -> update quotas
949
- * @param props - {@link StartDelayedWithdrawalProps}
950
- * @returns All necessary data to execute the transaction (call, credit facade)
951
- */
952
- startDelayedWithdrawal(props: StartDelayedWithdrawalProps): Promise<CreditAccountOperationResult>;
953
594
  /**
954
595
  * Builds start-delayed-withdrawal multicall calls without price feed updates
955
596
  * or quota updates.
956
597
  *
957
- * Same balance bracket as {@link startDelayedWithdrawal}:
598
+ * Balance bracket:
958
599
  * `storeExpectedBalances` → `preview.requestCalls` → `compareBalances`.
959
600
  *
960
601
  * Besides the positive output deltas, the bracket carries a negative delta
@@ -966,13 +607,14 @@ interface ICreditAccountsService extends Construct {
966
607
  *
967
608
  * @param props - {@link AssembleStartDelayedWithdrawalCallsProps}
968
609
  * @returns Raw facade multicall payload for the delayed-withdrawal request
610
+ * @throws If `props.creditFacade` does not belong to a loaded market.
969
611
  */
970
612
  assembleStartDelayedWithdrawalCalls(props: AssembleStartDelayedWithdrawalCallsProps): Array<MultiCall>;
971
613
  /**
972
614
  * Builds claim-delayed-withdrawal multicall calls without price feed updates
973
615
  * or quota updates.
974
616
  *
975
- * Same balance bracket as {@link claimDelayed}:
617
+ * Balance bracket:
976
618
  * `storeExpectedBalances` → `claimableNow.claimCalls` → `compareBalances`.
977
619
  *
978
620
  * Besides the positive output deltas, the bracket carries a negative delta
@@ -987,6 +629,7 @@ interface ICreditAccountsService extends Construct {
987
629
  *
988
630
  * @param props - {@link AssembleClaimDelayedCallsProps}
989
631
  * @returns Raw facade multicall payload for the claim
632
+ * @throws If `props.creditFacade` does not belong to a loaded market.
990
633
  */
991
634
  assembleClaimDelayedCalls(props: AssembleClaimDelayedCallsProps): Array<MultiCall>;
992
635
  /**
@@ -1001,13 +644,6 @@ interface ICreditAccountsService extends Construct {
1001
644
  * @returns
1002
645
  */
1003
646
  getPendingWithdrawals(props: GetPendingWithdrawalsProps): Promise<GetPendingWithdrawalsResult>;
1004
- /**
1005
- * Claim tokens with delayed withdrawal
1006
- - Claim is executed in the following order: price update -> execute claim calls -> update quotas
1007
- * @param props - {@link ClaimDelayedProps}
1008
- * @returns
1009
- */
1010
- claimDelayed(props: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
1011
647
  /**
1012
648
  * Returns address to which approval should be given on collateral token
1013
649
  * It's credit manager for classical markets and special wallet for RWA markets
@@ -1033,20 +669,9 @@ interface ICreditAccountsService extends Construct {
1033
669
  * - Strategy/trading: price update -> increase debt -> add collateral -> update quotas -> execute swap path
1034
670
  * - In strategy is possible situation when collateral is added, but not swapped; the only swapped value in this case will be debt
1035
671
  * @param props - {@link OpenCAProps}
1036
- * @returns All necessary data to execute the transaction (call, credit facade)
1037
- */
1038
- openCA(props: OpenCAProps): Promise<CreditAccountOperationResult>;
1039
- /**
1040
- * Returns borrow rate with 4 digits precision (10000 = 100%)
1041
- * @param ca
1042
- * @returns
1043
- */
1044
- getBorrowRate(ca: CreditAccountData): bigint;
1045
- /**
1046
- * Returns optimal HF for partial liquidation with 4 digits precision (10000 = 100%)
1047
- * @param ca
672
+ * @returns Raw transaction ready to be signed and sent
1048
673
  */
1049
- getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
674
+ openCA(props: OpenCAProps): Promise<RawTx>;
1050
675
  /**
1051
676
  * Returns account price updates that can be used in credit facade multicall or liquidator calls
1052
677
  * @param account - Credit account to get price updates for
@@ -1054,30 +679,6 @@ interface ICreditAccountsService extends Construct {
1054
679
  * @returns Array of price updates
1055
680
  */
1056
681
  getOnDemandPriceUpdates(account: CreditAccountTokensSlice, ignoreReservePrices?: boolean): Promise<PriceUpdate[]>;
1057
- /**
1058
- * Executes a multicall on a credit account, automatically prepending
1059
- * necessary on-demand price feed updates.
1060
- *
1061
- * @param creditAccount - Credit account to execute multicall on
1062
- * @param calls - Array of multicall operations (price updates will be inferred)
1063
- * @param options - Optional settings for price update generation
1064
- * @returns Raw transaction ready to be signed and sent
1065
- */
1066
- multicall(creditAccount: RouterCASlice, calls: Array<MultiCall>, options?: {
1067
- ignoreReservePrices?: boolean;
1068
- }): Promise<RawTx>;
1069
- /**
1070
- * Executes a bot multicall on a credit account, automatically prepending
1071
- * necessary on-demand price feed updates.
1072
- *
1073
- * @param creditAccount - Credit account to execute bot multicall on
1074
- * @param calls - Array of multicall operations (price updates will be inferred)
1075
- * @param options - Optional settings for price update generation
1076
- * @returns Raw transaction ready to be signed and sent
1077
- */
1078
- botMulticall(creditAccount: RouterCASlice, calls: Array<MultiCall>, options?: {
1079
- ignoreReservePrices?: boolean;
1080
- }): Promise<RawTx>;
1081
682
  /**
1082
683
  * Analyzes a multicall array and prepends necessary on-demand price feed updates.
1083
684
  *
@@ -1103,26 +704,42 @@ interface ICreditAccountsService extends Construct {
1103
704
  *
1104
705
  * @param props - Encodable operations and account context
1105
706
  * @returns Array of facade / adapter multicall calls (without price feed updates)
707
+ * @throws If `props.creditFacade` does not belong to a loaded market.
1106
708
  */
1107
709
  assembleCaOperations(props: AssembleCaOperationsProps): Array<MultiCall>;
1108
710
  /**
1109
711
  * Encodes a facade `increaseDebt` multicall entry.
712
+ *
713
+ * @throws If `creditFacade` does not belong to a loaded market.
714
+ * @deprecated Use `creditSuite.creditFacade.prepareIncreaseDebt(debt)`.
1110
715
  */
1111
716
  prepareIncreaseDebt(creditFacade: Address, debt: bigint): MultiCall;
1112
717
  /**
1113
718
  * Encodes a facade `increaseDebt` or `decreaseDebt` multicall entry.
719
+ *
720
+ * @throws If `creditFacade` does not belong to a loaded market.
721
+ * @deprecated Use `creditSuite.creditFacade.prepareChangeDebt(change, isDecrease)`.
1114
722
  */
1115
723
  prepareChangeDebt(creditFacade: Address, change: bigint, isDecrease: boolean): MultiCall;
1116
724
  /**
1117
725
  * Encodes facade `addCollateral` / `addCollateralWithPermit` multicall entries.
726
+ *
727
+ * @throws If `creditFacade` does not belong to a loaded market.
728
+ * @deprecated Use `creditSuite.creditFacade.prepareAddCollateral(assets, permits)`.
1118
729
  */
1119
730
  prepareAddCollateral(creditFacade: Address, assets: Array<Asset>, permits: Record<string, PermitResult>): Array<MultiCall>;
1120
731
  /**
1121
732
  * Encodes a facade `withdrawCollateral` multicall entry.
733
+ *
734
+ * @throws If `creditFacade` does not belong to a loaded market.
735
+ * @deprecated Use `creditSuite.creditFacade.prepareWithdrawCollateral(token, amount, to)`.
1122
736
  */
1123
737
  prepareWithdrawToken(creditFacade: Address, token: Address, amount: bigint, to: Address): MultiCall;
1124
738
  /**
1125
739
  * Encodes facade `updateQuota` multicall entries from average/min quota assets.
740
+ *
741
+ * @throws If `creditFacade` does not belong to a loaded market.
742
+ * @deprecated Use `creditSuite.creditFacade.prepareUpdateQuotas(props)`.
1126
743
  */
1127
744
  prepareUpdateQuotas(creditFacade: Address, props: PrepareUpdateQuotasProps): Array<MultiCall>;
1128
745
  /**
@@ -1132,15 +749,12 @@ interface ICreditAccountsService extends Construct {
1132
749
  * @param creditAccount - Credit account to update
1133
750
  * @param calls - Operation calls to execute
1134
751
  * @param options - Optional price update and ETH value settings
1135
- * @returns Raw transaction and the final multicall payload
752
+ * @returns Raw transaction ready to be signed and sent
1136
753
  */
1137
754
  executeCaUpdate(creditAccount: RouterCASlice, calls: Array<MultiCall>, options?: {
1138
755
  ignoreReservePrices?: boolean;
1139
756
  ethAmount?: bigint;
1140
- }): Promise<{
1141
- tx: RawTx;
1142
- calls: Array<MultiCall>;
1143
- }>;
757
+ }): Promise<RawTx>;
1144
758
  /**
1145
759
  * Returns multicall entries to redeem (unwrap) RWA ERC-4626 vault shares into underlying for the given credit manager.
1146
760
  * Used when withdrawing debt from a RWA market: redeems adapter vault shares so the underlying can be withdrawn.
@@ -1149,7 +763,7 @@ interface ICreditAccountsService extends Construct {
1149
763
  * @param creditManager - Credit manager address
1150
764
  * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
1151
765
  */
1152
- getRWAUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
766
+ assembleRWAUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
1153
767
  /**
1154
768
  * Returns multicall entries to deposit (wrap) underlying into RWA ERC-4626 vault shares for the given credit manager.
1155
769
  * Used when adding debt on a RWA market: deposits underlying into the adapter vault so shares are minted on the account.
@@ -1158,7 +772,7 @@ interface ICreditAccountsService extends Construct {
1158
772
  * @param creditManager - Credit manager address
1159
773
  * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
1160
774
  */
1161
- getRWAWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
775
+ assembleRWAWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
1162
776
  /**
1163
777
  * Returns multicall entries to call redeemDiff on the RWA ERC-4626 adapter for the given credit manager.
1164
778
  * Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess RWA vault tokens.
@@ -1167,7 +781,7 @@ interface ICreditAccountsService extends Construct {
1167
781
  * @param creditManager - Credit manager address
1168
782
  * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
1169
783
  */
1170
- getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
784
+ assembleRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
1171
785
  /**
1172
786
  * Returns multicall entries to call depositDiff on the RWA ERC-4626 adapter for the given credit manager.
1173
787
  * Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
@@ -1176,50 +790,25 @@ interface ICreditAccountsService extends Construct {
1176
790
  * @param creditManager - Credit manager address
1177
791
  * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
1178
792
  */
1179
- getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
793
+ assembleDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
1180
794
  /**
1181
- * Withdraws a single collateral from credit account to wallet to and updates quotas;
1182
- * technically can withdraw several tokens at once
1183
- * - Collateral is withdrawn in the following order: price update -> withdraw token -> update quotas for affected tokens
1184
- * @param props - {@link WithdrawCollateralProps}
1185
- * @return All necessary data to execute the transaction (call, credit facade)
1186
- */
1187
- withdrawCollateral(props: WithdrawCollateralProps): Promise<CreditAccountOperationResult>;
1188
- /**
1189
- * Builds repay multicall calls without price feed updates.
1190
- *
1191
- * Same operation sequence as {@link repayCreditAccount} (add collateral, wrap calls,
1192
- * disable quotas, decrease debt, redeem/unwrap, claim rewards, withdraw assets),
1193
- * but does not prepend price updates and does not build the facade transaction.
795
+ * Builds repay multicall calls without price feed updates: add collateral,
796
+ * wrap calls, disable quotas, decrease debt, redeem/unwrap, claim rewards,
797
+ * withdraw assets. Does not prepend price updates and does not build the
798
+ * facade transaction.
1194
799
  *
1195
800
  * @param props - {@link AssembleRepayCreditAccountCallsProps}
1196
801
  * @returns Raw facade multicall payload for repay (before price feed updates)
1197
802
  */
1198
803
  assembleRepayCreditAccountCalls(props: AssembleRepayCreditAccountCallsProps): Promise<Array<MultiCall>>;
1199
- /**
1200
- * Fully repays credit account or repays credit account and keeps it open with zero debt
1201
- * - Repays in the following order: price update -> add collateral to cover the debt ->
1202
- * -> disable quotas for all tokens -> decrease debt -> disable tokens all tokens -> withdraw all tokens
1203
- * @param props - {@link RepayCreditAccountProps}
1204
- * @return All necessary data to execute the transaction (call, credit facade)
1205
- */
1206
- repayCreditAccount(props: RepayCreditAccountProps): Promise<CreditAccountOperationResult>;
1207
- /**
1208
- * Fully repays liquidatable account
1209
- * - Repay and liquidate is executed in the following order: price update -> add collateral to cover the debt ->
1210
- * withdraw all tokens from credit account
1211
- * @param props - {@link RepayAndLiquidateCreditAccountProps}
1212
- * @return All necessary data to execute the transaction (call, credit facade)
1213
- */
1214
- repayAndLiquidateCreditAccount(props: RepayAndLiquidateCreditAccountProps): Promise<CreditAccountOperationResult>;
1215
804
  /**
1216
805
  * Claims farm rewards and optionally updates quotas
1217
806
  * - Claim rewards is executed in the following order: price update -> execute claim calls ->
1218
807
  * -> (optionally: update quotas)
1219
808
  * @param props - {@link ClaimFarmRewardsProps}
1220
- * @return All necessary data to execute the transaction (call, credit facade)
809
+ * @return Raw transaction ready to be signed and sent
1221
810
  */
1222
- claimFarmRewards(props: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
811
+ claimFarmRewards(props: ClaimFarmRewardsProps): Promise<RawTx>;
1223
812
  }
1224
813
  //#endregion
1225
- export { AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CloseOptions, CreditAccountFilter, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerFilter, CreditManagerOperationResult, DefaultPartialLiquidationParams, EncodableCreditAccountOperation, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, ListStrategyPositionsProps, OpenCAProps, PartiallyLiquidateProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps };
814
+ export { AccountToCheck, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ClaimFarmRewardsProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditManagerOperationResult, EncodableCreditAccountOperation, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, Rewards, SetBotProps };