@gearbox-protocol/sdk 14.4.2 → 14.4.3

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.
@@ -453,6 +453,20 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
453
453
  creditFacade: cm.creditFacade
454
454
  };
455
455
  }
456
+ /**
457
+ * {@inheritDoc ICreditAccountsService.defaultPartialLiquidationParams}
458
+ */
459
+ defaultPartialLiquidationParams(ca) {
460
+ const tokenOut = this.#getBestTokenOut(ca);
461
+ const optimalHF = this.getOptimalHFForPartialLiquidation(ca);
462
+ const repaidAmount = this.#calcOptimalRepaidAmount(ca, tokenOut, optimalHF);
463
+ const minSeizedAmount = this.#calcMinSeizedAmount(
464
+ ca,
465
+ tokenOut,
466
+ repaidAmount
467
+ );
468
+ return { tokenOut, optimalHF, repaidAmount, minSeizedAmount };
469
+ }
456
470
  /**
457
471
  * {@inheritDoc ICreditAccountsService.partiallyLiquidate}
458
472
  */
@@ -448,6 +448,20 @@ class CreditAccountsServiceV310 extends SDKConstruct {
448
448
  creditFacade: cm.creditFacade
449
449
  };
450
450
  }
451
+ /**
452
+ * {@inheritDoc ICreditAccountsService.defaultPartialLiquidationParams}
453
+ */
454
+ defaultPartialLiquidationParams(ca) {
455
+ const tokenOut = this.#getBestTokenOut(ca);
456
+ const optimalHF = this.getOptimalHFForPartialLiquidation(ca);
457
+ const repaidAmount = this.#calcOptimalRepaidAmount(ca, tokenOut, optimalHF);
458
+ const minSeizedAmount = this.#calcMinSeizedAmount(
459
+ ca,
460
+ tokenOut,
461
+ repaidAmount
462
+ );
463
+ return { tokenOut, optimalHF, repaidAmount, minSeizedAmount };
464
+ }
451
465
  /**
452
466
  * {@inheritDoc ICreditAccountsService.partiallyLiquidate}
453
467
  */
@@ -6,7 +6,7 @@ import type { KYCOpenAccountRequirements } from "../market/kyc/index.js";
6
6
  import type { OnchainSDK } from "../OnchainSDK.js";
7
7
  import { type RouterCASlice } from "../router/index.js";
8
8
  import type { MultiCall, RawTx } from "../types/index.js";
9
- import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
9
+ import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
10
10
  /**
11
11
  * Options for configuring the credit account service.
12
12
  **/
@@ -64,6 +64,10 @@ export declare class CreditAccountsServiceV310 extends SDKConstruct implements I
64
64
  * {@inheritDoc ICreditAccountsService.fullyLiquidate}
65
65
  **/
66
66
  fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
67
+ /**
68
+ * {@inheritDoc ICreditAccountsService.defaultPartialLiquidationParams}
69
+ */
70
+ defaultPartialLiquidationParams(ca: CreditAccountData): DefaultPartialLiquidationParams;
67
71
  /**
68
72
  * {@inheritDoc ICreditAccountsService.partiallyLiquidate}
69
73
  */
@@ -488,6 +488,24 @@ export interface FullyLiquidateProps {
488
488
  */
489
489
  debtOnly?: boolean;
490
490
  }
491
+ export interface DefaultPartialLiquidationParams {
492
+ /**
493
+ * {@link PartiallyLiquidateProps.tokenOut}
494
+ */
495
+ tokenOut: Address;
496
+ /**
497
+ * {@link PartiallyLiquidateProps.repaidAmount}
498
+ */
499
+ repaidAmount: bigint;
500
+ /**
501
+ * {@link PartiallyLiquidateProps.minSeizedAmount}
502
+ */
503
+ minSeizedAmount: bigint;
504
+ /**
505
+ * {@link PartiallyLiquidateProps.optimalHF}
506
+ */
507
+ optimalHF: bigint;
508
+ }
491
509
  export interface PartiallyLiquidateProps {
492
510
  /**
493
511
  * Credit account to liquidate
@@ -510,7 +528,9 @@ export interface PartiallyLiquidateProps {
510
528
  repaidAmount?: bigint;
511
529
  /**
512
530
  * Minimum amount of `token` to seize from `creditAccount`.
513
- * If omitted, computed internally
531
+ * If `token` is a phantom token, it's withdrawn first, and its `depositedToken` is then sent to the liquidator.
532
+ * In this case, `minSeizedAmount` is denominated in `depositedToken`.
533
+ * If omitted, computed internally.
514
534
  */
515
535
  minSeizedAmount?: bigint;
516
536
  /**
@@ -713,14 +733,19 @@ export interface ICreditAccountsService extends Construct {
713
733
  * @returns Transaction data and optional loss policy data
714
734
  */
715
735
  fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
736
+ /**
737
+ * Calculates default partial liquidation parameters for a credit account
738
+ * These parameters are used as defaults for the {@link partiallyLiquidate} method.
739
+ * @param ca - Credit account to partially liquidate
740
+ */
741
+ defaultPartialLiquidationParams(ca: CreditAccountData): DefaultPartialLiquidationParams;
716
742
  /**
717
743
  * Generates transaction to partially liquidate credit account;
718
744
  *
719
745
  * Transaction partially liquidates credit account's debt in exchange for discounted collateral
720
746
  * by transferring underlying from the caller (requires approval to the credit manager) and uses it to repay
721
747
  * account's debt and pay fees to the treasury
722
- * Transfers chosen collateral token at discounted oracle price to the liquidator (liquidation discount
723
- * and fee are the same as for full liquidations, though fees are not deposited into the pool)
748
+ * Transfers chosen collateral token at discounted oracle price to the liquidator
724
749
  *
725
750
  * @param props - {@link PartiallyLiquidateProps}
726
751
  * @returns Raw transaction ready to be signed and sent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.4.2",
3
+ "version": "14.4.3",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",