@gearbox-protocol/sdk 8.26.6 → 8.27.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 (40) hide show
  1. package/dist/cjs/plugins/bots/BotsPlugin.js +1 -1
  2. package/dist/cjs/plugins/bots/types.js +3 -3
  3. package/dist/cjs/sdk/accountMigration/AbstractMigrateCreditAccountsService.js +218 -0
  4. package/dist/cjs/sdk/accountMigration/MigrateCreditAccountsServiceV300.js +30 -0
  5. package/dist/cjs/sdk/accountMigration/MigrateCreditAccountsServiceV310.js +30 -0
  6. package/dist/cjs/sdk/accountMigration/createMigrateCreditAccountsService.js +41 -0
  7. package/dist/cjs/sdk/accountMigration/index.js +26 -0
  8. package/dist/cjs/sdk/accountMigration/types.js +28 -0
  9. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +42 -14
  10. package/dist/cjs/sdk/accounts/constants.js +3 -0
  11. package/dist/cjs/sdk/index.js +2 -0
  12. package/dist/cjs/sdk/sdk-legacy/core/transactions.js +20 -0
  13. package/dist/esm/plugins/bots/BotsPlugin.js +2 -2
  14. package/dist/esm/plugins/bots/types.js +2 -2
  15. package/dist/esm/sdk/accountMigration/AbstractMigrateCreditAccountsService.js +197 -0
  16. package/dist/esm/sdk/accountMigration/MigrateCreditAccountsServiceV300.js +6 -0
  17. package/dist/esm/sdk/accountMigration/MigrateCreditAccountsServiceV310.js +6 -0
  18. package/dist/esm/sdk/accountMigration/createMigrateCreditAccountsService.js +17 -0
  19. package/dist/esm/sdk/accountMigration/index.js +3 -0
  20. package/dist/esm/sdk/accountMigration/types.js +4 -0
  21. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +47 -15
  22. package/dist/esm/sdk/accounts/constants.js +3 -0
  23. package/dist/esm/sdk/index.js +1 -0
  24. package/dist/esm/sdk/sdk-legacy/core/transactions.js +19 -0
  25. package/dist/types/plugins/bots/PartialLiquidationBotV300Contract.d.ts +3 -3
  26. package/dist/types/plugins/bots/types.d.ts +3 -3
  27. package/dist/types/sdk/accountMigration/AbstractMigrateCreditAccountsService.d.ts +39 -0
  28. package/dist/types/sdk/accountMigration/MigrateCreditAccountsServiceV300.d.ts +4 -0
  29. package/dist/types/sdk/accountMigration/MigrateCreditAccountsServiceV310.d.ts +4 -0
  30. package/dist/types/sdk/accountMigration/createMigrateCreditAccountsService.d.ts +8 -0
  31. package/dist/types/sdk/accountMigration/index.d.ts +3 -0
  32. package/dist/types/sdk/accountMigration/types.d.ts +74 -0
  33. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +9 -5
  34. package/dist/types/sdk/accounts/types.d.ts +37 -9
  35. package/dist/types/sdk/index.d.ts +1 -0
  36. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -2
  37. package/dist/types/sdk/market/oracle/types.d.ts +2 -2
  38. package/dist/types/sdk/sdk-legacy/core/creditAccount.d.ts +2 -2
  39. package/dist/types/sdk/sdk-legacy/core/transactions.d.ts +13 -1
  40. package/package.json +1 -1
@@ -1,10 +1,11 @@
1
1
  import type { Address, ContractFunctionArgs } from "viem";
2
2
  import type { iCreditAccountCompressorAbi } from "../../abi/compressors.js";
3
- import type { BotType } from "../../plugins/bots/types.js";
3
+ import type { LiquidationBotType as LiquidationBotTypeSDK } from "../../plugins/bots/types.js";
4
+ import type { MigrationBotType } from "../accountMigration/types.js";
4
5
  import type { ConnectedBotData, CreditAccountData } from "../base/index.js";
5
6
  import type { SDKConstruct } from "../base/SDKConstruct.js";
6
- import type { CreditSuite, OnDemandPriceUpdates, UpdatePriceFeedsResult } from "../market/index.js";
7
- import type { Asset, RouterCASlice, RouterCloseResult } from "../router/index.js";
7
+ import type { CreditSuite, OnDemandPriceUpdates, PriceUpdateV300, PriceUpdateV310, UpdatePriceFeedsResult } from "../market/index.js";
8
+ import type { Asset, CreditAccountTokensSlice, RouterCASlice, RouterCloseResult } from "../router/index.js";
8
9
  import type { MultiCall, RawTx } from "../types/index.js";
9
10
  export type GetCreditAccountsArgs = ContractFunctionArgs<typeof iCreditAccountCompressorAbi, "pure" | "view", "getCreditAccounts">;
10
11
  export interface CreditAccountFilter {
@@ -158,11 +159,11 @@ export interface ExecuteSwapProps extends PrepareUpdateQuotasProps {
158
159
  }
159
160
  export interface StartDelayedWithdrawalProps extends PrepareUpdateQuotasProps {
160
161
  /**
161
- * Amount of source token (ex. sp0xlrt)
162
+ * Amount of source token (ex. cp0xlrt)
162
163
  */
163
164
  sourceAmount: bigint;
164
165
  /**
165
- * Address of source token (ex. sp0xlrt)
166
+ * Address of source token (ex. cp0xlrt)
166
167
  */
167
168
  sourceToken: Address;
168
169
  /**
@@ -328,8 +329,9 @@ export interface Rewards {
328
329
  BotBaseType = "liquidationProtection" | someOtherBaseType
329
330
  BotDetailedType = LiquidationBotType | someOtherDetailedType
330
331
  * */
331
- export type BotBaseType = "LIQUIDATION_PROTECTION";
332
- export type LiquidationBotType = Exclude<BotType, "PARTIAL_LIQUIDATION_BOT">;
332
+ export type BotBaseType = "LIQUIDATION_PROTECTION" | "MIGRATION";
333
+ export type LiquidationBotType = Exclude<LiquidationBotTypeSDK, "PARTIAL_LIQUIDATION_BOT">;
334
+ export type { MigrationBotType };
333
335
  export interface SetBotProps {
334
336
  /**
335
337
  * Address of a bot that is being updated
@@ -357,6 +359,21 @@ export type GetConnectedBotsResult = Array<{
357
359
  result?: undefined;
358
360
  status: "failure";
359
361
  }>;
362
+ export type GetConnectedMigrationBotsResult = {
363
+ result: ({
364
+ error: Error;
365
+ result?: undefined;
366
+ status: "failure";
367
+ } | {
368
+ error?: undefined;
369
+ result: readonly [bigint, boolean, boolean] | readonly [bigint, boolean];
370
+ status: "success";
371
+ })[];
372
+ migrationBot: {
373
+ botAddress: Address;
374
+ previewerAddress: Address;
375
+ };
376
+ } | undefined;
360
377
  export interface ICreditAccountsService extends SDKConstruct {
361
378
  /**
362
379
  * Returns single credit account data, or undefined if it's not found
@@ -391,7 +408,10 @@ export interface ICreditAccountsService extends SDKConstruct {
391
408
  getConnectedBots(accountsToCheck: Array<{
392
409
  creditAccount: Address;
393
410
  creditManager: Address;
394
- }>): Promise<GetConnectedBotsResult>;
411
+ }>): Promise<{
412
+ legacy: GetConnectedBotsResult;
413
+ legacyMigration: GetConnectedMigrationBotsResult;
414
+ }>;
395
415
  /**
396
416
  * V3.1 method, throws in V3. Connects/disables a bot and updates prices
397
417
  * @param props - {@link SetBotProps}
@@ -499,7 +519,15 @@ export interface ICreditAccountsService extends SDKConstruct {
499
519
  * @param desiredQuotas
500
520
  * @returns
501
521
  */
502
- getOnDemandPriceUpdates(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<OnDemandPriceUpdates>;
522
+ getOnDemandPriceUpdates(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<OnDemandPriceUpdates<PriceUpdateV310 | PriceUpdateV300>>;
523
+ /**
524
+ * Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
525
+ * @param creditManager
526
+ * @param creditAccount
527
+ * @param desiredQuotas
528
+ * @returns
529
+ */
530
+ getPriceUpdatesForFacade(creditManager: Address, creditAccount: CreditAccountTokensSlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<Array<MultiCall>>;
503
531
  /**
504
532
  * Withdraws a single collateral from credit account to wallet to and updates quotas;
505
533
  * technically can withdraw several tokens at once
@@ -1,3 +1,4 @@
1
+ export * from "./accountMigration/index.js";
1
2
  export * from "./accounts/index.js";
2
3
  export * from "./base/index.js";
3
4
  export * from "./chain/index.js";
@@ -5,7 +5,7 @@ import { BaseContract } from "../../base/index.js";
5
5
  import type { GearboxSDK } from "../../GearboxSDK.js";
6
6
  import type { PriceOracleStateHuman } from "../../types/index.js";
7
7
  import { AddressMap } from "../../utils/index.js";
8
- import type { IPriceFeedContract, UpdatePriceFeedsResult } from "../pricefeeds/index.js";
8
+ import type { IPriceFeedContract, PriceUpdateV300, PriceUpdateV310, UpdatePriceFeedsResult } from "../pricefeeds/index.js";
9
9
  import { PriceFeedRef } from "../pricefeeds/index.js";
10
10
  import PriceFeedAnswerMap from "./PriceFeedAnswerMap.js";
11
11
  import type { OnDemandPriceUpdates } from "./types";
@@ -41,7 +41,7 @@ export declare abstract class PriceOracleBaseContract<abi extends Abi | readonly
41
41
  * @returns
42
42
  */
43
43
  updatePriceFeeds(): Promise<UpdatePriceFeedsResult>;
44
- abstract onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates;
44
+ abstract onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates<PriceUpdateV310 | PriceUpdateV300>;
45
45
  /**
46
46
  * Gets main price for given token
47
47
  * Throws if token price feed is not found or answer is not successful
@@ -3,7 +3,7 @@ import type { iPriceFeedCompressorAbi } from "../../../abi/compressors.js";
3
3
  import type { IBaseContract } from "../../base/index.js";
4
4
  import type { MultiCall, PriceOracleStateHuman } from "../../types/index.js";
5
5
  import type { AddressMap } from "../../utils/index.js";
6
- import type { IPriceFeedContract, PriceFeedRef, UpdatePriceFeedsResult } from "../pricefeeds/index.js";
6
+ import type { IPriceFeedContract, PriceFeedRef, PriceUpdateV300, PriceUpdateV310, UpdatePriceFeedsResult } from "../pricefeeds/index.js";
7
7
  import type PriceFeedAnswerMap from "./PriceFeedAnswerMap.js";
8
8
  export interface PriceFeedsForTokensOptions {
9
9
  main?: boolean;
@@ -82,7 +82,7 @@ export interface IPriceOracleContract extends IBaseContract {
82
82
  * @param updates
83
83
  * @returns
84
84
  */
85
- onDemandPriceUpdates: (creditFacade: Address, updates?: UpdatePriceFeedsResult) => OnDemandPriceUpdates;
85
+ onDemandPriceUpdates: (creditFacade: Address, updates?: UpdatePriceFeedsResult) => OnDemandPriceUpdates<PriceUpdateV310 | PriceUpdateV300>;
86
86
  /**
87
87
  * Tries to convert amount of from one token to another, using latest known prices
88
88
  * @param from
@@ -133,8 +133,8 @@ export declare class CreditAccountData_Legacy {
133
133
  constructor(payload: CreditAccountDataPayload);
134
134
  static sortBalances(balances: Record<Address, bigint>, prices: Record<Address, bigint>, tokens: Record<Address, TokenData>): Array<[Address, bigint]>;
135
135
  static sortAssets<T extends Asset>(balances: Array<T>, prices: Record<Address, bigint>, tokens: Record<Address, TokenData>): T[];
136
- static assetComparator<T extends Asset>(t1: T, t2: T, prices1: Record<Address, bigint> | undefined, prices2: Record<Address, bigint> | undefined, tokens1: Record<Address, TokenData> | undefined, tokens2: Record<Address, TokenData> | undefined): 1 | 0 | -1;
137
- static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | 0 | -1;
136
+ static assetComparator<T extends Asset>(t1: T, t2: T, prices1: Record<Address, bigint> | undefined, prices2: Record<Address, bigint> | undefined, tokens1: Record<Address, TokenData> | undefined, tokens2: Record<Address, TokenData> | undefined): 1 | -1 | 0;
137
+ static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | -1 | 0;
138
138
  static amountAbcComparator(t1: bigint, t2: bigint): 1 | -1;
139
139
  isForbidden(token: Address): boolean;
140
140
  isQuoted(token: Address): boolean;
@@ -1,10 +1,11 @@
1
1
  import type { Address } from "viem";
2
2
  import type { Asset } from "../../router/index.js";
3
3
  import type { TokenData } from "../tokens/tokenData.js";
4
+ import type { CreditManagerData_Legacy } from "./creditManager.js";
4
5
  import type { EVMTxProps } from "./eventOrTx.js";
5
6
  import { EVMTx } from "./eventOrTx.js";
6
7
  export interface TxSerialized {
7
- type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimNFT" | "TxClaimRewards" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral" | "TxAddBot" | "TxRemoveBot" | "TxLiquidateAccount" | "TxStakeDiesel" | "TxUnstakeDiesel" | "TxEnableTokens" | "TxFillOrder" | "TxStartDelayedWithdrawal";
8
+ type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimNFT" | "TxClaimRewards" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral" | "TxAddBot" | "TxRemoveBot" | "TxLiquidateAccount" | "TxStakeDiesel" | "TxUnstakeDiesel" | "TxEnableTokens" | "TxFillOrder" | "TxStartDelayedWithdrawal" | "TxMigrateCreditAccount";
8
9
  content: string;
9
10
  }
10
11
  export declare class TxSerializer {
@@ -176,6 +177,17 @@ export declare class TxStartDelayedWithdrawal extends EVMTx {
176
177
  toString(): string;
177
178
  serialize(): TxSerialized;
178
179
  }
180
+ interface TxMigrateCreditAccountProps extends EVMTxProps {
181
+ targetCreditManager: CreditManagerData_Legacy;
182
+ curatorName: string;
183
+ tokensList: Record<Address, TokenData>;
184
+ }
185
+ export declare class TxMigrateCreditAccount extends EVMTx {
186
+ readonly targetCreditManager: string;
187
+ constructor(opts: TxMigrateCreditAccountProps);
188
+ toString(): string;
189
+ serialize(): TxSerialized;
190
+ }
179
191
  interface RepayAccountProps extends EVMTxProps {
180
192
  creditManagerName: string;
181
193
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.26.6",
3
+ "version": "8.27.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",