@gearbox-protocol/sdk 16.3.0-next.5 → 16.3.0-next.6

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 (69) hide show
  1. package/dist/esm/dev/AccountOpener.js +1 -1
  2. package/dist/esm/dev/withdrawalUtils.js +1 -1
  3. package/dist/esm/history/trace/extractTransfers.js +1 -1
  4. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  5. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  6. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  7. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  8. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  9. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  10. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  11. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  12. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  13. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  14. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  15. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  16. package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
  17. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  18. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  19. package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  20. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  21. package/package.json +1 -1
  22. package/dist/cjs/plugins/bots/BotsPlugin.js +0 -107
  23. package/dist/cjs/plugins/bots/PartialLiquidationBotV310Contract.js +0 -47
  24. package/dist/cjs/plugins/bots/abi/iPartialLiquidationBotV310.js +0 -225
  25. package/dist/cjs/plugins/bots/abi/index.js +0 -3
  26. package/dist/cjs/plugins/bots/config.js +0 -39
  27. package/dist/cjs/plugins/bots/deserializePartialLiquidationBotParams.js +0 -39
  28. package/dist/cjs/plugins/bots/index.js +0 -17
  29. package/dist/cjs/plugins/bots/package.json +0 -1
  30. package/dist/cjs/plugins/bots/types.js +0 -28
  31. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -61
  32. package/dist/cjs/plugins/degen-distributors/index.js +0 -4
  33. package/dist/cjs/plugins/degen-distributors/package.json +0 -1
  34. package/dist/cjs/plugins/degen-distributors/types.js +0 -1
  35. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -114
  36. package/dist/cjs/plugins/delayed-withdrawal/index.js +0 -4
  37. package/dist/cjs/plugins/delayed-withdrawal/package.json +0 -1
  38. package/dist/cjs/plugins/delayed-withdrawal/types.js +0 -1
  39. package/dist/esm/plugins/bots/BotsPlugin.js +0 -106
  40. package/dist/esm/plugins/bots/PartialLiquidationBotV310Contract.js +0 -46
  41. package/dist/esm/plugins/bots/abi/iPartialLiquidationBotV310.js +0 -224
  42. package/dist/esm/plugins/bots/abi/index.js +0 -2
  43. package/dist/esm/plugins/bots/config.js +0 -34
  44. package/dist/esm/plugins/bots/deserializePartialLiquidationBotParams.js +0 -35
  45. package/dist/esm/plugins/bots/index.js +0 -7
  46. package/dist/esm/plugins/bots/package.json +0 -1
  47. package/dist/esm/plugins/bots/types.js +0 -26
  48. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -60
  49. package/dist/esm/plugins/degen-distributors/index.js +0 -3
  50. package/dist/esm/plugins/degen-distributors/package.json +0 -1
  51. package/dist/esm/plugins/degen-distributors/types.js +0 -1
  52. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -113
  53. package/dist/esm/plugins/delayed-withdrawal/index.js +0 -3
  54. package/dist/esm/plugins/delayed-withdrawal/package.json +0 -1
  55. package/dist/esm/plugins/delayed-withdrawal/types.js +0 -1
  56. package/dist/types/plugins/bots/BotsPlugin.d.ts +0 -18
  57. package/dist/types/plugins/bots/PartialLiquidationBotV310Contract.d.ts +0 -216
  58. package/dist/types/plugins/bots/abi/iPartialLiquidationBotV310.d.ts +0 -193
  59. package/dist/types/plugins/bots/abi/index.d.ts +0 -2
  60. package/dist/types/plugins/bots/config.d.ts +0 -12
  61. package/dist/types/plugins/bots/deserializePartialLiquidationBotParams.d.ts +0 -7
  62. package/dist/types/plugins/bots/index.d.ts +0 -7
  63. package/dist/types/plugins/bots/types.d.ts +0 -53
  64. package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +0 -25
  65. package/dist/types/plugins/degen-distributors/index.d.ts +0 -3
  66. package/dist/types/plugins/degen-distributors/types.d.ts +0 -8
  67. package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +0 -25
  68. package/dist/types/plugins/delayed-withdrawal/index.d.ts +0 -3
  69. package/dist/types/plugins/delayed-withdrawal/types.d.ts +0 -10
@@ -1,39 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- let viem = require("viem");
6
- //#region src/plugins/bots/deserializePartialLiquidationBotParams.ts
7
- function deserializePartialLiquidationBotParams(params) {
8
- const [treasury, minHealthFactor, maxHealthFactor, premiumScaleFactor, feeScaleFactor] = (0, viem.decodeAbiParameters)([
9
- {
10
- name: "treasury",
11
- type: "address"
12
- },
13
- {
14
- name: "minHealthFactor",
15
- type: "uint16"
16
- },
17
- {
18
- name: "maxHealthFactor",
19
- type: "uint16"
20
- },
21
- {
22
- name: "premiumScaleFactor",
23
- type: "uint16"
24
- },
25
- {
26
- name: "feeScaleFactor",
27
- type: "uint16"
28
- }
29
- ], params.serializedParams);
30
- return {
31
- treasury,
32
- minHealthFactor,
33
- maxHealthFactor,
34
- premiumScaleFactor,
35
- feeScaleFactor
36
- };
37
- }
38
- //#endregion
39
- exports.default = deserializePartialLiquidationBotParams;
@@ -1,17 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_plugins_bots_abi_iPartialLiquidationBotV310 = require("./abi/iPartialLiquidationBotV310.js");
3
- const require_plugins_bots_config = require("./config.js");
4
- require("./abi/index.js");
5
- const require_plugins_bots_types = require("./types.js");
6
- const require_plugins_bots_PartialLiquidationBotV310Contract = require("./PartialLiquidationBotV310Contract.js");
7
- const require_plugins_bots_BotsPlugin = require("./BotsPlugin.js");
8
- exports.BOT_PARAMS_ABI = require_plugins_bots_types.BOT_PARAMS_ABI;
9
- exports.BOT_PARTIAL_LIQUIDATION = require_plugins_bots_types.BOT_PARTIAL_LIQUIDATION;
10
- exports.BotsPlugin = require_plugins_bots_BotsPlugin.BotsPlugin;
11
- exports.LEGACY_MIGRATION_BOT = require_plugins_bots_config.LEGACY_MIGRATION_BOT;
12
- exports.PARTIAL_LIQUIDATION_BOT_CONFIGS = require_plugins_bots_config.PARTIAL_LIQUIDATION_BOT_CONFIGS;
13
- exports.PARTIAL_LIQUIDATION_BOT_DEPLOYER = require_plugins_bots_config.PARTIAL_LIQUIDATION_BOT_DEPLOYER;
14
- exports.PARTIAL_LIQUIDATION_BOT_SALT = require_plugins_bots_config.PARTIAL_LIQUIDATION_BOT_SALT;
15
- exports.PERMISSION_BY_TYPE = require_plugins_bots_config.PERMISSION_BY_TYPE;
16
- exports.PartialLiquidationBotV310Contract = require_plugins_bots_PartialLiquidationBotV310Contract.PartialLiquidationBotV310Contract;
17
- exports.iPartialLiquidationBotV310Abi = require_plugins_bots_abi_iPartialLiquidationBotV310.iPartialLiquidationBotV310Abi;
@@ -1 +0,0 @@
1
- {"type": "commonjs"}
@@ -1,28 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/plugins/bots/types.ts
3
- const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
4
- const BOT_PARAMS_ABI = [
5
- {
6
- type: "address",
7
- name: "treasury"
8
- },
9
- {
10
- type: "uint16",
11
- name: "minHealthFactor"
12
- },
13
- {
14
- type: "uint16",
15
- name: "maxHealthFactor"
16
- },
17
- {
18
- type: "uint16",
19
- name: "premiumScaleFactor"
20
- },
21
- {
22
- type: "uint16",
23
- name: "feeScaleFactor"
24
- }
25
- ];
26
- //#endregion
27
- exports.BOT_PARAMS_ABI = BOT_PARAMS_ABI;
28
- exports.BOT_PARTIAL_LIQUIDATION = BOT_PARTIAL_LIQUIDATION;
@@ -1,61 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_onchain_utils_AddressMap = require("../../onchain/utils/AddressMap.js");
3
- const require_onchain_market_MarketConfiguratorContract = require("../../onchain/market/MarketConfiguratorContract.js");
4
- const require_onchain_plugins_BasePlugin = require("../../onchain/plugins/BasePlugin.js");
5
- require("../../onchain/index.js");
6
- //#region src/plugins/degen-distributors/DegenDistributorsPlugin.ts
7
- const MAP_LABEL = "degenDistributors";
8
- var DegenDistributorsPlugin = class extends require_onchain_plugins_BasePlugin.BasePlugin {
9
- #distributors;
10
- async load(force) {
11
- if (!force && this.loaded) return this.state;
12
- const configurators = Object.values(this.sdk.marketRegister.markets.reduce((acc, market) => {
13
- const cfgLC = market.configurator.address.toLowerCase();
14
- acc[cfgLC] = market.configurator;
15
- return acc;
16
- }, {}));
17
- this.sdk.logger?.debug(`loading degen distributors for ${this.sdk.networkType}`);
18
- const distributors = await require_onchain_market_MarketConfiguratorContract.MarketConfiguratorContract.getPeripheryContractBatch(Object.values(configurators), this.sdk.client, "DEGEN_DISTRIBUTOR", this.sdk.currentBlock);
19
- const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
20
- const cfgLC = cfg.address.toLowerCase();
21
- acc[cfgLC] = distributors[index];
22
- return acc;
23
- }, {});
24
- this.#distributors = new require_onchain_utils_AddressMap.AddressMap(void 0, MAP_LABEL);
25
- this.sdk.marketRegister.markets.forEach((m) => {
26
- const pool = m.pool.pool.address;
27
- const cfg = m.configurator.address;
28
- const cfgLC = cfg.toLowerCase();
29
- const r = distributorByConfigurator?.[cfgLC];
30
- if (r.status === "success" && r.result.length > 0) this.#distributors?.upsert(pool, r.result[0]);
31
- else this.sdk.logger?.warn(`failed to load degen distributor for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`);
32
- });
33
- return this.state;
34
- }
35
- get loaded() {
36
- return !!this.#distributors;
37
- }
38
- /**
39
- * Returns a map of pool addresses to degen distributor addresses
40
- * @throws if degen distributor plugin is not attached
41
- */
42
- get distributors() {
43
- if (!this.#distributors) throw new Error("degen distributor plugin not attached");
44
- return this.#distributors;
45
- }
46
- stateHuman(_) {
47
- return this.distributors.entries().flatMap(([pool, distributor]) => ({
48
- address: distributor,
49
- version: this.version,
50
- pool
51
- }));
52
- }
53
- get state() {
54
- return { distributors: this.distributors.asRecord() };
55
- }
56
- hydrate(state) {
57
- this.#distributors = new require_onchain_utils_AddressMap.AddressMap(Object.entries(state.distributors), MAP_LABEL);
58
- }
59
- };
60
- //#endregion
61
- exports.DegenDistributorsPlugin = DegenDistributorsPlugin;
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_plugins_degen_distributors_DegenDistributorsPlugin = require("./DegenDistributorsPlugin.js");
3
- require("./types.js");
4
- exports.DegenDistributorsPlugin = require_plugins_degen_distributors_DegenDistributorsPlugin.DegenDistributorsPlugin;
@@ -1 +0,0 @@
1
- {"type": "commonjs"}
@@ -1 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,114 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_onchain_utils_AddressMap = require("../../onchain/utils/AddressMap.js");
3
- const require_onchain_plugins_BasePlugin = require("../../onchain/plugins/BasePlugin.js");
4
- require("../../onchain/index.js");
5
- //#region src/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.ts
6
- const MAP_LABEL = "delayedWithdrawal";
7
- var DelayedWithdrawalPlugin = class extends require_onchain_plugins_BasePlugin.BasePlugin {
8
- async load(force) {
9
- if (!force && this.loaded) return this.state;
10
- await this.sdk.withdrawalCompressor?.loadWithdrawableAssets(force);
11
- return this.state;
12
- }
13
- get loaded() {
14
- return !!this.sdk.withdrawalCompressor?.state;
15
- }
16
- /**
17
- * Returns a map of cmAddress -> array of delayed assets
18
- * @throws if withdrawable assets have not been loaded
19
- */
20
- get withdrawableAssets() {
21
- const compressor = this.sdk.withdrawalCompressor;
22
- if (!compressor?.state) throw new Error("withdrawable assets are not loaded");
23
- const result = new require_onchain_utils_AddressMap.AddressMap(void 0, MAP_LABEL);
24
- for (const cfg of compressor.getWithdrawableAssets()) {
25
- const assets = result.get(cfg.creditManager) ?? [];
26
- assets.push({
27
- ...cfg,
28
- disabled: isConfigToOmit({
29
- creditManager: cfg.creditManager,
30
- token: cfg.token,
31
- withdrawalPhantomToken: cfg.withdrawalPhantomToken,
32
- underlying: cfg.underlying
33
- })
34
- });
35
- result.upsert(cfg.creditManager, assets);
36
- }
37
- return result;
38
- }
39
- stateHuman(_) {
40
- return this.withdrawableAssets.values().flatMap((cm) => {
41
- return cm.map((a) => {
42
- return {
43
- address: a.creditManager,
44
- version: this.version,
45
- ...a
46
- };
47
- });
48
- });
49
- }
50
- get state() {
51
- return {};
52
- }
53
- };
54
- function getConfigKey(config) {
55
- return `${config.creditManager}-${config.token}-${config.withdrawalPhantomToken}-${config.underlying}`.toLowerCase();
56
- }
57
- function isConfigToOmit(config) {
58
- return !!CONFIGS_TO_OMIT_RECORD[getConfigKey(config)];
59
- }
60
- const CONFIGS_TO_OMIT_RECORD = [
61
- {
62
- creditManager: "0xf5edc34204e67e592bdcb84114571c9e4bd0bdf7",
63
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
64
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
65
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
66
- },
67
- {
68
- creditManager: "0xb79d6544839d169869476589d2e54014a074317b",
69
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
70
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
71
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
72
- },
73
- {
74
- creditManager: "0x79c6c1ce5b12abcc3e407ce8c160ee1160250921",
75
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
76
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
77
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
78
- },
79
- {
80
- creditManager: "0xc307a074bd5aec2d6ad1d9b74465c24a59b490fd",
81
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
82
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
83
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
84
- },
85
- {
86
- creditManager: "0x9a0fdf7cdab4604fc27ebeab4b3d57bd825e8ebe",
87
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
88
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
89
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
90
- },
91
- {
92
- creditManager: "0x06c0df5ac1f24bc2097b59ed8ee1db86bf0b09df",
93
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
94
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
95
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
96
- },
97
- {
98
- creditManager: "0x1128860755c6d452d9326e35d1672ca7c920b7c1",
99
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
100
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
101
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
102
- },
103
- {
104
- creditManager: "0x35e154be3c856c37d539aae90178fe5ac6d37644",
105
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
106
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
107
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
108
- }
109
- ].reduce((acc, config) => {
110
- acc[getConfigKey(config)] = config;
111
- return acc;
112
- }, {});
113
- //#endregion
114
- exports.DelayedWithdrawalPlugin = DelayedWithdrawalPlugin;
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_plugins_delayed_withdrawal_DelayedWithdrawalPlugin = require("./DelayedWithdrawalPlugin.js");
3
- require("./types.js");
4
- exports.DelayedWithdrawalPlugin = require_plugins_delayed_withdrawal_DelayedWithdrawalPlugin.DelayedWithdrawalPlugin;
@@ -1 +0,0 @@
1
- {"type": "commonjs"}
@@ -1 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,106 +0,0 @@
1
- import { AddressMap } from "../../onchain/utils/AddressMap.js";
2
- import { chains } from "../../onchain/chain/chains.js";
3
- import { AP_BYTECODE_REPOSITORY, AP_TREASURY } from "../../onchain/constants/address-provider.js";
4
- import { hexEq } from "../../onchain/utils/hex.js";
5
- import { BasePlugin } from "../../onchain/plugins/BasePlugin.js";
6
- import "../../onchain/index.js";
7
- import { iBytecodeRepositoryAbi } from "../../abi/310/iBytecodeRepository.js";
8
- import { iPartialLiquidationBotV310Abi } from "./abi/iPartialLiquidationBotV310.js";
9
- import { LEGACY_MIGRATION_BOT, PARTIAL_LIQUIDATION_BOT_CONFIGS, PARTIAL_LIQUIDATION_BOT_DEPLOYER, PARTIAL_LIQUIDATION_BOT_SALT } from "./config.js";
10
- import { BOT_PARAMS_ABI, BOT_PARTIAL_LIQUIDATION } from "./types.js";
11
- import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
12
- import { encodeAbiParameters, stringToHex } from "viem";
13
- //#region src/plugins/bots/BotsPlugin.ts
14
- var BotsPlugin = class extends BasePlugin {
15
- #bots;
16
- get loaded() {
17
- return !!this.#bots;
18
- }
19
- get bots() {
20
- return this.#bots?.values() ?? [];
21
- }
22
- async load(force) {
23
- if (!force && this.loaded) return this.state;
24
- const treasury = this.sdk.addressProvider.getAddress(AP_TREASURY);
25
- const bcr = this.sdk.addressProvider.getAddress(AP_BYTECODE_REPOSITORY);
26
- const configs = PARTIAL_LIQUIDATION_BOT_CONFIGS[this.sdk.networkType] ?? [];
27
- this.#bots = new AddressMap();
28
- if (!configs.length) return this.state;
29
- const deployedBots = await this.client.multicall({
30
- contracts: configs.map((config) => ({
31
- address: bcr,
32
- abi: iBytecodeRepositoryAbi,
33
- functionName: "computeAddress",
34
- args: [
35
- stringToHex(BOT_PARTIAL_LIQUIDATION, { size: 32 }),
36
- 310,
37
- encodeAbiParameters(BOT_PARAMS_ABI, [
38
- treasury,
39
- config.minHealthFactor,
40
- config.maxHealthFactor,
41
- config.premiumScaleFactor,
42
- config.feeScaleFactor
43
- ]),
44
- stringToHex(PARTIAL_LIQUIDATION_BOT_SALT, { size: 32 }),
45
- PARTIAL_LIQUIDATION_BOT_DEPLOYER
46
- ]
47
- })),
48
- allowFailure: true,
49
- blockNumber: this.sdk.currentBlock,
50
- batchSize: 0
51
- });
52
- const expectedBots = new AddressMap();
53
- for (let i = 0; i < configs.length; i++) {
54
- const b = deployedBots[i];
55
- const { minHealthFactor, maxHealthFactor } = configs[i];
56
- if (b.status === "success") {
57
- expectedBots.upsert(b.result, {
58
- ...configs[i],
59
- treasury
60
- });
61
- this.logger?.debug(`expected bot [${minHealthFactor}, ${maxHealthFactor}] at ${b.result}`);
62
- } else this.logger?.error(`failed compute address for bot [${minHealthFactor}, ${maxHealthFactor}]`, b.error);
63
- }
64
- const botAddrs = expectedBots.keys();
65
- const serializedBots = await this.client.multicall({
66
- contracts: botAddrs.map((address) => ({
67
- address,
68
- abi: iPartialLiquidationBotV310Abi,
69
- functionName: "serialize"
70
- })),
71
- allowFailure: true,
72
- blockNumber: this.sdk.currentBlock,
73
- batchSize: 0
74
- });
75
- for (let i = 0; i < botAddrs.length; i++) {
76
- const serialized = serializedBots[i];
77
- const expected = expectedBots.mustGet(botAddrs[i]);
78
- if (serialized.status === "success") {
79
- const bot = new PartialLiquidationBotV310Contract(this.sdk, {
80
- addr: botAddrs[i],
81
- version: BigInt(310),
82
- contractType: BOT_PARTIAL_LIQUIDATION,
83
- serializedParams: serialized.result
84
- });
85
- if (!hexEq(treasury, expected.treasury) || bot.minHealthFactor !== expected.minHealthFactor || bot.maxHealthFactor !== expected.maxHealthFactor || bot.premiumScaleFactor !== expected.premiumScaleFactor || bot.feeScaleFactor !== expected.feeScaleFactor) this.logger?.error(`serialized bot ${botAddrs[i]} does not match expected bot`, serialized.error);
86
- else this.#bots.upsert(botAddrs[i], bot);
87
- }
88
- }
89
- return this.state;
90
- }
91
- stateHuman(raw) {
92
- return { bots: this.#bots?.values().map((bot) => bot.stateHuman(raw)) ?? [] };
93
- }
94
- get state() {
95
- return { bots: this.#bots?.values().map((bot) => bot.state) ?? [] };
96
- }
97
- hydrate(state) {
98
- this.#bots = new AddressMap();
99
- for (const botState of state.bots) this.#bots.upsert(botState.addr, new PartialLiquidationBotV310Contract(this.sdk, botState));
100
- }
101
- static getMigrationBotData(chainId) {
102
- return chainId === chains.Mainnet.id ? LEGACY_MIGRATION_BOT : void 0;
103
- }
104
- };
105
- //#endregion
106
- export { BotsPlugin };
@@ -1,46 +0,0 @@
1
- import { percentFmt } from "../../onchain/utils/formatter.js";
2
- import { BaseContract } from "../../onchain/base/BaseContract.js";
3
- import "../../onchain/index.js";
4
- import { iPartialLiquidationBotV310Abi } from "./abi/iPartialLiquidationBotV310.js";
5
- import "./abi/index.js";
6
- import { BOT_PARAMS_ABI } from "./types.js";
7
- import { decodeAbiParameters, stringToHex } from "viem";
8
- //#region src/plugins/bots/PartialLiquidationBotV310Contract.ts
9
- const abi = iPartialLiquidationBotV310Abi;
10
- var PartialLiquidationBotV310Contract = class extends BaseContract {
11
- treasury;
12
- minHealthFactor;
13
- maxHealthFactor;
14
- premiumScaleFactor;
15
- feeScaleFactor;
16
- #serializedParams;
17
- constructor(sdk, args) {
18
- super(sdk, {
19
- ...args,
20
- abi,
21
- name: "PartialLiquidationBotV310"
22
- });
23
- [this.treasury, this.minHealthFactor, this.maxHealthFactor, this.premiumScaleFactor, this.feeScaleFactor] = decodeAbiParameters(BOT_PARAMS_ABI, args.serializedParams);
24
- this.#serializedParams = args.serializedParams;
25
- }
26
- stateHuman(raw) {
27
- return {
28
- ...super.stateHuman(raw),
29
- treasury: this.treasury,
30
- minHealthFactor: percentFmt(this.minHealthFactor, raw),
31
- maxHealthFactor: percentFmt(this.maxHealthFactor, raw),
32
- premiumScaleFactor: percentFmt(this.premiumScaleFactor, raw),
33
- feeScaleFactor: percentFmt(this.feeScaleFactor, raw)
34
- };
35
- }
36
- get state() {
37
- return {
38
- addr: this.address,
39
- version: BigInt(this.version),
40
- contractType: stringToHex(this.contractType, { size: 32 }),
41
- serializedParams: this.#serializedParams
42
- };
43
- }
44
- };
45
- //#endregion
46
- export { PartialLiquidationBotV310Contract };
@@ -1,224 +0,0 @@
1
- //#region src/plugins/bots/abi/iPartialLiquidationBotV310.ts
2
- const iPartialLiquidationBotV310Abi = [
3
- {
4
- type: "function",
5
- name: "contractType",
6
- inputs: [],
7
- outputs: [{
8
- name: "",
9
- type: "bytes32",
10
- internalType: "bytes32"
11
- }],
12
- stateMutability: "view"
13
- },
14
- {
15
- type: "function",
16
- name: "feeScaleFactor",
17
- inputs: [],
18
- outputs: [{
19
- name: "",
20
- type: "uint16",
21
- internalType: "uint16"
22
- }],
23
- stateMutability: "view"
24
- },
25
- {
26
- type: "function",
27
- name: "maxHealthFactor",
28
- inputs: [],
29
- outputs: [{
30
- name: "",
31
- type: "uint16",
32
- internalType: "uint16"
33
- }],
34
- stateMutability: "view"
35
- },
36
- {
37
- type: "function",
38
- name: "minHealthFactor",
39
- inputs: [],
40
- outputs: [{
41
- name: "",
42
- type: "uint16",
43
- internalType: "uint16"
44
- }],
45
- stateMutability: "view"
46
- },
47
- {
48
- type: "function",
49
- name: "partiallyLiquidate",
50
- inputs: [
51
- {
52
- name: "creditAccount",
53
- type: "address",
54
- internalType: "address"
55
- },
56
- {
57
- name: "token",
58
- type: "address",
59
- internalType: "address"
60
- },
61
- {
62
- name: "repaidAmount",
63
- type: "uint256",
64
- internalType: "uint256"
65
- },
66
- {
67
- name: "minSeizedAmount",
68
- type: "uint256",
69
- internalType: "uint256"
70
- },
71
- {
72
- name: "to",
73
- type: "address",
74
- internalType: "address"
75
- },
76
- {
77
- name: "priceUpdates",
78
- type: "tuple[]",
79
- internalType: "struct PriceUpdate[]",
80
- components: [{
81
- name: "priceFeed",
82
- type: "address",
83
- internalType: "address"
84
- }, {
85
- name: "data",
86
- type: "bytes",
87
- internalType: "bytes"
88
- }]
89
- }
90
- ],
91
- outputs: [{
92
- name: "seizedAmount",
93
- type: "uint256",
94
- internalType: "uint256"
95
- }],
96
- stateMutability: "nonpayable"
97
- },
98
- {
99
- type: "function",
100
- name: "premiumScaleFactor",
101
- inputs: [],
102
- outputs: [{
103
- name: "",
104
- type: "uint16",
105
- internalType: "uint16"
106
- }],
107
- stateMutability: "view"
108
- },
109
- {
110
- type: "function",
111
- name: "requiredPermissions",
112
- inputs: [],
113
- outputs: [{
114
- name: "",
115
- type: "uint192",
116
- internalType: "uint192"
117
- }],
118
- stateMutability: "view"
119
- },
120
- {
121
- type: "function",
122
- name: "serialize",
123
- inputs: [],
124
- outputs: [{
125
- name: "serializedData",
126
- type: "bytes",
127
- internalType: "bytes"
128
- }],
129
- stateMutability: "view"
130
- },
131
- {
132
- type: "function",
133
- name: "treasury",
134
- inputs: [],
135
- outputs: [{
136
- name: "",
137
- type: "address",
138
- internalType: "address"
139
- }],
140
- stateMutability: "view"
141
- },
142
- {
143
- type: "function",
144
- name: "version",
145
- inputs: [],
146
- outputs: [{
147
- name: "",
148
- type: "uint256",
149
- internalType: "uint256"
150
- }],
151
- stateMutability: "view"
152
- },
153
- {
154
- type: "event",
155
- name: "PartiallyLiquidate",
156
- inputs: [
157
- {
158
- name: "creditManager",
159
- type: "address",
160
- indexed: true,
161
- internalType: "address"
162
- },
163
- {
164
- name: "creditAccount",
165
- type: "address",
166
- indexed: true,
167
- internalType: "address"
168
- },
169
- {
170
- name: "token",
171
- type: "address",
172
- indexed: true,
173
- internalType: "address"
174
- },
175
- {
176
- name: "liquidator",
177
- type: "address",
178
- indexed: false,
179
- internalType: "address"
180
- },
181
- {
182
- name: "repaidDebt",
183
- type: "uint256",
184
- indexed: false,
185
- internalType: "uint256"
186
- },
187
- {
188
- name: "seizedCollateral",
189
- type: "uint256",
190
- indexed: false,
191
- internalType: "uint256"
192
- },
193
- {
194
- name: "fee",
195
- type: "uint256",
196
- indexed: false,
197
- internalType: "uint256"
198
- }
199
- ],
200
- anonymous: false
201
- },
202
- {
203
- type: "error",
204
- name: "LiquidatedLessThanNeededException",
205
- inputs: []
206
- },
207
- {
208
- type: "error",
209
- name: "LiquidatedMoreThanNeededException",
210
- inputs: []
211
- },
212
- {
213
- type: "error",
214
- name: "SeizedLessThanRequiredException",
215
- inputs: []
216
- },
217
- {
218
- type: "error",
219
- name: "UnderlyingNotLiquidatableException",
220
- inputs: []
221
- }
222
- ];
223
- //#endregion
224
- export { iPartialLiquidationBotV310Abi };
@@ -1,2 +0,0 @@
1
- import { iPartialLiquidationBotV310Abi } from "./iPartialLiquidationBotV310.js";
2
- export { iPartialLiquidationBotV310Abi };