@gearbox-protocol/sdk 11.11.2 → 11.12.0

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.
@@ -48,7 +48,7 @@ async function claimFromFaucet(opts) {
48
48
  args = [amount];
49
49
  amnt = amount.map((v) => {
50
50
  try {
51
- return sdk.tokensMeta.formatBN(v.token, v.amount, { symbol: true });
51
+ return sdk?.tokensMeta.formatBN(v.token, v.amount, { symbol: true }) ?? `${v.amount} of ${v.token}`;
52
52
  } catch {
53
53
  return `${v.amount} of ${v.token}`;
54
54
  }
@@ -18,71 +18,34 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var BotsPlugin_exports = {};
20
20
  __export(BotsPlugin_exports, {
21
- BotsPlugin: () => BotsPlugin,
22
- UnsupportedBotVersionError: () => UnsupportedBotVersionError
21
+ BotsPlugin: () => BotsPlugin
23
22
  });
24
23
  module.exports = __toCommonJS(BotsPlugin_exports);
25
24
  var import_viem = require("viem");
26
25
  var import_iBytecodeRepository = require("../../abi/310/iBytecodeRepository.js");
27
- var import_peripheryCompressor = require("../../abi/compressors/peripheryCompressor.js");
28
26
  var import_sdk = require("../../sdk/index.js");
29
27
  var import_iPartialLiquidationBotV310 = require("./abi/iPartialLiquidationBotV310.js");
30
28
  var import_config = require("./config.js");
31
- var import_PartialLiquidationBotV300Contract = require("./PartialLiquidationBotV300Contract.js");
32
29
  var import_PartialLiquidationBotV310Contract = require("./PartialLiquidationBotV310Contract.js");
33
30
  var import_types = require("./types.js");
34
- class UnsupportedBotVersionError extends Error {
35
- state;
36
- constructor(state) {
37
- super(
38
- `unsupported bot version ${state.baseParams.version} for bot at ${state.baseParams.addr}`
39
- );
40
- this.state = state;
41
- }
42
- }
43
31
  class BotsPlugin extends import_sdk.BasePlugin {
44
- #botsByMarket;
32
+ #bots;
45
33
  get loaded() {
46
- return !!this.#botsByMarket;
34
+ return !!this.#bots;
35
+ }
36
+ get bots() {
37
+ return this.#bots?.values() ?? [];
47
38
  }
48
39
  async load(force) {
49
40
  if (!force && this.loaded) {
50
41
  return this.state;
51
42
  }
52
- const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
53
- import_sdk.AP_PERIPHERY_COMPRESSOR,
54
- import_sdk.VERSION_RANGE_310
55
- );
56
- this.logger?.debug(`loading bots with periphery compressor ${pcAddr}`);
57
- const mcs = this.sdk.marketRegister.marketConfigurators.map(
58
- (mc) => mc.address
59
- );
60
- const botsData = await this.client.multicall({
61
- contracts: mcs.map(
62
- (mc) => ({
63
- address: pcAddr,
64
- abi: import_peripheryCompressor.peripheryCompressorAbi,
65
- functionName: "getBots",
66
- args: [mc]
67
- })
68
- ),
69
- allowFailure: false
70
- });
71
- this.#botsByMarket = new import_sdk.AddressMap();
72
- for (let i = 0; i < mcs.length; i++) {
73
- const mc = mcs[i];
74
- const marketBotData = botsData[i];
75
- this.#loadStateMarketState(mc, marketBotData);
76
- }
77
- return this.state;
78
- }
79
- async findDeployedPartialLiquidationBots() {
80
43
  const treasury = this.sdk.addressProvider.getAddress(import_sdk.AP_TREASURY);
81
44
  const bcr = this.sdk.addressProvider.getAddress(import_sdk.AP_BYTECODE_REPOSITORY);
82
45
  const configs = import_config.PARTIAL_LIQUIDATION_BOT_CONFIGS[this.sdk.networkType] ?? [];
83
- const result = new import_sdk.AddressMap();
46
+ this.#bots = new import_sdk.AddressMap();
84
47
  if (!configs.length) {
85
- return result;
48
+ return this.state;
86
49
  }
87
50
  const deployedBots = await this.client.multicall({
88
51
  contracts: configs.map(
@@ -91,7 +54,7 @@ class BotsPlugin extends import_sdk.BasePlugin {
91
54
  abi: import_iBytecodeRepository.iBytecodeRepositoryAbi,
92
55
  functionName: "computeAddress",
93
56
  args: [
94
- (0, import_viem.stringToHex)("BOT::PARTIAL_LIQUIDATION", { size: 32 }),
57
+ (0, import_viem.stringToHex)(import_types.BOT_PARTIAL_LIQUIDATION, { size: 32 }),
95
58
  310,
96
59
  (0, import_viem.encodeAbiParameters)(import_types.BOT_PARAMS_ABI, [
97
60
  treasury,
@@ -141,88 +104,41 @@ class BotsPlugin extends import_sdk.BasePlugin {
141
104
  const serialized = serializedBots[i];
142
105
  const expected = expectedBots.mustGet(botAddrs[i]);
143
106
  if (serialized.status === "success") {
144
- const [
145
- treasury2,
146
- minHealthFactor,
147
- maxHealthFactor,
148
- premiumScaleFactor,
149
- feeScaleFactor
150
- ] = (0, import_viem.decodeAbiParameters)(import_types.BOT_PARAMS_ABI, serialized.result);
151
- if (!(0, import_sdk.hexEq)(treasury2, expected.treasury) || minHealthFactor !== expected.minHealthFactor || maxHealthFactor !== expected.maxHealthFactor || premiumScaleFactor !== expected.premiumScaleFactor || feeScaleFactor !== expected.feeScaleFactor) {
107
+ const bot = new import_PartialLiquidationBotV310Contract.PartialLiquidationBotV310Contract(this.sdk, {
108
+ addr: botAddrs[i],
109
+ version: BigInt(310),
110
+ contractType: import_types.BOT_PARTIAL_LIQUIDATION,
111
+ serializedParams: serialized.result
112
+ });
113
+ if (!(0, import_sdk.hexEq)(treasury, expected.treasury) || bot.minHealthFactor !== expected.minHealthFactor || bot.maxHealthFactor !== expected.maxHealthFactor || bot.premiumScaleFactor !== expected.premiumScaleFactor || bot.feeScaleFactor !== expected.feeScaleFactor) {
152
114
  this.logger?.error(
153
115
  `serialized bot ${botAddrs[i]} does not match expected bot`,
154
116
  serialized.error
155
117
  );
156
118
  } else {
157
- result.upsert(botAddrs[i], expected);
119
+ this.#bots.upsert(botAddrs[i], bot);
158
120
  }
159
121
  }
160
122
  }
161
- return result;
162
- }
163
- #loadStateMarketState(mc, state) {
164
- const bots = state.map((state2) => this.#createBot(mc, state2)).sort((a, b) => a.minHealthFactor - b.minHealthFactor);
165
- if (bots.length && (0, import_sdk.isV300)(Number(bots[0].version))) {
166
- if (bots.length !== 4) {
167
- throw new Error(`expected 4 bots v300 for market configurator ${mc}`);
168
- }
169
- for (let i = 0; i < bots.length; i++) {
170
- bots[i].botType = import_types.LIQUIDATION_BOT_TYPES[i];
171
- }
172
- }
173
- this.botsByMarket.upsert(mc, bots);
123
+ return this.state;
174
124
  }
175
125
  stateHuman(raw) {
176
126
  return {
177
- bots: Object.fromEntries(
178
- this.botsByMarket.entries().map(([mc, bots]) => [
179
- this.labelAddress(mc),
180
- bots.map((b) => b.stateHuman(raw))
181
- ])
182
- )
127
+ bots: this.#bots?.values().map((bot) => bot.stateHuman(raw)) ?? []
183
128
  };
184
129
  }
185
- get botsByMarket() {
186
- if (!this.#botsByMarket) {
187
- throw new Error("bots plugin not loaded");
188
- }
189
- return this.#botsByMarket;
190
- }
191
- botsByMarketConfigurator(mc) {
192
- return this.botsByMarket.get(mc) ?? [];
193
- }
194
- get allBots() {
195
- return this.botsByMarket.values().flat();
196
- }
197
130
  get state() {
198
131
  return {
199
- bots: import_sdk.TypedObjectUtils.fromEntries(
200
- this.botsByMarket.entries().map(([mc, bots]) => [mc, bots.map((b) => b.state)])
201
- )
132
+ bots: this.#bots?.values().map((bot) => bot.state) ?? []
202
133
  };
203
134
  }
204
135
  hydrate(state) {
205
- this.#botsByMarket = new import_sdk.AddressMap();
206
- for (const [mc, botStates] of import_sdk.TypedObjectUtils.entries(state.bots)) {
207
- this.#loadStateMarketState(mc, botStates);
208
- }
209
- }
210
- #createBot(marketConfigurator, data) {
211
- const v = Number(data.baseParams.version);
212
- if ((0, import_sdk.isV300)(v)) {
213
- return new import_PartialLiquidationBotV300Contract.PartialLiquidationBotV300Contract(
214
- this.sdk,
215
- data,
216
- marketConfigurator
217
- );
218
- } else if ((0, import_sdk.isV310)(v)) {
219
- return new import_PartialLiquidationBotV310Contract.PartialLiquidationBotV310Contract(
220
- this.sdk,
221
- data,
222
- marketConfigurator
136
+ this.#bots = new import_sdk.AddressMap();
137
+ for (const botState of state.bots) {
138
+ this.#bots.upsert(
139
+ botState.addr,
140
+ new import_PartialLiquidationBotV310Contract.PartialLiquidationBotV310Contract(this.sdk, botState)
223
141
  );
224
- } else {
225
- throw new Error(`unsupported bot version: ${v}`);
226
142
  }
227
143
  }
228
144
  static getMigrationBotData(chainId) {
@@ -231,6 +147,5 @@ class BotsPlugin extends import_sdk.BasePlugin {
231
147
  }
232
148
  // Annotate the CommonJS export names for ESM import in node:
233
149
  0 && (module.exports = {
234
- BotsPlugin,
235
- UnsupportedBotVersionError
150
+ BotsPlugin
236
151
  });
@@ -21,18 +21,50 @@ __export(PartialLiquidationBotV310Contract_exports, {
21
21
  PartialLiquidationBotV310Contract: () => PartialLiquidationBotV310Contract
22
22
  });
23
23
  module.exports = __toCommonJS(PartialLiquidationBotV310Contract_exports);
24
+ var import_viem = require("viem");
25
+ var import_sdk = require("../../sdk/index.js");
24
26
  var import_abi = require("./abi/index.js");
25
- var import_PartialLiquidationBotBaseContract = require("./PartialLiquidationBotBaseContract.js");
27
+ var import_types = require("./types.js");
26
28
  const abi = import_abi.iPartialLiquidationBotV310Abi;
27
- class PartialLiquidationBotV310Contract extends import_PartialLiquidationBotBaseContract.PartialLiquidationBotBaseContract {
28
- constructor(sdk, args, marketConfigurator) {
29
+ class PartialLiquidationBotV310Contract extends import_sdk.BaseContract {
30
+ treasury;
31
+ minHealthFactor;
32
+ maxHealthFactor;
33
+ premiumScaleFactor;
34
+ feeScaleFactor;
35
+ #serializedParams;
36
+ constructor(sdk, args) {
29
37
  super(sdk, {
38
+ ...args,
30
39
  abi,
31
- ...args.baseParams,
32
- requiredPermissions: args.requiredPermissions,
33
- marketConfigurator,
34
40
  name: "PartialLiquidationBotV310"
35
41
  });
42
+ [
43
+ this.treasury,
44
+ this.minHealthFactor,
45
+ this.maxHealthFactor,
46
+ this.premiumScaleFactor,
47
+ this.feeScaleFactor
48
+ ] = (0, import_viem.decodeAbiParameters)(import_types.BOT_PARAMS_ABI, args.serializedParams);
49
+ this.#serializedParams = args.serializedParams;
50
+ }
51
+ stateHuman(raw) {
52
+ return {
53
+ ...super.stateHuman(raw),
54
+ treasury: this.treasury,
55
+ minHealthFactor: (0, import_sdk.formatPercentage)(this.minHealthFactor),
56
+ maxHealthFactor: (0, import_sdk.formatPercentage)(this.maxHealthFactor),
57
+ premiumScaleFactor: (0, import_sdk.formatPercentage)(this.premiumScaleFactor),
58
+ feeScaleFactor: (0, import_sdk.formatPercentage)(this.feeScaleFactor)
59
+ };
60
+ }
61
+ get state() {
62
+ return {
63
+ addr: this.address,
64
+ version: BigInt(this.version),
65
+ contractType: (0, import_viem.stringToHex)(this.contractType, { size: 32 }),
66
+ serializedParams: this.#serializedParams
67
+ };
36
68
  }
37
69
  }
38
70
  // Annotate the CommonJS export names for ESM import in node:
@@ -18,7 +18,6 @@ module.exports = __toCommonJS(bots_exports);
18
18
  __reExport(bots_exports, require("./abi/index.js"), module.exports);
19
19
  __reExport(bots_exports, require("./BotsPlugin.js"), module.exports);
20
20
  __reExport(bots_exports, require("./config.js"), module.exports);
21
- __reExport(bots_exports, require("./PartialLiquidationBotV300Contract.js"), module.exports);
22
21
  __reExport(bots_exports, require("./PartialLiquidationBotV310Contract.js"), module.exports);
23
22
  __reExport(bots_exports, require("./types.js"), module.exports);
24
23
  // Annotate the CommonJS export names for ESM import in node:
@@ -26,7 +25,6 @@ __reExport(bots_exports, require("./types.js"), module.exports);
26
25
  ...require("./abi/index.js"),
27
26
  ...require("./BotsPlugin.js"),
28
27
  ...require("./config.js"),
29
- ...require("./PartialLiquidationBotV300Contract.js"),
30
28
  ...require("./PartialLiquidationBotV310Contract.js"),
31
29
  ...require("./types.js")
32
30
  });
@@ -19,10 +19,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var types_exports = {};
20
20
  __export(types_exports, {
21
21
  BOT_PARAMS_ABI: () => BOT_PARAMS_ABI,
22
- LIQUIDATION_BOT_TYPES: () => LIQUIDATION_BOT_TYPES,
22
+ BOT_PARTIAL_LIQUIDATION: () => BOT_PARTIAL_LIQUIDATION,
23
23
  MIGRATION_BOT_TYPES: () => MIGRATION_BOT_TYPES
24
24
  });
25
25
  module.exports = __toCommonJS(types_exports);
26
+ const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
26
27
  const BOT_PARAMS_ABI = [
27
28
  { type: "address", name: "treasury" },
28
29
  { type: "uint16", name: "minHealthFactor" },
@@ -30,16 +31,10 @@ const BOT_PARAMS_ABI = [
30
31
  { type: "uint16", name: "premiumScaleFactor" },
31
32
  { type: "uint16", name: "feeScaleFactor" }
32
33
  ];
33
- const LIQUIDATION_BOT_TYPES = [
34
- "PARTIAL_LIQUIDATION_BOT",
35
- "DELEVERAGE_BOT_PEGGED",
36
- "DELEVERAGE_BOT_LV",
37
- "DELEVERAGE_BOT_HV"
38
- ];
39
34
  const MIGRATION_BOT_TYPES = ["MIGRATION_BOT"];
40
35
  // Annotate the CommonJS export names for ESM import in node:
41
36
  0 && (module.exports = {
42
37
  BOT_PARAMS_ABI,
43
- LIQUIDATION_BOT_TYPES,
38
+ BOT_PARTIAL_LIQUIDATION,
44
39
  MIGRATION_BOT_TYPES
45
40
  });
@@ -27,7 +27,7 @@ async function claimFromFaucet(opts) {
27
27
  args = [amount];
28
28
  amnt = amount.map((v) => {
29
29
  try {
30
- return sdk.tokensMeta.formatBN(v.token, v.amount, { symbol: true });
30
+ return sdk?.tokensMeta.formatBN(v.token, v.amount, { symbol: true }) ?? `${v.amount} of ${v.token}`;
31
31
  } catch {
32
32
  return `${v.amount} of ${v.token}`;
33
33
  }
@@ -1,22 +1,12 @@
1
- import {
2
- decodeAbiParameters,
3
- encodeAbiParameters,
4
- stringToHex
5
- } from "viem";
1
+ import { encodeAbiParameters, stringToHex } from "viem";
6
2
  import { iBytecodeRepositoryAbi } from "../../abi/310/iBytecodeRepository.js";
7
- import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
8
3
  import {
9
4
  AddressMap,
10
5
  AP_BYTECODE_REPOSITORY,
11
- AP_PERIPHERY_COMPRESSOR,
12
6
  AP_TREASURY,
13
7
  BasePlugin,
14
8
  chains as CHAINS,
15
- hexEq,
16
- isV300,
17
- isV310,
18
- TypedObjectUtils,
19
- VERSION_RANGE_310
9
+ hexEq
20
10
  } from "../../sdk/index.js";
21
11
  import { iPartialLiquidationBotV310Abi } from "./abi/iPartialLiquidationBotV310.js";
22
12
  import {
@@ -25,64 +15,29 @@ import {
25
15
  PARTIAL_LIQUIDATION_BOT_DEPLOYER,
26
16
  PARTIAL_LIQUIDATION_BOT_SALT
27
17
  } from "./config.js";
28
- import { PartialLiquidationBotV300Contract } from "./PartialLiquidationBotV300Contract.js";
29
18
  import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
30
19
  import {
31
20
  BOT_PARAMS_ABI,
32
- LIQUIDATION_BOT_TYPES
21
+ BOT_PARTIAL_LIQUIDATION
33
22
  } from "./types.js";
34
- class UnsupportedBotVersionError extends Error {
35
- state;
36
- constructor(state) {
37
- super(
38
- `unsupported bot version ${state.baseParams.version} for bot at ${state.baseParams.addr}`
39
- );
40
- this.state = state;
41
- }
42
- }
43
23
  class BotsPlugin extends BasePlugin {
44
- #botsByMarket;
24
+ #bots;
45
25
  get loaded() {
46
- return !!this.#botsByMarket;
26
+ return !!this.#bots;
27
+ }
28
+ get bots() {
29
+ return this.#bots?.values() ?? [];
47
30
  }
48
31
  async load(force) {
49
32
  if (!force && this.loaded) {
50
33
  return this.state;
51
34
  }
52
- const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
53
- AP_PERIPHERY_COMPRESSOR,
54
- VERSION_RANGE_310
55
- );
56
- this.logger?.debug(`loading bots with periphery compressor ${pcAddr}`);
57
- const mcs = this.sdk.marketRegister.marketConfigurators.map(
58
- (mc) => mc.address
59
- );
60
- const botsData = await this.client.multicall({
61
- contracts: mcs.map(
62
- (mc) => ({
63
- address: pcAddr,
64
- abi: peripheryCompressorAbi,
65
- functionName: "getBots",
66
- args: [mc]
67
- })
68
- ),
69
- allowFailure: false
70
- });
71
- this.#botsByMarket = new AddressMap();
72
- for (let i = 0; i < mcs.length; i++) {
73
- const mc = mcs[i];
74
- const marketBotData = botsData[i];
75
- this.#loadStateMarketState(mc, marketBotData);
76
- }
77
- return this.state;
78
- }
79
- async findDeployedPartialLiquidationBots() {
80
35
  const treasury = this.sdk.addressProvider.getAddress(AP_TREASURY);
81
36
  const bcr = this.sdk.addressProvider.getAddress(AP_BYTECODE_REPOSITORY);
82
37
  const configs = PARTIAL_LIQUIDATION_BOT_CONFIGS[this.sdk.networkType] ?? [];
83
- const result = new AddressMap();
38
+ this.#bots = new AddressMap();
84
39
  if (!configs.length) {
85
- return result;
40
+ return this.state;
86
41
  }
87
42
  const deployedBots = await this.client.multicall({
88
43
  contracts: configs.map(
@@ -91,7 +46,7 @@ class BotsPlugin extends BasePlugin {
91
46
  abi: iBytecodeRepositoryAbi,
92
47
  functionName: "computeAddress",
93
48
  args: [
94
- stringToHex("BOT::PARTIAL_LIQUIDATION", { size: 32 }),
49
+ stringToHex(BOT_PARTIAL_LIQUIDATION, { size: 32 }),
95
50
  310,
96
51
  encodeAbiParameters(BOT_PARAMS_ABI, [
97
52
  treasury,
@@ -141,88 +96,41 @@ class BotsPlugin extends BasePlugin {
141
96
  const serialized = serializedBots[i];
142
97
  const expected = expectedBots.mustGet(botAddrs[i]);
143
98
  if (serialized.status === "success") {
144
- const [
145
- treasury2,
146
- minHealthFactor,
147
- maxHealthFactor,
148
- premiumScaleFactor,
149
- feeScaleFactor
150
- ] = decodeAbiParameters(BOT_PARAMS_ABI, serialized.result);
151
- if (!hexEq(treasury2, expected.treasury) || minHealthFactor !== expected.minHealthFactor || maxHealthFactor !== expected.maxHealthFactor || premiumScaleFactor !== expected.premiumScaleFactor || feeScaleFactor !== expected.feeScaleFactor) {
99
+ const bot = new PartialLiquidationBotV310Contract(this.sdk, {
100
+ addr: botAddrs[i],
101
+ version: BigInt(310),
102
+ contractType: BOT_PARTIAL_LIQUIDATION,
103
+ serializedParams: serialized.result
104
+ });
105
+ if (!hexEq(treasury, expected.treasury) || bot.minHealthFactor !== expected.minHealthFactor || bot.maxHealthFactor !== expected.maxHealthFactor || bot.premiumScaleFactor !== expected.premiumScaleFactor || bot.feeScaleFactor !== expected.feeScaleFactor) {
152
106
  this.logger?.error(
153
107
  `serialized bot ${botAddrs[i]} does not match expected bot`,
154
108
  serialized.error
155
109
  );
156
110
  } else {
157
- result.upsert(botAddrs[i], expected);
111
+ this.#bots.upsert(botAddrs[i], bot);
158
112
  }
159
113
  }
160
114
  }
161
- return result;
162
- }
163
- #loadStateMarketState(mc, state) {
164
- const bots = state.map((state2) => this.#createBot(mc, state2)).sort((a, b) => a.minHealthFactor - b.minHealthFactor);
165
- if (bots.length && isV300(Number(bots[0].version))) {
166
- if (bots.length !== 4) {
167
- throw new Error(`expected 4 bots v300 for market configurator ${mc}`);
168
- }
169
- for (let i = 0; i < bots.length; i++) {
170
- bots[i].botType = LIQUIDATION_BOT_TYPES[i];
171
- }
172
- }
173
- this.botsByMarket.upsert(mc, bots);
115
+ return this.state;
174
116
  }
175
117
  stateHuman(raw) {
176
118
  return {
177
- bots: Object.fromEntries(
178
- this.botsByMarket.entries().map(([mc, bots]) => [
179
- this.labelAddress(mc),
180
- bots.map((b) => b.stateHuman(raw))
181
- ])
182
- )
119
+ bots: this.#bots?.values().map((bot) => bot.stateHuman(raw)) ?? []
183
120
  };
184
121
  }
185
- get botsByMarket() {
186
- if (!this.#botsByMarket) {
187
- throw new Error("bots plugin not loaded");
188
- }
189
- return this.#botsByMarket;
190
- }
191
- botsByMarketConfigurator(mc) {
192
- return this.botsByMarket.get(mc) ?? [];
193
- }
194
- get allBots() {
195
- return this.botsByMarket.values().flat();
196
- }
197
122
  get state() {
198
123
  return {
199
- bots: TypedObjectUtils.fromEntries(
200
- this.botsByMarket.entries().map(([mc, bots]) => [mc, bots.map((b) => b.state)])
201
- )
124
+ bots: this.#bots?.values().map((bot) => bot.state) ?? []
202
125
  };
203
126
  }
204
127
  hydrate(state) {
205
- this.#botsByMarket = new AddressMap();
206
- for (const [mc, botStates] of TypedObjectUtils.entries(state.bots)) {
207
- this.#loadStateMarketState(mc, botStates);
208
- }
209
- }
210
- #createBot(marketConfigurator, data) {
211
- const v = Number(data.baseParams.version);
212
- if (isV300(v)) {
213
- return new PartialLiquidationBotV300Contract(
214
- this.sdk,
215
- data,
216
- marketConfigurator
217
- );
218
- } else if (isV310(v)) {
219
- return new PartialLiquidationBotV310Contract(
220
- this.sdk,
221
- data,
222
- marketConfigurator
128
+ this.#bots = new AddressMap();
129
+ for (const botState of state.bots) {
130
+ this.#bots.upsert(
131
+ botState.addr,
132
+ new PartialLiquidationBotV310Contract(this.sdk, botState)
223
133
  );
224
- } else {
225
- throw new Error(`unsupported bot version: ${v}`);
226
134
  }
227
135
  }
228
136
  static getMigrationBotData(chainId) {
@@ -230,6 +138,5 @@ class BotsPlugin extends BasePlugin {
230
138
  }
231
139
  }
232
140
  export {
233
- BotsPlugin,
234
- UnsupportedBotVersionError
141
+ BotsPlugin
235
142
  };
@@ -1,15 +1,50 @@
1
+ import { decodeAbiParameters, stringToHex } from "viem";
2
+ import {
3
+ BaseContract,
4
+ formatPercentage
5
+ } from "../../sdk/index.js";
1
6
  import { iPartialLiquidationBotV310Abi } from "./abi/index.js";
2
- import { PartialLiquidationBotBaseContract } from "./PartialLiquidationBotBaseContract.js";
7
+ import { BOT_PARAMS_ABI } from "./types.js";
3
8
  const abi = iPartialLiquidationBotV310Abi;
4
- class PartialLiquidationBotV310Contract extends PartialLiquidationBotBaseContract {
5
- constructor(sdk, args, marketConfigurator) {
9
+ class PartialLiquidationBotV310Contract extends BaseContract {
10
+ treasury;
11
+ minHealthFactor;
12
+ maxHealthFactor;
13
+ premiumScaleFactor;
14
+ feeScaleFactor;
15
+ #serializedParams;
16
+ constructor(sdk, args) {
6
17
  super(sdk, {
18
+ ...args,
7
19
  abi,
8
- ...args.baseParams,
9
- requiredPermissions: args.requiredPermissions,
10
- marketConfigurator,
11
20
  name: "PartialLiquidationBotV310"
12
21
  });
22
+ [
23
+ this.treasury,
24
+ this.minHealthFactor,
25
+ this.maxHealthFactor,
26
+ this.premiumScaleFactor,
27
+ this.feeScaleFactor
28
+ ] = decodeAbiParameters(BOT_PARAMS_ABI, args.serializedParams);
29
+ this.#serializedParams = args.serializedParams;
30
+ }
31
+ stateHuman(raw) {
32
+ return {
33
+ ...super.stateHuman(raw),
34
+ treasury: this.treasury,
35
+ minHealthFactor: formatPercentage(this.minHealthFactor),
36
+ maxHealthFactor: formatPercentage(this.maxHealthFactor),
37
+ premiumScaleFactor: formatPercentage(this.premiumScaleFactor),
38
+ feeScaleFactor: formatPercentage(this.feeScaleFactor)
39
+ };
40
+ }
41
+ get state() {
42
+ return {
43
+ addr: this.address,
44
+ version: BigInt(this.version),
45
+ contractType: stringToHex(this.contractType, { size: 32 }),
46
+ serializedParams: this.#serializedParams
47
+ };
13
48
  }
14
49
  }
15
50
  export {
@@ -1,6 +1,5 @@
1
1
  export * from "./abi/index.js";
2
2
  export * from "./BotsPlugin.js";
3
3
  export * from "./config.js";
4
- export * from "./PartialLiquidationBotV300Contract.js";
5
4
  export * from "./PartialLiquidationBotV310Contract.js";
6
5
  export * from "./types.js";
@@ -1,3 +1,4 @@
1
+ const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
1
2
  const BOT_PARAMS_ABI = [
2
3
  { type: "address", name: "treasury" },
3
4
  { type: "uint16", name: "minHealthFactor" },
@@ -5,15 +6,9 @@ const BOT_PARAMS_ABI = [
5
6
  { type: "uint16", name: "premiumScaleFactor" },
6
7
  { type: "uint16", name: "feeScaleFactor" }
7
8
  ];
8
- const LIQUIDATION_BOT_TYPES = [
9
- "PARTIAL_LIQUIDATION_BOT",
10
- "DELEVERAGE_BOT_PEGGED",
11
- "DELEVERAGE_BOT_LV",
12
- "DELEVERAGE_BOT_HV"
13
- ];
14
9
  const MIGRATION_BOT_TYPES = ["MIGRATION_BOT"];
15
10
  export {
16
11
  BOT_PARAMS_ABI,
17
- LIQUIDATION_BOT_TYPES,
12
+ BOT_PARTIAL_LIQUIDATION,
18
13
  MIGRATION_BOT_TYPES
19
14
  };
@@ -5,7 +5,7 @@ interface TokenClaim {
5
5
  amount: bigint;
6
6
  }
7
7
  interface ClaimFromFaucetOptions {
8
- sdk: GearboxSDK;
8
+ sdk?: GearboxSDK;
9
9
  publicClient: PublicClient;
10
10
  wallet: WalletClient;
11
11
  faucet: Address;
@@ -1,23 +1,13 @@
1
- import { type Address } from "viem";
2
1
  import type { IGearboxSDKPlugin } from "../../sdk/index.js";
3
- import { AddressMap, BasePlugin } from "../../sdk/index.js";
4
- import { PartialLiquidationBotV300Contract } from "./PartialLiquidationBotV300Contract.js";
2
+ import { BasePlugin } from "../../sdk/index.js";
5
3
  import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
6
- import { type BotParameters, type BotState, type BotsPluginState, type BotsPluginStateHuman, type MigrationBotState } from "./types.js";
7
- export declare class UnsupportedBotVersionError extends Error {
8
- readonly state: BotState;
9
- constructor(state: BotState);
10
- }
11
- export type PartialLiquidationBotContract = PartialLiquidationBotV300Contract | PartialLiquidationBotV310Contract;
4
+ import { type BotsPluginState, type BotsPluginStateHuman, type MigrationBotState } from "./types.js";
12
5
  export declare class BotsPlugin extends BasePlugin<BotsPluginState> implements IGearboxSDKPlugin<BotsPluginState> {
13
6
  #private;
14
7
  get loaded(): boolean;
8
+ get bots(): PartialLiquidationBotV310Contract[];
15
9
  load(force?: boolean): Promise<BotsPluginState>;
16
- findDeployedPartialLiquidationBots(): Promise<AddressMap<BotParameters>>;
17
10
  stateHuman(raw?: boolean): BotsPluginStateHuman;
18
- get botsByMarket(): AddressMap<PartialLiquidationBotContract[]>;
19
- botsByMarketConfigurator(mc: Address): PartialLiquidationBotContract[];
20
- get allBots(): PartialLiquidationBotContract[];
21
11
  get state(): BotsPluginState;
22
12
  hydrate(state: BotsPluginState): void;
23
13
  static getMigrationBotData(chainId: number): MigrationBotState | undefined;
@@ -1,7 +1,6 @@
1
- import type { Address } from "abitype";
2
- import type { GearboxSDK } from "../../sdk/index.js";
3
- import { PartialLiquidationBotBaseContract } from "./PartialLiquidationBotBaseContract.js";
4
- import type { BotState } from "./types.js";
1
+ import { type Address, type Hex } from "viem";
2
+ import { BaseContract, type GearboxSDK } from "../../sdk/index.js";
3
+ import { type BotStateV310Human } from "./types.js";
5
4
  declare const abi: readonly [{
6
5
  readonly type: "function";
7
6
  readonly name: "contractType";
@@ -193,7 +192,21 @@ declare const abi: readonly [{
193
192
  readonly inputs: readonly [];
194
193
  }];
195
194
  type abi = typeof abi;
196
- export declare class PartialLiquidationBotV310Contract extends PartialLiquidationBotBaseContract<abi> {
197
- constructor(sdk: GearboxSDK, args: BotState, marketConfigurator: Address);
195
+ export interface PartialLiquidationBotV310Params {
196
+ addr: Address;
197
+ version: bigint;
198
+ contractType: string;
199
+ serializedParams: Hex;
200
+ }
201
+ export declare class PartialLiquidationBotV310Contract extends BaseContract<abi> {
202
+ #private;
203
+ readonly treasury: Address;
204
+ readonly minHealthFactor: number;
205
+ readonly maxHealthFactor: number;
206
+ readonly premiumScaleFactor: number;
207
+ readonly feeScaleFactor: number;
208
+ constructor(sdk: GearboxSDK, args: PartialLiquidationBotV310Params);
209
+ stateHuman(raw?: boolean): BotStateV310Human;
210
+ get state(): PartialLiquidationBotV310Params;
198
211
  }
199
212
  export {};
@@ -1,6 +1,5 @@
1
1
  export * from "./abi/index.js";
2
2
  export * from "./BotsPlugin.js";
3
3
  export * from "./config.js";
4
- export * from "./PartialLiquidationBotV300Contract.js";
5
4
  export * from "./PartialLiquidationBotV310Contract.js";
6
5
  export * from "./types.js";
@@ -1,8 +1,6 @@
1
- import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
2
1
  import type { Address } from "viem";
3
- import type { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
4
- import type { BaseContractStateHuman, Unarray } from "../../sdk/index.js";
5
- export type BotState = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof peripheryCompressorAbi, "getBots">["outputs"]>>;
2
+ import type { BaseContractStateHuman } from "../../sdk/index.js";
3
+ import type { PartialLiquidationBotV310Params } from "./PartialLiquidationBotV310Contract.js";
6
4
  export interface BotParameters {
7
5
  treasury: Address;
8
6
  minHealthFactor: number;
@@ -10,6 +8,7 @@ export interface BotParameters {
10
8
  premiumScaleFactor: number;
11
9
  feeScaleFactor: number;
12
10
  }
11
+ export declare const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
13
12
  export declare const BOT_PARAMS_ABI: readonly [{
14
13
  readonly type: "address";
15
14
  readonly name: "treasury";
@@ -26,32 +25,20 @@ export declare const BOT_PARAMS_ABI: readonly [{
26
25
  readonly type: "uint16";
27
26
  readonly name: "feeScaleFactor";
28
27
  }];
29
- export declare const LIQUIDATION_BOT_TYPES: readonly ["PARTIAL_LIQUIDATION_BOT", "DELEVERAGE_BOT_PEGGED", "DELEVERAGE_BOT_LV", "DELEVERAGE_BOT_HV"];
30
- export type LiquidationBotType = (typeof LIQUIDATION_BOT_TYPES)[number];
31
- export interface BotStateBaseHuman extends BaseContractStateHuman {
28
+ export interface BotStateV310Human extends BaseContractStateHuman {
32
29
  treasury: Address;
33
30
  minHealthFactor: string;
34
31
  maxHealthFactor: string;
35
32
  premiumScaleFactor: string;
36
33
  feeScaleFactor: string;
37
- requiredPermissions: string;
38
34
  }
39
- export interface BotStateV300Human extends BotStateBaseHuman {
40
- botType: LiquidationBotType;
41
- }
42
- export type BotStateV310Human = BotStateBaseHuman;
43
- export type BotStateHuman = BotStateV300Human | BotStateV310Human;
35
+ export type BotStateHuman = BotStateV310Human;
36
+ export type BotState = PartialLiquidationBotV310Params;
44
37
  export interface BotsPluginStateHuman {
45
- /**
46
- * Mapping market configurator to bot states
47
- */
48
- bots: Record<string, BotStateHuman[]>;
38
+ bots: BotStateHuman[];
49
39
  }
50
40
  export interface BotsPluginState {
51
- /**
52
- * Mapping market configurator address to bot states
53
- */
54
- bots: Record<Address, BotState[]>;
41
+ bots: BotState[];
55
42
  }
56
43
  export type BotBaseType = "LIQUIDATION_PROTECTION" | "MIGRATION";
57
44
  export declare const MIGRATION_BOT_TYPES: readonly ["MIGRATION_BOT"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "11.11.2",
3
+ "version": "11.12.0",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var PartialLiquidationBotBaseContract_exports = {};
20
- __export(PartialLiquidationBotBaseContract_exports, {
21
- PartialLiquidationBotBaseContract: () => PartialLiquidationBotBaseContract
22
- });
23
- module.exports = __toCommonJS(PartialLiquidationBotBaseContract_exports);
24
- var import_viem = require("viem");
25
- var import_sdk = require("../../sdk/index.js");
26
- var import_types = require("./types.js");
27
- class PartialLiquidationBotBaseContract extends import_sdk.BaseContract {
28
- requiredPermissions;
29
- marketConfigurator;
30
- #serializedParams;
31
- constructor(sdk, args) {
32
- super(sdk, args);
33
- this.#serializedParams = args.serializedParams;
34
- const [
35
- treasury,
36
- minHealthFactor,
37
- maxHealthFactor,
38
- premiumScaleFactor,
39
- feeScaleFactor
40
- ] = (0, import_viem.decodeAbiParameters)(import_types.BOT_PARAMS_ABI, args.serializedParams);
41
- this.treasury = treasury;
42
- this.minHealthFactor = minHealthFactor;
43
- this.maxHealthFactor = maxHealthFactor;
44
- this.premiumScaleFactor = premiumScaleFactor;
45
- this.feeScaleFactor = feeScaleFactor;
46
- this.marketConfigurator = args.marketConfigurator;
47
- this.requiredPermissions = args.requiredPermissions;
48
- }
49
- stateHuman(raw) {
50
- return {
51
- ...super.stateHuman(raw),
52
- treasury: this.treasury,
53
- minHealthFactor: (0, import_sdk.formatPercentage)(this.minHealthFactor),
54
- maxHealthFactor: (0, import_sdk.formatPercentage)(this.maxHealthFactor),
55
- premiumScaleFactor: (0, import_sdk.formatPercentage)(this.premiumScaleFactor),
56
- feeScaleFactor: (0, import_sdk.formatPercentage)(this.feeScaleFactor),
57
- requiredPermissions: this.requiredPermissions.toString(10)
58
- };
59
- }
60
- get state() {
61
- return {
62
- baseParams: {
63
- addr: this.address,
64
- version: BigInt(this.version),
65
- contractType: this.contractType,
66
- serializedParams: this.#serializedParams
67
- },
68
- requiredPermissions: this.requiredPermissions
69
- };
70
- }
71
- }
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- PartialLiquidationBotBaseContract
75
- });
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var PartialLiquidationBotV300Contract_exports = {};
20
- __export(PartialLiquidationBotV300Contract_exports, {
21
- PartialLiquidationBotV300Contract: () => PartialLiquidationBotV300Contract
22
- });
23
- module.exports = __toCommonJS(PartialLiquidationBotV300Contract_exports);
24
- var import_abi = require("./abi/index.js");
25
- var import_PartialLiquidationBotBaseContract = require("./PartialLiquidationBotBaseContract.js");
26
- const abi = import_abi.iPartialLiquidationBotV300Abi;
27
- class PartialLiquidationBotV300Contract extends import_PartialLiquidationBotBaseContract.PartialLiquidationBotBaseContract {
28
- #botType;
29
- constructor(sdk, args, marketConfigurator) {
30
- super(sdk, {
31
- abi,
32
- ...args.baseParams,
33
- requiredPermissions: args.requiredPermissions,
34
- marketConfigurator,
35
- name: "PartialLiquidationBotV300"
36
- });
37
- }
38
- stateHuman(raw) {
39
- return {
40
- ...super.stateHuman(raw),
41
- botType: this.botType
42
- };
43
- }
44
- /**
45
- * Set the bot type
46
- * This method should only be called once from BotsPlugin
47
- */
48
- set botType(type) {
49
- if (this.#botType) {
50
- throw new Error("bot type already set");
51
- }
52
- this.#botType = type;
53
- this.name = `PartialLiquidationBotV300 (${type})`;
54
- }
55
- get botType() {
56
- if (!this.#botType) {
57
- throw new Error("bot type not set");
58
- }
59
- return this.#botType;
60
- }
61
- }
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- PartialLiquidationBotV300Contract
65
- });
@@ -1,53 +0,0 @@
1
- import { decodeAbiParameters } from "viem";
2
- import { BaseContract, formatPercentage } from "../../sdk/index.js";
3
- import {
4
- BOT_PARAMS_ABI
5
- } from "./types.js";
6
- class PartialLiquidationBotBaseContract extends BaseContract {
7
- requiredPermissions;
8
- marketConfigurator;
9
- #serializedParams;
10
- constructor(sdk, args) {
11
- super(sdk, args);
12
- this.#serializedParams = args.serializedParams;
13
- const [
14
- treasury,
15
- minHealthFactor,
16
- maxHealthFactor,
17
- premiumScaleFactor,
18
- feeScaleFactor
19
- ] = decodeAbiParameters(BOT_PARAMS_ABI, args.serializedParams);
20
- this.treasury = treasury;
21
- this.minHealthFactor = minHealthFactor;
22
- this.maxHealthFactor = maxHealthFactor;
23
- this.premiumScaleFactor = premiumScaleFactor;
24
- this.feeScaleFactor = feeScaleFactor;
25
- this.marketConfigurator = args.marketConfigurator;
26
- this.requiredPermissions = args.requiredPermissions;
27
- }
28
- stateHuman(raw) {
29
- return {
30
- ...super.stateHuman(raw),
31
- treasury: this.treasury,
32
- minHealthFactor: formatPercentage(this.minHealthFactor),
33
- maxHealthFactor: formatPercentage(this.maxHealthFactor),
34
- premiumScaleFactor: formatPercentage(this.premiumScaleFactor),
35
- feeScaleFactor: formatPercentage(this.feeScaleFactor),
36
- requiredPermissions: this.requiredPermissions.toString(10)
37
- };
38
- }
39
- get state() {
40
- return {
41
- baseParams: {
42
- addr: this.address,
43
- version: BigInt(this.version),
44
- contractType: this.contractType,
45
- serializedParams: this.#serializedParams
46
- },
47
- requiredPermissions: this.requiredPermissions
48
- };
49
- }
50
- }
51
- export {
52
- PartialLiquidationBotBaseContract
53
- };
@@ -1,41 +0,0 @@
1
- import { iPartialLiquidationBotV300Abi } from "./abi/index.js";
2
- import { PartialLiquidationBotBaseContract } from "./PartialLiquidationBotBaseContract.js";
3
- const abi = iPartialLiquidationBotV300Abi;
4
- class PartialLiquidationBotV300Contract extends PartialLiquidationBotBaseContract {
5
- #botType;
6
- constructor(sdk, args, marketConfigurator) {
7
- super(sdk, {
8
- abi,
9
- ...args.baseParams,
10
- requiredPermissions: args.requiredPermissions,
11
- marketConfigurator,
12
- name: "PartialLiquidationBotV300"
13
- });
14
- }
15
- stateHuman(raw) {
16
- return {
17
- ...super.stateHuman(raw),
18
- botType: this.botType
19
- };
20
- }
21
- /**
22
- * Set the bot type
23
- * This method should only be called once from BotsPlugin
24
- */
25
- set botType(type) {
26
- if (this.#botType) {
27
- throw new Error("bot type already set");
28
- }
29
- this.#botType = type;
30
- this.name = `PartialLiquidationBotV300 (${type})`;
31
- }
32
- get botType() {
33
- if (!this.#botType) {
34
- throw new Error("bot type not set");
35
- }
36
- return this.#botType;
37
- }
38
- }
39
- export {
40
- PartialLiquidationBotV300Contract
41
- };
@@ -1,25 +0,0 @@
1
- import type { Address } from "abitype";
2
- import type { Abi, Hex } from "viem";
3
- import type { GearboxSDK } from "../../sdk/index.js";
4
- import { BaseContract } from "../../sdk/index.js";
5
- import { type BotParameters, type BotState, type BotStateBaseHuman } from "./types.js";
6
- export interface PartialLiquidationBotBaseArgs<abi extends Abi | readonly unknown[]> {
7
- abi: abi;
8
- addr: Address;
9
- name?: string;
10
- version?: number | bigint;
11
- contractType?: string;
12
- serializedParams: Hex;
13
- requiredPermissions: bigint;
14
- marketConfigurator: Address;
15
- }
16
- export interface PartialLiquidationBotBaseContract<abi extends Abi | readonly unknown[]> extends BotParameters, BaseContract<abi> {
17
- }
18
- export declare abstract class PartialLiquidationBotBaseContract<abi extends Abi | readonly unknown[]> extends BaseContract<abi> {
19
- #private;
20
- readonly requiredPermissions: bigint;
21
- readonly marketConfigurator: Address;
22
- constructor(sdk: GearboxSDK, args: PartialLiquidationBotBaseArgs<abi>);
23
- stateHuman(raw?: boolean): BotStateBaseHuman;
24
- get state(): BotState;
25
- }
@@ -1,227 +0,0 @@
1
- import type { Address } from "abitype";
2
- import type { GearboxSDK } from "../../sdk/index.js";
3
- import { PartialLiquidationBotBaseContract } from "./PartialLiquidationBotBaseContract.js";
4
- import type { BotState, BotStateV300Human, LiquidationBotType } from "./types.js";
5
- declare const abi: readonly [{
6
- readonly type: "function";
7
- readonly name: "feeScaleFactor";
8
- readonly inputs: readonly [];
9
- readonly outputs: readonly [{
10
- readonly name: "";
11
- readonly type: "uint16";
12
- readonly internalType: "uint16";
13
- }];
14
- readonly stateMutability: "view";
15
- }, {
16
- readonly type: "function";
17
- readonly name: "liquidateExactCollateral";
18
- readonly inputs: readonly [{
19
- readonly name: "creditAccount";
20
- readonly type: "address";
21
- readonly internalType: "address";
22
- }, {
23
- readonly name: "token";
24
- readonly type: "address";
25
- readonly internalType: "address";
26
- }, {
27
- readonly name: "seizedAmount";
28
- readonly type: "uint256";
29
- readonly internalType: "uint256";
30
- }, {
31
- readonly name: "maxRepaidAmount";
32
- readonly type: "uint256";
33
- readonly internalType: "uint256";
34
- }, {
35
- readonly name: "to";
36
- readonly type: "address";
37
- readonly internalType: "address";
38
- }, {
39
- readonly name: "priceUpdates";
40
- readonly type: "tuple[]";
41
- readonly internalType: "struct IPartialLiquidationBotV3.PriceUpdate[]";
42
- readonly components: readonly [{
43
- readonly name: "token";
44
- readonly type: "address";
45
- readonly internalType: "address";
46
- }, {
47
- readonly name: "reserve";
48
- readonly type: "bool";
49
- readonly internalType: "bool";
50
- }, {
51
- readonly name: "data";
52
- readonly type: "bytes";
53
- readonly internalType: "bytes";
54
- }];
55
- }];
56
- readonly outputs: readonly [{
57
- readonly name: "repaidAmount";
58
- readonly type: "uint256";
59
- readonly internalType: "uint256";
60
- }];
61
- readonly stateMutability: "nonpayable";
62
- }, {
63
- readonly type: "function";
64
- readonly name: "liquidateExactDebt";
65
- readonly inputs: readonly [{
66
- readonly name: "creditAccount";
67
- readonly type: "address";
68
- readonly internalType: "address";
69
- }, {
70
- readonly name: "token";
71
- readonly type: "address";
72
- readonly internalType: "address";
73
- }, {
74
- readonly name: "repaidAmount";
75
- readonly type: "uint256";
76
- readonly internalType: "uint256";
77
- }, {
78
- readonly name: "minSeizedAmount";
79
- readonly type: "uint256";
80
- readonly internalType: "uint256";
81
- }, {
82
- readonly name: "to";
83
- readonly type: "address";
84
- readonly internalType: "address";
85
- }, {
86
- readonly name: "priceUpdates";
87
- readonly type: "tuple[]";
88
- readonly internalType: "struct IPartialLiquidationBotV3.PriceUpdate[]";
89
- readonly components: readonly [{
90
- readonly name: "token";
91
- readonly type: "address";
92
- readonly internalType: "address";
93
- }, {
94
- readonly name: "reserve";
95
- readonly type: "bool";
96
- readonly internalType: "bool";
97
- }, {
98
- readonly name: "data";
99
- readonly type: "bytes";
100
- readonly internalType: "bytes";
101
- }];
102
- }];
103
- readonly outputs: readonly [{
104
- readonly name: "seizedAmount";
105
- readonly type: "uint256";
106
- readonly internalType: "uint256";
107
- }];
108
- readonly stateMutability: "nonpayable";
109
- }, {
110
- readonly type: "function";
111
- readonly name: "maxHealthFactor";
112
- readonly inputs: readonly [];
113
- readonly outputs: readonly [{
114
- readonly name: "";
115
- readonly type: "uint16";
116
- readonly internalType: "uint16";
117
- }];
118
- readonly stateMutability: "view";
119
- }, {
120
- readonly type: "function";
121
- readonly name: "minHealthFactor";
122
- readonly inputs: readonly [];
123
- readonly outputs: readonly [{
124
- readonly name: "";
125
- readonly type: "uint16";
126
- readonly internalType: "uint16";
127
- }];
128
- readonly stateMutability: "view";
129
- }, {
130
- readonly type: "function";
131
- readonly name: "premiumScaleFactor";
132
- readonly inputs: readonly [];
133
- readonly outputs: readonly [{
134
- readonly name: "";
135
- readonly type: "uint16";
136
- readonly internalType: "uint16";
137
- }];
138
- readonly stateMutability: "view";
139
- }, {
140
- readonly type: "function";
141
- readonly name: "treasury";
142
- readonly inputs: readonly [];
143
- readonly outputs: readonly [{
144
- readonly name: "";
145
- readonly type: "address";
146
- readonly internalType: "address";
147
- }];
148
- readonly stateMutability: "view";
149
- }, {
150
- readonly type: "function";
151
- readonly name: "version";
152
- readonly inputs: readonly [];
153
- readonly outputs: readonly [{
154
- readonly name: "";
155
- readonly type: "uint256";
156
- readonly internalType: "uint256";
157
- }];
158
- readonly stateMutability: "view";
159
- }, {
160
- readonly type: "event";
161
- readonly name: "LiquidatePartial";
162
- readonly inputs: readonly [{
163
- readonly name: "creditManager";
164
- readonly type: "address";
165
- readonly indexed: true;
166
- readonly internalType: "address";
167
- }, {
168
- readonly name: "creditAccount";
169
- readonly type: "address";
170
- readonly indexed: true;
171
- readonly internalType: "address";
172
- }, {
173
- readonly name: "token";
174
- readonly type: "address";
175
- readonly indexed: true;
176
- readonly internalType: "address";
177
- }, {
178
- readonly name: "repaidDebt";
179
- readonly type: "uint256";
180
- readonly indexed: false;
181
- readonly internalType: "uint256";
182
- }, {
183
- readonly name: "seizedCollateral";
184
- readonly type: "uint256";
185
- readonly indexed: false;
186
- readonly internalType: "uint256";
187
- }, {
188
- readonly name: "fee";
189
- readonly type: "uint256";
190
- readonly indexed: false;
191
- readonly internalType: "uint256";
192
- }];
193
- readonly anonymous: false;
194
- }, {
195
- readonly type: "error";
196
- readonly name: "LiquidatedLessThanNeededException";
197
- readonly inputs: readonly [];
198
- }, {
199
- readonly type: "error";
200
- readonly name: "LiquidatedMoreThanNeededException";
201
- readonly inputs: readonly [];
202
- }, {
203
- readonly type: "error";
204
- readonly name: "RepaidMoreThanAllowedException";
205
- readonly inputs: readonly [];
206
- }, {
207
- readonly type: "error";
208
- readonly name: "SeizedLessThanRequiredException";
209
- readonly inputs: readonly [];
210
- }, {
211
- readonly type: "error";
212
- readonly name: "UnderlyingNotLiquidatableException";
213
- readonly inputs: readonly [];
214
- }];
215
- type abi = typeof abi;
216
- export declare class PartialLiquidationBotV300Contract extends PartialLiquidationBotBaseContract<abi> {
217
- #private;
218
- constructor(sdk: GearboxSDK, args: BotState, marketConfigurator: Address);
219
- stateHuman(raw?: boolean): BotStateV300Human;
220
- /**
221
- * Set the bot type
222
- * This method should only be called once from BotsPlugin
223
- */
224
- set botType(type: LiquidationBotType);
225
- get botType(): LiquidationBotType;
226
- }
227
- export {};