@gearbox-protocol/sdk 14.12.0-next.72 → 14.12.0-next.74

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 (67) hide show
  1. package/dist/cjs/dev/AccountOpener.js +2 -5
  2. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +49 -533
  3. package/dist/cjs/sdk/accounts/index.js +0 -4
  4. package/dist/cjs/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +1 -1
  5. package/dist/cjs/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +1 -1
  6. package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +2 -2
  7. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +3 -3
  8. package/dist/cjs/sdk/accounts/liquidations/constants.js +0 -2
  9. package/dist/cjs/sdk/accounts/liquidations/index.js +0 -2
  10. package/dist/cjs/sdk/constants/index.js +1 -0
  11. package/dist/cjs/sdk/constants/math.js +5 -0
  12. package/dist/cjs/sdk/index.js +8 -4
  13. package/dist/cjs/sdk/market/MarketRegister.js +10 -0
  14. package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +181 -0
  15. package/dist/cjs/sdk/market/credit/CreditSuite.js +107 -1
  16. package/dist/cjs/sdk/{accounts → market/credit}/dominantCollateral.js +18 -4
  17. package/dist/cjs/sdk/market/credit/index.js +3 -0
  18. package/dist/cjs/sdk/market/index.js +3 -0
  19. package/dist/cjs/sdk/market/math.js +59 -0
  20. package/dist/cjs/sdk/market/oracle/PriceOracleV310Contract.js +2 -9
  21. package/dist/cjs/sdk/opportunities/index.js +4 -0
  22. package/dist/esm/dev/AccountOpener.js +2 -5
  23. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +50 -534
  24. package/dist/esm/sdk/accounts/index.js +1 -3
  25. package/dist/esm/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +1 -1
  26. package/dist/esm/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +1 -1
  27. package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +2 -2
  28. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +2 -2
  29. package/dist/esm/sdk/accounts/liquidations/constants.js +1 -2
  30. package/dist/esm/sdk/accounts/liquidations/index.js +1 -2
  31. package/dist/esm/sdk/constants/index.js +2 -2
  32. package/dist/esm/sdk/constants/math.js +5 -1
  33. package/dist/esm/sdk/index.js +4 -5
  34. package/dist/esm/sdk/market/MarketRegister.js +10 -0
  35. package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +181 -0
  36. package/dist/esm/sdk/market/credit/CreditSuite.js +108 -2
  37. package/dist/esm/sdk/{accounts → market/credit}/dominantCollateral.js +18 -5
  38. package/dist/esm/sdk/market/credit/index.js +2 -1
  39. package/dist/esm/sdk/market/index.js +2 -1
  40. package/dist/esm/sdk/market/math.js +56 -1
  41. package/dist/esm/sdk/market/oracle/PriceOracleV310Contract.js +3 -10
  42. package/dist/esm/sdk/opportunities/index.js +2 -2
  43. package/dist/types/sdk/OnchainSDK.d.ts +1 -1
  44. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +11 -78
  45. package/dist/types/sdk/accounts/index.d.ts +2 -4
  46. package/dist/types/sdk/accounts/liquidations/constants.d.ts +1 -2
  47. package/dist/types/sdk/accounts/liquidations/index.d.ts +1 -2
  48. package/dist/types/sdk/accounts/types.d.ts +42 -346
  49. package/dist/types/sdk/constants/index.d.ts +2 -2
  50. package/dist/types/sdk/constants/math.d.ts +5 -1
  51. package/dist/types/sdk/index.d.ts +10 -11
  52. package/dist/types/sdk/market/MarketRegister.d.ts +7 -0
  53. package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +47 -2
  54. package/dist/types/sdk/market/credit/CreditSuite.d.ts +24 -2
  55. package/dist/types/sdk/{accounts → market/credit}/dominantCollateral.d.ts +13 -6
  56. package/dist/types/sdk/market/credit/index.d.ts +3 -2
  57. package/dist/types/sdk/market/credit/types.d.ts +112 -2
  58. package/dist/types/sdk/market/index.d.ts +3 -2
  59. package/dist/types/sdk/market/math.d.ts +60 -1
  60. package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +1 -0
  61. package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +1 -1
  62. package/dist/types/sdk/market/rwa/types.d.ts +1 -1
  63. package/dist/types/sdk/opportunities/index.d.ts +2 -2
  64. package/package.json +1 -1
  65. package/dist/cjs/sdk/accounts/constants.js +0 -12
  66. package/dist/esm/sdk/accounts/constants.js +0 -11
  67. package/dist/types/sdk/accounts/constants.d.ts +0 -11
@@ -3,12 +3,13 @@ import { StrategyPosition } from "../../model/positions.js";
3
3
  import "../../model/index.js";
4
4
  import { ClaimableWithdrawal, DelayedIntent, PendingWithdrawal, RequestableWithdrawal } from "./withdrawal-compressor/types.js";
5
5
  import { Asset, ConnectedBotData, CreditAccountData } from "../base/types.js";
6
+ import { RWAOpenAccountRequirements, RWAOperationArgs } from "../market/rwa/types.js";
7
+ import "../market/rwa/index.js";
6
8
  import { RouterCASlice, RouterCloseResult } from "../router/types.js";
7
9
  import "../router/index.js";
8
10
  import "./withdrawal-compressor/index.js";
9
- import { RWAOpenAccountRequirements, RWAOperationArgs } from "../market/rwa/types.js";
10
- import "../market/rwa/index.js";
11
11
  import { PriceUpdate } from "../market/pricefeeds/types.js";
12
+ import { PartialLiquidationParams } from "../market/credit/types.js";
12
13
  import { CreditSuite } from "../market/credit/CreditSuite.js";
13
14
  import "../market/index.js";
14
15
  import { MultiCall, RawTx } from "../types/transactions.js";
@@ -174,39 +175,6 @@ interface CreditManagerOperationResult {
174
175
  **/
175
176
  creditFacade: CreditSuite["creditFacade"];
176
177
  }
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
178
  /**
211
179
  * Input for {@link ICreditAccountsService.assembleCloseCreditAccountCalls}.
212
180
  */
@@ -228,34 +196,6 @@ type AssembleCloseCreditAccountCallsProps = {
228
196
  */
229
197
  to: Address;
230
198
  };
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
199
  /**
260
200
  * Input for {@link ICreditAccountsService.assembleRepayCreditAccountCalls}.
261
201
  */
@@ -271,16 +211,6 @@ type AssembleRepayCreditAccountCallsProps = {
271
211
  */
272
212
  calls?: Array<MultiCall>;
273
213
  };
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
214
  /**
285
215
  * Quota `Asset.balance` values are denominated in **pool underlying token
286
216
  * units**, not in the quoted token's own units.
@@ -300,44 +230,6 @@ interface PrepareUpdateQuotasProps {
300
230
  */
301
231
  minQuota: Array<Asset>;
302
232
  }
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
233
  /**
342
234
  * Credit account and credit manager address pair, used for batch queries such as connected bot lookups.
343
235
  **/
@@ -351,16 +243,6 @@ type AccountToCheck = {
351
243
  **/
352
244
  creditManager: Address;
353
245
  };
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
246
  interface PreviewDelayedWithdrawalProps {
365
247
  /**
366
248
  * Amount of source token (ex. cp0xlrt)
@@ -430,26 +312,6 @@ type AssembleClaimDelayedCallsProps = {
430
312
  */
431
313
  claimableNow: Pick<ClaimableWithdrawal, "outputs" | "claimCalls" | "withdrawalPhantomToken" | "withdrawalTokenSpent">;
432
314
  };
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
315
  interface ClaimFarmRewardsProps extends PrepareUpdateQuotasProps {
454
316
  /**
455
317
  * Legacy property, v3.1 only enables token when quota is bought and when quota is bought token cannot be disabled.
@@ -529,27 +391,6 @@ interface OpenCAProps extends PrepareUpdateQuotasProps {
529
391
  */
530
392
  rwaOptions?: RWAOperationArgs;
531
393
  }
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
394
  interface FullyLiquidateProps {
554
395
  /**
555
396
  * Credit account to liquidate
@@ -580,25 +421,7 @@ interface FullyLiquidateProps {
580
421
  */
581
422
  debtOnly?: boolean;
582
423
  }
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 {
424
+ interface PartiallyLiquidateProps extends PartialLiquidationParams {
602
425
  /**
603
426
  * Credit account to liquidate
604
427
  */
@@ -607,30 +430,6 @@ interface PartiallyLiquidateProps {
607
430
  * Address to transfer underlying left after liquidation
608
431
  */
609
432
  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
433
  }
635
434
  /**
636
435
  * EIP-2612 permit signature data for a token, enabling gasless approval for credit account operations.
@@ -878,12 +677,6 @@ interface ICreditAccountsService extends Construct {
878
677
  * @returns Transaction data and optional loss policy data
879
678
  */
880
679
  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
680
  /**
888
681
  * Generates transaction to partially liquidate credit account;
889
682
  *
@@ -897,64 +690,19 @@ interface ICreditAccountsService extends Construct {
897
690
  */
898
691
  partiallyLiquidate(props: PartiallyLiquidateProps): Promise<RawTx>;
899
692
  /**
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.
693
+ * Builds close multicall calls without price feed updates: close path swaps,
694
+ * disable quotas, decrease debt, withdraw assets. Does not prepend price
695
+ * updates and does not build the facade transaction.
905
696
  *
906
697
  * @param props - {@link AssembleCloseCreditAccountCallsProps}
907
698
  * @returns Raw facade multicall payload for close (before price feed updates)
908
699
  */
909
700
  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
701
  /**
954
702
  * Builds start-delayed-withdrawal multicall calls without price feed updates
955
703
  * or quota updates.
956
704
  *
957
- * Same balance bracket as {@link startDelayedWithdrawal}:
705
+ * Balance bracket:
958
706
  * `storeExpectedBalances` → `preview.requestCalls` → `compareBalances`.
959
707
  *
960
708
  * Besides the positive output deltas, the bracket carries a negative delta
@@ -966,13 +714,14 @@ interface ICreditAccountsService extends Construct {
966
714
  *
967
715
  * @param props - {@link AssembleStartDelayedWithdrawalCallsProps}
968
716
  * @returns Raw facade multicall payload for the delayed-withdrawal request
717
+ * @throws If `props.creditFacade` does not belong to a loaded market.
969
718
  */
970
719
  assembleStartDelayedWithdrawalCalls(props: AssembleStartDelayedWithdrawalCallsProps): Array<MultiCall>;
971
720
  /**
972
721
  * Builds claim-delayed-withdrawal multicall calls without price feed updates
973
722
  * or quota updates.
974
723
  *
975
- * Same balance bracket as {@link claimDelayed}:
724
+ * Balance bracket:
976
725
  * `storeExpectedBalances` → `claimableNow.claimCalls` → `compareBalances`.
977
726
  *
978
727
  * Besides the positive output deltas, the bracket carries a negative delta
@@ -987,6 +736,7 @@ interface ICreditAccountsService extends Construct {
987
736
  *
988
737
  * @param props - {@link AssembleClaimDelayedCallsProps}
989
738
  * @returns Raw facade multicall payload for the claim
739
+ * @throws If `props.creditFacade` does not belong to a loaded market.
990
740
  */
991
741
  assembleClaimDelayedCalls(props: AssembleClaimDelayedCallsProps): Array<MultiCall>;
992
742
  /**
@@ -1001,13 +751,6 @@ interface ICreditAccountsService extends Construct {
1001
751
  * @returns
1002
752
  */
1003
753
  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
754
  /**
1012
755
  * Returns address to which approval should be given on collateral token
1013
756
  * It's credit manager for classical markets and special wallet for RWA markets
@@ -1033,20 +776,9 @@ interface ICreditAccountsService extends Construct {
1033
776
  * - Strategy/trading: price update -> increase debt -> add collateral -> update quotas -> execute swap path
1034
777
  * - In strategy is possible situation when collateral is added, but not swapped; the only swapped value in this case will be debt
1035
778
  * @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
779
+ * @returns Raw transaction ready to be signed and sent
1048
780
  */
1049
- getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
781
+ openCA(props: OpenCAProps): Promise<RawTx>;
1050
782
  /**
1051
783
  * Returns account price updates that can be used in credit facade multicall or liquidator calls
1052
784
  * @param account - Credit account to get price updates for
@@ -1054,30 +786,6 @@ interface ICreditAccountsService extends Construct {
1054
786
  * @returns Array of price updates
1055
787
  */
1056
788
  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
789
  /**
1082
790
  * Analyzes a multicall array and prepends necessary on-demand price feed updates.
1083
791
  *
@@ -1103,26 +811,42 @@ interface ICreditAccountsService extends Construct {
1103
811
  *
1104
812
  * @param props - Encodable operations and account context
1105
813
  * @returns Array of facade / adapter multicall calls (without price feed updates)
814
+ * @throws If `props.creditFacade` does not belong to a loaded market.
1106
815
  */
1107
816
  assembleCaOperations(props: AssembleCaOperationsProps): Array<MultiCall>;
1108
817
  /**
1109
818
  * Encodes a facade `increaseDebt` multicall entry.
819
+ *
820
+ * @throws If `creditFacade` does not belong to a loaded market.
821
+ * @deprecated Use `creditSuite.creditFacade.prepareIncreaseDebt(debt)`.
1110
822
  */
1111
823
  prepareIncreaseDebt(creditFacade: Address, debt: bigint): MultiCall;
1112
824
  /**
1113
825
  * Encodes a facade `increaseDebt` or `decreaseDebt` multicall entry.
826
+ *
827
+ * @throws If `creditFacade` does not belong to a loaded market.
828
+ * @deprecated Use `creditSuite.creditFacade.prepareChangeDebt(change, isDecrease)`.
1114
829
  */
1115
830
  prepareChangeDebt(creditFacade: Address, change: bigint, isDecrease: boolean): MultiCall;
1116
831
  /**
1117
832
  * Encodes facade `addCollateral` / `addCollateralWithPermit` multicall entries.
833
+ *
834
+ * @throws If `creditFacade` does not belong to a loaded market.
835
+ * @deprecated Use `creditSuite.creditFacade.prepareAddCollateral(assets, permits)`.
1118
836
  */
1119
837
  prepareAddCollateral(creditFacade: Address, assets: Array<Asset>, permits: Record<string, PermitResult>): Array<MultiCall>;
1120
838
  /**
1121
839
  * Encodes a facade `withdrawCollateral` multicall entry.
840
+ *
841
+ * @throws If `creditFacade` does not belong to a loaded market.
842
+ * @deprecated Use `creditSuite.creditFacade.prepareWithdrawCollateral(token, amount, to)`.
1122
843
  */
1123
844
  prepareWithdrawToken(creditFacade: Address, token: Address, amount: bigint, to: Address): MultiCall;
1124
845
  /**
1125
846
  * Encodes facade `updateQuota` multicall entries from average/min quota assets.
847
+ *
848
+ * @throws If `creditFacade` does not belong to a loaded market.
849
+ * @deprecated Use `creditSuite.creditFacade.prepareUpdateQuotas(props)`.
1126
850
  */
1127
851
  prepareUpdateQuotas(creditFacade: Address, props: PrepareUpdateQuotasProps): Array<MultiCall>;
1128
852
  /**
@@ -1132,15 +856,12 @@ interface ICreditAccountsService extends Construct {
1132
856
  * @param creditAccount - Credit account to update
1133
857
  * @param calls - Operation calls to execute
1134
858
  * @param options - Optional price update and ETH value settings
1135
- * @returns Raw transaction and the final multicall payload
859
+ * @returns Raw transaction ready to be signed and sent
1136
860
  */
1137
861
  executeCaUpdate(creditAccount: RouterCASlice, calls: Array<MultiCall>, options?: {
1138
862
  ignoreReservePrices?: boolean;
1139
863
  ethAmount?: bigint;
1140
- }): Promise<{
1141
- tx: RawTx;
1142
- calls: Array<MultiCall>;
1143
- }>;
864
+ }): Promise<RawTx>;
1144
865
  /**
1145
866
  * Returns multicall entries to redeem (unwrap) RWA ERC-4626 vault shares into underlying for the given credit manager.
1146
867
  * Used when withdrawing debt from a RWA market: redeems adapter vault shares so the underlying can be withdrawn.
@@ -1149,7 +870,7 @@ interface ICreditAccountsService extends Construct {
1149
870
  * @param creditManager - Credit manager address
1150
871
  * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
1151
872
  */
1152
- getRWAUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
873
+ assembleRWAUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
1153
874
  /**
1154
875
  * Returns multicall entries to deposit (wrap) underlying into RWA ERC-4626 vault shares for the given credit manager.
1155
876
  * Used when adding debt on a RWA market: deposits underlying into the adapter vault so shares are minted on the account.
@@ -1158,7 +879,7 @@ interface ICreditAccountsService extends Construct {
1158
879
  * @param creditManager - Credit manager address
1159
880
  * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
1160
881
  */
1161
- getRWAWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
882
+ assembleRWAWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
1162
883
  /**
1163
884
  * Returns multicall entries to call redeemDiff on the RWA ERC-4626 adapter for the given credit manager.
1164
885
  * Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess RWA vault tokens.
@@ -1167,7 +888,7 @@ interface ICreditAccountsService extends Construct {
1167
888
  * @param creditManager - Credit manager address
1168
889
  * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
1169
890
  */
1170
- getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
891
+ assembleRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
1171
892
  /**
1172
893
  * Returns multicall entries to call depositDiff on the RWA ERC-4626 adapter for the given credit manager.
1173
894
  * Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
@@ -1176,50 +897,25 @@ interface ICreditAccountsService extends Construct {
1176
897
  * @param creditManager - Credit manager address
1177
898
  * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
1178
899
  */
1179
- getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
900
+ assembleDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
1180
901
  /**
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.
902
+ * Builds repay multicall calls without price feed updates: add collateral,
903
+ * wrap calls, disable quotas, decrease debt, redeem/unwrap, claim rewards,
904
+ * withdraw assets. Does not prepend price updates and does not build the
905
+ * facade transaction.
1194
906
  *
1195
907
  * @param props - {@link AssembleRepayCreditAccountCallsProps}
1196
908
  * @returns Raw facade multicall payload for repay (before price feed updates)
1197
909
  */
1198
910
  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
911
  /**
1216
912
  * Claims farm rewards and optionally updates quotas
1217
913
  * - Claim rewards is executed in the following order: price update -> execute claim calls ->
1218
914
  * -> (optionally: update quotas)
1219
915
  * @param props - {@link ClaimFarmRewardsProps}
1220
- * @return All necessary data to execute the transaction (call, credit facade)
916
+ * @return Raw transaction ready to be signed and sent
1221
917
  */
1222
- claimFarmRewards(props: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
918
+ claimFarmRewards(props: ClaimFarmRewardsProps): Promise<RawTx>;
1223
919
  }
1224
920
  //#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 };
921
+ export { AccountToCheck, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ClaimFarmRewardsProps, CloseCreditAccountResult, CreditAccountFilter, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerFilter, CreditManagerOperationResult, EncodableCreditAccountOperation, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, ListStrategyPositionsProps, OpenCAProps, PartiallyLiquidateProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, Rewards, SetBotProps };
@@ -1,8 +1,8 @@
1
1
  import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION } from "./address-provider.js";
2
2
  import { ADDRESS_0X0, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED } from "./addresses.js";
3
3
  import { BotPermissions, botPermissionsToString } from "./bot-permissions.js";
4
- import { LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY } from "./math.js";
4
+ import { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY } from "./math.js";
5
5
  import { BLOCKS_PER_WEEK_BY_NETWORK, RAMP_DURATION_BY_NETWORK } from "./networks.js";
6
6
  import { PERIPHERY_CONTRACTS, PeripheryContract } from "./periphery.js";
7
7
  import { VERSION_RANGE_310, VersionRange, isV310, isVersionRange } from "./versions.js";
8
- export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, BLOCKS_PER_WEEK_BY_NETWORK, BotPermissions, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PRICE_DECIMALS, PRICE_DECIMALS_POW, PeripheryContract, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, VERSION_RANGE_310, VersionRange, WAD, WAD_DECIMALS_POW, botPermissionsToString, halfRAY, isV310, isVersionRange };
8
+ export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, BLOCKS_PER_WEEK_BY_NETWORK, BotPermissions, DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PRICE_DECIMALS, PRICE_DECIMALS_POW, PeripheryContract, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, VERSION_RANGE_310, VersionRange, WAD, WAD_DECIMALS_POW, botPermissionsToString, halfRAY, isV310, isVersionRange };
@@ -16,5 +16,9 @@ declare const PERCENTAGE_FACTOR = 10000n;
16
16
  declare const PERCENTAGE_FACTOR_1KK: bigint;
17
17
  declare const LEVERAGE_DECIMALS = 100n;
18
18
  declare const SLIPPAGE_DECIMALS = 100n;
19
+ /**
20
+ * Token balances at or below this threshold are treated as dust and ignored.
21
+ **/
22
+ declare const DUST_THRESHOLD = 10n;
19
23
  //#endregion
20
- export { LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY };
24
+ export { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY };