@gearbox-protocol/sdk 14.1.1 → 15.0.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 (30) hide show
  1. package/dist/cjs/plugins/accounts/AccountsPlugin.js +1 -2
  2. package/dist/cjs/sdk/OnchainSDK.js +12 -0
  3. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1448 -23
  4. package/dist/cjs/sdk/accounts/index.js +0 -4
  5. package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +6 -0
  6. package/dist/cjs/sdk/market/oracle/PriceOracleV310Contract.js +26 -0
  7. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -0
  8. package/dist/esm/plugins/accounts/AccountsPlugin.js +2 -7
  9. package/dist/esm/sdk/OnchainSDK.js +14 -0
  10. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1466 -23
  11. package/dist/esm/sdk/accounts/index.js +0 -2
  12. package/dist/esm/sdk/accounts/multicall-utils.js +1 -5
  13. package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +6 -0
  14. package/dist/esm/sdk/market/oracle/PriceOracleV310Contract.js +26 -0
  15. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -0
  16. package/dist/types/sdk/OnchainSDK.d.ts +10 -0
  17. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +181 -3
  18. package/dist/types/sdk/accounts/index.d.ts +0 -2
  19. package/dist/types/sdk/accounts/types.d.ts +56 -0
  20. package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +2 -0
  21. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +5 -0
  22. package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +4 -0
  23. package/dist/types/sdk/market/oracle/types.d.ts +9 -0
  24. package/package.json +1 -1
  25. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +0 -1411
  26. package/dist/cjs/sdk/accounts/createCreditAccountService.js +0 -35
  27. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +0 -1405
  28. package/dist/esm/sdk/accounts/createCreditAccountService.js +0 -11
  29. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +0 -226
  30. package/dist/types/sdk/accounts/createCreditAccountService.d.ts +0 -9
@@ -1,4 +1,2 @@
1
- export * from "./AbstractCreditAccountsService.js";
2
1
  export * from "./CreditAccountsServiceV310.js";
3
- export * from "./createCreditAccountService.js";
4
2
  export * from "./types.js";
@@ -1,8 +1,4 @@
1
- import {
2
- decodeFunctionData,
3
- getAbiItem,
4
- toFunctionSelector
5
- } from "viem";
1
+ import { decodeFunctionData, getAbiItem, toFunctionSelector } from "viem";
6
2
  import { iCreditFacadeMulticallV310Abi } from "../../abi/310/generated.js";
7
3
  import { AddressMap } from "../utils/AddressMap.js";
8
4
  import { AddressSet } from "../utils/AddressSet.js";
@@ -60,6 +60,12 @@ class CreditFacadeV310Contract extends CreditFacadeV310BaseContract {
60
60
  args: lossPolicyData ? [ca, to, calls, lossPolicyData] : [ca, to, calls]
61
61
  });
62
62
  }
63
+ partiallyLiquidateCreditAccount(ca, token, repaidAmount, minSeizedAmount, to, updates) {
64
+ return this.createRawTx({
65
+ functionName: "partiallyLiquidateCreditAccount",
66
+ args: [ca, token, repaidAmount, minSeizedAmount, to, updates]
67
+ });
68
+ }
63
69
  closeCreditAccount(ca, calls) {
64
70
  return this.createRawTx({
65
71
  functionName: "closeCreditAccount",
@@ -5,6 +5,7 @@ import {
5
5
  iCreditFacadeMulticallV310Abi,
6
6
  iPriceOracleV310Abi
7
7
  } from "../../../abi/310/generated.js";
8
+ import { simulateWithPriceUpdates } from "../../utils/viem/simulateWithPriceUpdates.js";
8
9
  import {
9
10
  getRawPriceUpdates
10
11
  } from "../pricefeeds/index.js";
@@ -48,6 +49,31 @@ class PriceOracleV310Contract extends PriceOracleBaseContract {
48
49
  ]
49
50
  };
50
51
  }
52
+ /**
53
+ * {@inheritDoc IPriceOracleContract.updateAndConvert}
54
+ **/
55
+ async updateAndConvert(from, to, amount) {
56
+ const fromFeed = this.mainPriceFeeds.mustGet(from).priceFeed;
57
+ const toFeed = this.mainPriceFeeds.mustGet(to).priceFeed;
58
+ const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs([
59
+ fromFeed,
60
+ toFeed
61
+ ]);
62
+ const [result] = await simulateWithPriceUpdates(this.sdk.client, {
63
+ priceUpdates: updates.txs,
64
+ contracts: [
65
+ {
66
+ abi: this.contract.abi,
67
+ functionName: "convert",
68
+ args: [amount, from, to],
69
+ address: this.contract.address
70
+ }
71
+ ],
72
+ strictPrices: true,
73
+ gas: this.sdk.gasLimit
74
+ });
75
+ return result;
76
+ }
51
77
  processLog(log) {
52
78
  switch (log.eventName) {
53
79
  case "SetPriceFeed":
@@ -85,6 +85,9 @@ class PriceFeedRegister extends SDKConstruct {
85
85
  updateables = this.sdk.marketRegister.priceOracles.flatMap((o) => o.reservePriceFeeds.values()).flatMap((pf) => pf.priceFeed.updatableDependencies());
86
86
  }
87
87
  }
88
+ if (updateables.length === 0) {
89
+ return { txs: [], timestamp: 0 };
90
+ }
88
91
  const txs = [];
89
92
  const latestUpdate = {
90
93
  updates: [],
@@ -1,6 +1,7 @@
1
1
  import type { Address } from "viem";
2
2
  import { type PublicClient, type Transport } from "viem";
3
3
  import type { HttpRpcClientOptions } from "viem/utils";
4
+ import { type ICreditAccountsService } from "./accounts/index.js";
4
5
  import type { BaseState, IBaseContract } from "./base/index.js";
5
6
  import { ChainContractsRegister } from "./base/index.js";
6
7
  import type { GearboxChain, NetworkType } from "./chain/chains.js";
@@ -11,6 +12,7 @@ import { MarketRegister } from "./market/MarketRegister.js";
11
12
  import { PriceFeedRegister } from "./market/pricefeeds/index.js";
12
13
  import type { PythOptions, RedstoneOptions } from "./market/pricefeeds/updates/index.js";
13
14
  import type { PluginsMap } from "./plugins/index.js";
15
+ import { type IPoolsService } from "./pools/index.js";
14
16
  import { type IRouterContract } from "./router/index.js";
15
17
  import type { GearboxState, GearboxStateHuman, ILogger } from "./types/index.js";
16
18
  /**
@@ -177,6 +179,14 @@ export declare class OnchainSDK<const Plugins extends PluginsMap = {}> extends C
177
179
  * When `true`, the SDK throws on unrecognised contract types.
178
180
  **/
179
181
  readonly strictContractTypes: boolean;
182
+ /**
183
+ * Namespace for credit accounts operations.
184
+ */
185
+ readonly accounts: ICreditAccountsService;
186
+ /**
187
+ * Namespace for pool operations.
188
+ */
189
+ readonly pools: IPoolsService;
180
190
  /**
181
191
  * @param network - Gearbox network type (e.g. `"Mainnet"`, `"Monad"`).
182
192
  * @param clientOptions - Connection options (RPC URLs, transport, or client).
@@ -1,5 +1,28 @@
1
- import { AbstractCreditAccountService } from "./AbstractCreditAccountsService.js";
2
- import type { ClaimFarmRewardsProps, CreditAccountOperationResult, CreditManagerOperationResult, ICreditAccountsService, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, SetBotProps, WithdrawCollateralProps } from "./types.js";
1
+ import type { Address } from "viem";
2
+ import type { CreditAccountData } from "../base/index.js";
3
+ import { SDKConstruct } from "../base/index.js";
4
+ import { type PriceUpdate } from "../market/index.js";
5
+ import type { KYCOpenAccountRequirements } from "../market/kyc/index.js";
6
+ import type { OnchainSDK } from "../OnchainSDK.js";
7
+ import { type RouterCASlice } from "../router/index.js";
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";
10
+ /**
11
+ * Options for configuring the credit account service.
12
+ **/
13
+ export interface CreditAccountServiceOptions {
14
+ /**
15
+ * Maximum number of credit accounts to fetch per compressor call.
16
+ * When set, accounts are loaded in batches of this size until all are fetched.
17
+ **/
18
+ batchSize?: number;
19
+ }
20
+ /**
21
+ * Returns the withdrawal compressor contract address for the given chain, or `undefined` if none is configured.
22
+ * @param chainId - Numeric chain ID.
23
+ * @returns Withdrawal compressor address, or `undefined`.
24
+ **/
25
+ export declare function getWithdrawalCompressorAddress(chainId: number): `0x${string}`;
3
26
  /**
4
27
  * Service for querying and operating on Gearbox credit accounts.
5
28
  *
@@ -9,7 +32,138 @@ import type { ClaimFarmRewardsProps, CreditAccountOperationResult, CreditManager
9
32
  *
10
33
  * @see {@link ICreditAccountsService}
11
34
  **/
12
- export declare class CreditAccountServiceV310 extends AbstractCreditAccountService implements ICreditAccountsService {
35
+ export declare class CreditAccountsServiceV310 extends SDKConstruct implements ICreditAccountsService {
36
+ #private;
37
+ constructor(sdk: OnchainSDK, options?: CreditAccountServiceOptions);
38
+ setBatchSize(batchSize: number): void;
39
+ /**
40
+ * {@inheritDoc ICreditAccountsService.getCreditAccountData}
41
+ **/
42
+ getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData<true> | undefined>;
43
+ /**
44
+ * {@inheritDoc ICreditAccountsService.getCreditAccounts}
45
+ **/
46
+ getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
47
+ /**
48
+ * {@inheritDoc ICreditAccountsService.getBorrowerCreditAccounts}
49
+ **/
50
+ getBorrowerCreditAccounts(borrower: Address, options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData<true>>>;
51
+ /**
52
+ * {@inheritDoc ICreditAccountsService.getRewards}
53
+ **/
54
+ getRewards(creditAccount: Address): Promise<Array<Rewards>>;
55
+ /**
56
+ * {@inheritDoc ICreditAccountsService.getConnectedBots}
57
+ **/
58
+ getConnectedBots(accountsToCheck: Array<AccountToCheck>, legacyMigrationBot: Address | undefined, additionalBots: Array<Address>): Promise<{
59
+ legacy: GetConnectedBotsResult;
60
+ legacyMigration: GetConnectedMigrationBotsResult;
61
+ additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
62
+ }>;
63
+ /**
64
+ * {@inheritDoc ICreditAccountsService.fullyLiquidate}
65
+ **/
66
+ fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
67
+ /**
68
+ * {@inheritDoc ICreditAccountsService.calcMinSeizedAmount}
69
+ */
70
+ calcMinSeizedAmount(props: PartiallyLiquidateProps): Promise<bigint>;
71
+ /**
72
+ * {@inheritDoc ICreditAccountsService.partiallyLiquidate}
73
+ */
74
+ partiallyLiquidate(props: PartiallyLiquidateProps): Promise<RawTx>;
75
+ /**
76
+ * {@inheritDoc ICreditAccountsService.closeCreditAccount}
77
+ **/
78
+ closeCreditAccount({ operation, assetsToWithdraw, creditAccount: ca, to, slippage, closePath, }: CloseCreditAccountProps): Promise<CloseCreditAccountResult>;
79
+ /**
80
+ * {@inheritDoc ICreditAccountsService.updateQuotas}
81
+ **/
82
+ updateQuotas({ minQuota, averageQuota, creditAccount, }: UpdateQuotasProps): Promise<CreditAccountOperationResult>;
83
+ /**
84
+ * {@inheritDoc ICreditAccountsService.addCollateral}
85
+ **/
86
+ addCollateral({ creditAccount, asset, permit, ethAmount, minQuota, averageQuota, }: AddCollateralProps): Promise<CreditAccountOperationResult>;
87
+ /**
88
+ * {@inheritDoc ICreditAccountsService.changeDebt}
89
+ **/
90
+ changeDebt({ creditAccount, amount, collateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
91
+ /**
92
+ * {@inheritDoc ICreditAccountsService.executeSwap}
93
+ **/
94
+ executeSwap({ creditAccount, calls: swapCalls, minQuota, averageQuota, }: ExecuteSwapProps): Promise<CreditAccountOperationResult>;
95
+ /**
96
+ * {@inheritDoc ICreditAccountsService.previewDelayedWithdrawal}
97
+ **/
98
+ previewDelayedWithdrawal({ creditAccount, amount, token, }: PreviewDelayedWithdrawalProps): Promise<PreviewDelayedWithdrawalResult>;
99
+ /**
100
+ * {@inheritDoc ICreditAccountsService.getPendingWithdrawals}
101
+ **/
102
+ getPendingWithdrawals({ creditAccount, }: GetPendingWithdrawalsProps): Promise<GetPendingWithdrawalsResult>;
103
+ /**
104
+ * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
105
+ **/
106
+ startDelayedWithdrawal({ creditAccount, minQuota, averageQuota, preview, }: StartDelayedWithdrawalProps): Promise<CreditAccountOperationResult>;
107
+ /**
108
+ * {@inheritDoc ICreditAccountsService.claimDelayed}
109
+ **/
110
+ claimDelayed({ creditAccount, minQuota, averageQuota, claimableNow, }: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
111
+ /**
112
+ * {@inheritDoc ICreditAccountsService.getApprovalAddress}
113
+ **/
114
+ getApprovalAddress(options: GetApprovalAddressProps): Promise<Address>;
115
+ /**
116
+ * {@inheritDoc ICreditAccountsService.getOpenAccountRequirements}
117
+ */
118
+ getOpenAccountRequirements(borrower: Address, creditManager: Address, props: GetOpenAccountRequirementsProps): Promise<KYCOpenAccountRequirements | undefined>;
119
+ /**
120
+ * {@inheritDoc ICreditAccountsService.openCA}
121
+ **/
122
+ openCA(props: OpenCAProps): Promise<CreditAccountOperationResult>;
123
+ /**
124
+ * {@inheritDoc ICreditAccountsService.getBorrowRate}
125
+ **/
126
+ getBorrowRate(ca: CreditAccountData): bigint;
127
+ /**
128
+ * {@inheritDoc ICreditAccountsService.getOptimalHFForPartialLiquidation}
129
+ **/
130
+ getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
131
+ /**
132
+ * Returns multicall entries to redeem (unwrap) KYC ERC-4626 vault shares into underlying for the given credit manager.
133
+ * Used when withdrawing debt from a KYC market: redeems adapter vault shares so the underlying can be withdrawn.
134
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
135
+ * @param amount - Number of vault shares (adapter tokens) to redeem
136
+ * @param creditManager - Credit manager address
137
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
138
+ */
139
+ getKYCUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
140
+ /**
141
+ * Returns multicall entries to deposit (wrap) underlying into KYC ERC-4626 vault shares for the given credit manager.
142
+ * Used when adding debt on a KYC market: deposits underlying into the adapter vault so shares are minted on the account.
143
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
144
+ * @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
145
+ * @param creditManager - Credit manager address
146
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
147
+ */
148
+ getKYCWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
149
+ /**
150
+ * Returns multicall entries to call redeemDiff on the KYC ERC-4626 adapter for the given credit manager.
151
+ * Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess KYC vault tokens.
152
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
153
+ * @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
154
+ * @param creditManager - Credit manager address
155
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
156
+ */
157
+ getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
158
+ /**
159
+ * Returns multicall entries to call depositDiff on the KYC ERC-4626 adapter for the given credit manager.
160
+ * Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
161
+ * Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
162
+ * @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
163
+ * @param creditManager - Credit manager address
164
+ * @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
165
+ */
166
+ getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
13
167
  /**
14
168
  * {@inheritDoc ICreditAccountsService.setBot}
15
169
  */
@@ -30,4 +184,28 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
30
184
  * {@inheritDoc ICreditAccountsService.claimFarmRewards}
31
185
  */
32
186
  claimFarmRewards({ calls: externalCalls, creditAccount: ca, minQuota, averageQuota, tokensToClaim, }: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
187
+ /**
188
+ * Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
189
+ * {@inheritDoc ICreditAccountsService.getOnDemandPriceUpdates}
190
+ **/
191
+ getOnDemandPriceUpdates(account: CreditAccountTokensSlice, ignoreReservePrices?: boolean): Promise<PriceUpdate[]>;
192
+ /**
193
+ * {@inheritDoc ICreditAccountsService.multicall}
194
+ */
195
+ multicall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
196
+ ignoreReservePrices?: boolean;
197
+ }): Promise<RawTx>;
198
+ /**
199
+ * {@inheritDoc ICreditAccountsService.botMulticall}
200
+ */
201
+ botMulticall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
202
+ ignoreReservePrices?: boolean;
203
+ }): Promise<RawTx>;
204
+ /**
205
+ * Returns addresses of market configurators
206
+ */
207
+ private get marketConfigurators();
208
+ private get rewardCompressor();
209
+ private get peripheryCompressor();
210
+ private get compressor();
33
211
  }
@@ -1,4 +1,2 @@
1
- export * from "./AbstractCreditAccountsService.js";
2
1
  export * from "./CreditAccountsServiceV310.js";
3
- export * from "./createCreditAccountService.js";
4
2
  export * from "./types.js";
@@ -488,6 +488,42 @@ export interface FullyLiquidateProps {
488
488
  */
489
489
  debtOnly?: boolean;
490
490
  }
491
+ export interface CalcMinSeizedAmountProps {
492
+ /**
493
+ * Credit account to liquidate
494
+ */
495
+ account: RouterCASlice;
496
+ /**
497
+ * Collateral token to seize
498
+ */
499
+ token: Address;
500
+ /**
501
+ * Amount of underlying token to repay
502
+ */
503
+ repaidAmount: bigint;
504
+ }
505
+ export interface PartiallyLiquidateProps {
506
+ /**
507
+ * Credit account to liquidate
508
+ */
509
+ account: RouterCASlice;
510
+ /**
511
+ * Address to transfer underlying left after liquidation
512
+ */
513
+ to: Address;
514
+ /**
515
+ * Collateral token to seize
516
+ */
517
+ token: Address;
518
+ /**
519
+ * Amount of underlying token to repay
520
+ */
521
+ repaidAmount: bigint;
522
+ /**
523
+ * Minimum amount of `token` to seize from `creditAccount`
524
+ */
525
+ minSeizedAmount: bigint;
526
+ }
491
527
  /**
492
528
  * EIP-2612 permit signature data for a token, enabling gasless approval for credit account operations.
493
529
  **/
@@ -681,6 +717,26 @@ export interface ICreditAccountsService extends Construct {
681
717
  * @returns Transaction data and optional loss policy data
682
718
  */
683
719
  fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
720
+ /**
721
+ * Calculates minimum amount of collateral token to seize from credit account
722
+ * for partial liquidation, can be passed to {@link partiallyLiquidate} as `minSeizedAmount`
723
+ * @param props - {@link CalcMinSeizedAmountProps}
724
+ * @returns Minimum amount of collateral token to seize
725
+ */
726
+ calcMinSeizedAmount(props: CalcMinSeizedAmountProps): Promise<bigint>;
727
+ /**
728
+ * Generates transaction to partially liquidate credit account;
729
+ *
730
+ * Transaction partially liquidates credit account's debt in exchange for discounted collateral
731
+ * by transferring underlying from the caller (requires approval to the credit manager) and uses it to repay
732
+ * account's debt and pay fees to the treasury
733
+ * Transfers chosen collateral token at discounted oracle price to the liquidator (liquidation discount
734
+ * and fee are the same as for full liquidations, though fees are not deposited into the pool)
735
+ *
736
+ * @param props - {@link PartiallyLiquidateProps}
737
+ * @returns Raw transaction ready to be signed and sent
738
+ */
739
+ partiallyLiquidate(props: PartiallyLiquidateProps): Promise<RawTx>;
684
740
  /**
685
741
  * Closes credit account or closes credit account and keeps it open with zero debt.
686
742
  * - Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
@@ -1,6 +1,7 @@
1
1
  import type { Address, ContractEventName, Hex, Log } from "viem";
2
2
  import type { ConstructOptions, CreditFacadeState, CreditSuiteState } from "../../base/index.js";
3
3
  import type { CreditFacadeStateHuman, MultiCall, RawTx } from "../../types/index.js";
4
+ import type { PriceUpdate } from "../pricefeeds/index.js";
4
5
  import type { CreditFacadeV310Abi } from "./CreditFacadeV310BaseContract.js";
5
6
  import { CreditFacadeV310BaseContract } from "./CreditFacadeV310BaseContract.js";
6
7
  type abi = CreditFacadeV310Abi;
@@ -12,6 +13,7 @@ export declare class CreditFacadeV310Contract extends CreditFacadeV310BaseContra
12
13
  stateHuman(raw?: boolean): CreditFacadeStateHuman;
13
14
  processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
14
15
  liquidateCreditAccount(ca: Address, to: Address, calls: MultiCall[], lossPolicyData?: Hex): RawTx;
16
+ partiallyLiquidateCreditAccount(ca: Address, token: Address, repaidAmount: bigint, minSeizedAmount: bigint, to: Address, updates: PriceUpdate[]): RawTx;
15
17
  closeCreditAccount(ca: Address, calls: MultiCall[]): RawTx;
16
18
  multicall(ca: Address, calls: MultiCall[]): RawTx;
17
19
  botMulticall(ca: Address, calls: MultiCall[]): RawTx;
@@ -56,6 +56,11 @@ export declare abstract class PriceOracleBaseContract<abi extends Abi | readonly
56
56
  * {@inheritDoc IPriceOracleContract.usesPriceFeed}
57
57
  **/
58
58
  usesPriceFeed(priceFeed: Address): boolean;
59
+ /**
60
+ *
61
+ * {@inheritDoc IPriceOracleContract.updateAndConvert}
62
+ **/
63
+ abstract updateAndConvert(from: Address, to: Address, amount: bigint): Promise<bigint>;
59
64
  /**
60
65
  * {@inheritDoc IPriceOracleContract.convert}
61
66
  **/
@@ -349,6 +349,10 @@ export declare class PriceOracleV310Contract extends PriceOracleBaseContract<abi
349
349
  * @returns
350
350
  */
351
351
  onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates;
352
+ /**
353
+ * {@inheritDoc IPriceOracleContract.updateAndConvert}
354
+ **/
355
+ updateAndConvert(from: Address, to: Address, amount: bigint): Promise<bigint>;
352
356
  processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
353
357
  }
354
358
  export {};
@@ -114,6 +114,15 @@ export interface IPriceOracleContract extends IBaseContract {
114
114
  * @param reserve - Use reserve feeds instead of main.
115
115
  **/
116
116
  convertFromUSD: (to: Address, amount: bigint, reserve?: boolean) => bigint;
117
+ /**
118
+ * Unlike {@link convert}, this method will update the price feeds before converting,
119
+ * and conversion will be peformed onchain using main price feeds
120
+ * @param from
121
+ * @param to
122
+ * @param amount
123
+ * @returns
124
+ */
125
+ updateAndConvert: (from: Address, to: Address, amount: bigint) => Promise<bigint>;
117
126
  /**
118
127
  * @internal
119
128
  **/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.1.1",
3
+ "version": "15.0.0-next.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",