@gearbox-protocol/sdk 11.8.9 → 11.8.10

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.
@@ -34,15 +34,17 @@ class CreditAccountServiceV310 extends import_AbstractCreditAccountsService.Abst
34
34
  botAddress,
35
35
  botBaseType,
36
36
  stopBot,
37
- creditAccount: ca
37
+ targetContract
38
38
  }) {
39
- const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
40
- const priceUpdatesCalls = await this.getPriceUpdatesForFacade({
41
- creditManager: ca.creditManager,
42
- creditAccount: ca
43
- });
39
+ const cm = this.sdk.marketRegister.findCreditManager(
40
+ targetContract.creditManager
41
+ );
42
+ const priceUpdatesCalls = targetContract.type === "creditAccount" ? await this.getPriceUpdatesForFacade({
43
+ creditManager: targetContract.creditManager,
44
+ creditAccount: targetContract
45
+ }) : [];
44
46
  const addBotCall = {
45
- target: ca.creditFacade,
47
+ target: cm.creditFacade.address,
46
48
  callData: (0, import_viem.encodeFunctionData)({
47
49
  abi: import_generated.iCreditFacadeMulticallV310Abi,
48
50
  functionName: "setBotPermissions",
@@ -50,7 +52,7 @@ class CreditAccountServiceV310 extends import_AbstractCreditAccountsService.Abst
50
52
  })
51
53
  };
52
54
  const calls = [...priceUpdatesCalls, addBotCall];
53
- const tx = cm.creditFacade.multicall(ca.creditAccount, calls);
55
+ const tx = targetContract.type === "creditAccount" ? cm.creditFacade.multicall(targetContract.creditAccount, calls) : void 0;
54
56
  return { tx, calls, creditFacade: cm.creditFacade };
55
57
  }
56
58
  /**
@@ -11,15 +11,17 @@ class CreditAccountServiceV310 extends AbstractCreditAccountService {
11
11
  botAddress,
12
12
  botBaseType,
13
13
  stopBot,
14
- creditAccount: ca
14
+ targetContract
15
15
  }) {
16
- const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
17
- const priceUpdatesCalls = await this.getPriceUpdatesForFacade({
18
- creditManager: ca.creditManager,
19
- creditAccount: ca
20
- });
16
+ const cm = this.sdk.marketRegister.findCreditManager(
17
+ targetContract.creditManager
18
+ );
19
+ const priceUpdatesCalls = targetContract.type === "creditAccount" ? await this.getPriceUpdatesForFacade({
20
+ creditManager: targetContract.creditManager,
21
+ creditAccount: targetContract
22
+ }) : [];
21
23
  const addBotCall = {
22
- target: ca.creditFacade,
24
+ target: cm.creditFacade.address,
23
25
  callData: encodeFunctionData({
24
26
  abi: iCreditFacadeMulticallV310Abi,
25
27
  functionName: "setBotPermissions",
@@ -27,7 +29,7 @@ class CreditAccountServiceV310 extends AbstractCreditAccountService {
27
29
  })
28
30
  };
29
31
  const calls = [...priceUpdatesCalls, addBotCall];
30
- const tx = cm.creditFacade.multicall(ca.creditAccount, calls);
32
+ const tx = targetContract.type === "creditAccount" ? cm.creditFacade.multicall(targetContract.creditAccount, calls) : void 0;
31
33
  return { tx, calls, creditFacade: cm.creditFacade };
32
34
  }
33
35
  /**
@@ -1,10 +1,10 @@
1
1
  import { AbstractCreditAccountService } from "./AbstractCreditAccountsService.js";
2
- import type { ClaimFarmRewardsProps, CreditAccountOperationResult, ICreditAccountsService, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, SetBotProps, WithdrawCollateralProps } from "./types.js";
2
+ import type { ClaimFarmRewardsProps, CreditAccountOperationResult, CreditManagerOperationResult, ICreditAccountsService, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, SetBotProps, WithdrawCollateralProps } from "./types.js";
3
3
  export declare class CreditAccountServiceV310 extends AbstractCreditAccountService implements ICreditAccountsService {
4
4
  /**
5
5
  * Implements {@link ICreditAccountsService.setBot}
6
6
  */
7
- setBot({ botAddress, botBaseType, stopBot, creditAccount: ca, }: SetBotProps): Promise<CreditAccountOperationResult>;
7
+ setBot({ botAddress, botBaseType, stopBot, targetContract, }: SetBotProps): Promise<CreditAccountOperationResult | CreditManagerOperationResult>;
8
8
  /**
9
9
  * Implements {@link ICreditAccountsService.withdrawCollateral}
10
10
  */
@@ -50,6 +50,10 @@ export interface CreditAccountOperationResult {
50
50
  calls: Array<MultiCall>;
51
51
  creditFacade: CreditSuite["creditFacade"];
52
52
  }
53
+ export interface CreditManagerOperationResult {
54
+ calls: Array<MultiCall>;
55
+ creditFacade: CreditSuite["creditFacade"];
56
+ }
53
57
  export type CloseOptions = "close" | "zeroDebt";
54
58
  export interface CloseCreditAccountProps {
55
59
  /**
@@ -370,6 +374,11 @@ export interface Rewards {
370
374
  export type BotBaseType = "LIQUIDATION_PROTECTION" | "MIGRATION";
371
375
  export type LiquidationBotType = Exclude<LiquidationBotTypeSDK, "PARTIAL_LIQUIDATION_BOT">;
372
376
  export type { MigrationBotType };
377
+ interface CMSlice {
378
+ creditManager: Address;
379
+ creditFacade: Address;
380
+ type: "creditManager";
381
+ }
373
382
  export interface SetBotProps {
374
383
  /**
375
384
  * Address of a bot that is being updated
@@ -384,9 +393,13 @@ export interface SetBotProps {
384
393
  */
385
394
  stopBot: boolean;
386
395
  /**
387
- * Minimal credit account data {@link RouterCASlice} on which operation is performed
396
+ * Minimal credit account data {@link RouterCASlice} on which operation is performed; if omitted, credit manager data is used
397
+ * Minimal credit manager data {@link CMSlice} on which operation is performed; used only if credit account is omitted
398
+ * At least one of credit account or credit manager must be provided
388
399
  */
389
- creditAccount: RouterCASlice;
400
+ targetContract: (RouterCASlice & {
401
+ type: "creditAccount";
402
+ }) | CMSlice;
390
403
  }
391
404
  export type GetConnectedBotsResult = Array<{
392
405
  error?: undefined;
@@ -455,7 +468,7 @@ export interface ICreditAccountsService extends SDKConstruct {
455
468
  * @param props - {@link SetBotProps}
456
469
  * @return All necessary data to execute the transaction (call, credit facade)
457
470
  */
458
- setBot: (props: SetBotProps) => Promise<CreditAccountOperationResult>;
471
+ setBot: (props: SetBotProps) => Promise<CreditAccountOperationResult | CreditManagerOperationResult>;
459
472
  /**
460
473
  * Generates transaction to liquidate credit account
461
474
  * @param props - {@link FullyLiquidateProps}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "11.8.9",
3
+ "version": "11.8.10",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",