@gearbox-protocol/sdk 11.8.8 → 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.
@@ -49,12 +49,19 @@ class DelayedWithdrawalPlugin extends import_sdk.BasePlugin {
49
49
  this.#withdrawableAssets = new import_sdk.AddressMap(void 0, MAP_LABEL);
50
50
  resp.forEach((r, index) => {
51
51
  const cm = creditManagers[index];
52
- if (r.status === "success") {
52
+ if (r.status === "success" && r.result?.length > 0) {
53
+ const configsToShow = r.result;
53
54
  this.#withdrawableAssets?.upsert(
54
55
  cm.creditManager.address,
55
- r.result.map((cfg) => ({
56
+ configsToShow.map((cfg) => ({
56
57
  ...cfg,
57
- creditManager: cm.creditManager.address
58
+ creditManager: cm.creditManager.address,
59
+ disabled: isConfigToOmit({
60
+ creditManager: cm.creditManager.address,
61
+ token: cfg.token,
62
+ withdrawalPhantomToken: cfg.withdrawalPhantomToken,
63
+ underlying: cfg.underlying
64
+ })
58
65
  }))
59
66
  );
60
67
  } else {
@@ -99,6 +106,74 @@ class DelayedWithdrawalPlugin extends import_sdk.BasePlugin {
99
106
  );
100
107
  }
101
108
  }
109
+ function getConfigKey(config) {
110
+ return `${config.creditManager}-${config.token}-${config.withdrawalPhantomToken}-${config.underlying}`.toLowerCase();
111
+ }
112
+ function isConfigToOmit(config) {
113
+ return !!CONFIGS_TO_OMIT_RECORD[getConfigKey(config)];
114
+ }
115
+ const CONFIGS_TO_OMIT_LIST = [
116
+ {
117
+ // checked
118
+ creditManager: "0xf5edc34204e67e592bdcb84114571c9e4bd0bdf7",
119
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
120
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
121
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
122
+ },
123
+ {
124
+ // checked
125
+ creditManager: "0xb79d6544839d169869476589d2e54014a074317b",
126
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
127
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
128
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
129
+ },
130
+ {
131
+ // checked
132
+ creditManager: "0x79c6c1ce5b12abcc3e407ce8c160ee1160250921",
133
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
134
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
135
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
136
+ },
137
+ {
138
+ // checked
139
+ creditManager: "0xc307a074bd5aec2d6ad1d9b74465c24a59b490fd",
140
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
141
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
142
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
143
+ },
144
+ {
145
+ // zero debt limit + no opened positions
146
+ creditManager: "0x9a0fdf7cdab4604fc27ebeab4b3d57bd825e8ebe",
147
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
148
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
149
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
150
+ },
151
+ {
152
+ // cant load
153
+ creditManager: "0x06c0df5ac1f24bc2097b59ed8ee1db86bf0b09df",
154
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
155
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
156
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
157
+ },
158
+ {
159
+ // cant load
160
+ creditManager: "0x1128860755c6d452d9326e35d1672ca7c920b7c1",
161
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
162
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
163
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
164
+ },
165
+ {
166
+ // cant load
167
+ creditManager: "0x35e154be3c856c37d539aae90178fe5ac6d37644",
168
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
169
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
170
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
171
+ }
172
+ ];
173
+ const CONFIGS_TO_OMIT_RECORD = CONFIGS_TO_OMIT_LIST.reduce((acc, config) => {
174
+ acc[getConfigKey(config)] = config;
175
+ return acc;
176
+ }, {});
102
177
  // Annotate the CommonJS export names for ESM import in node:
103
178
  0 && (module.exports = {
104
179
  DelayedWithdrawalPlugin
@@ -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
  /**
@@ -30,12 +30,19 @@ class DelayedWithdrawalPlugin extends BasePlugin {
30
30
  this.#withdrawableAssets = new AddressMap(void 0, MAP_LABEL);
31
31
  resp.forEach((r, index) => {
32
32
  const cm = creditManagers[index];
33
- if (r.status === "success") {
33
+ if (r.status === "success" && r.result?.length > 0) {
34
+ const configsToShow = r.result;
34
35
  this.#withdrawableAssets?.upsert(
35
36
  cm.creditManager.address,
36
- r.result.map((cfg) => ({
37
+ configsToShow.map((cfg) => ({
37
38
  ...cfg,
38
- creditManager: cm.creditManager.address
39
+ creditManager: cm.creditManager.address,
40
+ disabled: isConfigToOmit({
41
+ creditManager: cm.creditManager.address,
42
+ token: cfg.token,
43
+ withdrawalPhantomToken: cfg.withdrawalPhantomToken,
44
+ underlying: cfg.underlying
45
+ })
39
46
  }))
40
47
  );
41
48
  } else {
@@ -80,6 +87,74 @@ class DelayedWithdrawalPlugin extends BasePlugin {
80
87
  );
81
88
  }
82
89
  }
90
+ function getConfigKey(config) {
91
+ return `${config.creditManager}-${config.token}-${config.withdrawalPhantomToken}-${config.underlying}`.toLowerCase();
92
+ }
93
+ function isConfigToOmit(config) {
94
+ return !!CONFIGS_TO_OMIT_RECORD[getConfigKey(config)];
95
+ }
96
+ const CONFIGS_TO_OMIT_LIST = [
97
+ {
98
+ // checked
99
+ creditManager: "0xf5edc34204e67e592bdcb84114571c9e4bd0bdf7",
100
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
101
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
102
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
103
+ },
104
+ {
105
+ // checked
106
+ creditManager: "0xb79d6544839d169869476589d2e54014a074317b",
107
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
108
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
109
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
110
+ },
111
+ {
112
+ // checked
113
+ creditManager: "0x79c6c1ce5b12abcc3e407ce8c160ee1160250921",
114
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
115
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
116
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
117
+ },
118
+ {
119
+ // checked
120
+ creditManager: "0xc307a074bd5aec2d6ad1d9b74465c24a59b490fd",
121
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
122
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
123
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
124
+ },
125
+ {
126
+ // zero debt limit + no opened positions
127
+ creditManager: "0x9a0fdf7cdab4604fc27ebeab4b3d57bd825e8ebe",
128
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
129
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
130
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
131
+ },
132
+ {
133
+ // cant load
134
+ creditManager: "0x06c0df5ac1f24bc2097b59ed8ee1db86bf0b09df",
135
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
136
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
137
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
138
+ },
139
+ {
140
+ // cant load
141
+ creditManager: "0x1128860755c6d452d9326e35d1672ca7c920b7c1",
142
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
143
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
144
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
145
+ },
146
+ {
147
+ // cant load
148
+ creditManager: "0x35e154be3c856c37d539aae90178fe5ac6d37644",
149
+ token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
150
+ withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
151
+ underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
152
+ }
153
+ ];
154
+ const CONFIGS_TO_OMIT_RECORD = CONFIGS_TO_OMIT_LIST.reduce((acc, config) => {
155
+ acc[getConfigKey(config)] = config;
156
+ return acc;
157
+ }, {});
83
158
  export {
84
159
  DelayedWithdrawalPlugin
85
160
  };
@@ -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
  /**
@@ -4,6 +4,7 @@ import type { BaseContractStateHuman } from "../../sdk/index.js";
4
4
  type WithdrawalCompressorV310InstanceType = GetContractReturnType<typeof iWithdrawalCompressorV310Abi, PublicClient>;
5
5
  export type WithdrawableAsset = Awaited<ReturnType<WithdrawalCompressorV310InstanceType["read"]["getWithdrawableAssets"]>>[number] & {
6
6
  creditManager: Address;
7
+ disabled: boolean;
7
8
  };
8
9
  export interface WithdrawableAssetStateHuman extends WithdrawableAsset, BaseContractStateHuman {
9
10
  }
@@ -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.8",
3
+ "version": "11.8.10",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",