@gearbox-protocol/sdk 3.0.0-vfour.310 → 3.0.0-vfour.312
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.
- package/dist/cjs/adapters/{GearboxAdaptersPlugin.js → AdaptersPlugin.js} +6 -6
- package/dist/cjs/adapters/index.js +2 -2
- package/dist/cjs/bots/BotsPlugin.js +191 -0
- package/dist/cjs/bots/PartialLiquidationBotV300Contract.js +55 -0
- package/dist/cjs/bots/abi/iPartialLiquidationBotV300.js +164 -0
- package/dist/cjs/{sdk/bots → bots/abi}/index.js +4 -6
- package/dist/cjs/bots/index.js +28 -0
- package/dist/cjs/bots/package.json +1 -0
- package/dist/cjs/{sdk/bots/utils.js → bots/types.js} +19 -2
- package/dist/cjs/sdk/index.js +0 -2
- package/dist/cjs/sdk/market/MarketRegister.js +2 -2
- package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +20 -6
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +43 -40
- package/dist/cjs/sdk/market/pricefeeds/RedstonePriceFeed.js +7 -2
- package/dist/cjs/zappers/{GearboxZappersPlugin.js → ZappersPlugin.js} +6 -6
- package/dist/cjs/zappers/index.js +3 -3
- package/dist/esm/adapters/{GearboxAdaptersPlugin.js → AdaptersPlugin.js} +2 -2
- package/dist/esm/adapters/index.js +1 -1
- package/dist/esm/bots/BotsPlugin.js +171 -0
- package/dist/esm/bots/PartialLiquidationBotV300Contract.js +31 -0
- package/dist/esm/bots/abi/iPartialLiquidationBotV300.js +140 -0
- package/dist/esm/bots/abi/index.js +1 -0
- package/dist/esm/bots/index.js +4 -0
- package/dist/esm/bots/package.json +1 -0
- package/dist/esm/bots/types.js +9 -0
- package/dist/esm/sdk/index.js +0 -1
- package/dist/esm/sdk/market/MarketRegister.js +2 -2
- package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +18 -5
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +46 -41
- package/dist/esm/sdk/market/pricefeeds/RedstonePriceFeed.js +5 -1
- package/dist/esm/zappers/{GearboxZappersPlugin.js → ZappersPlugin.js} +2 -2
- package/dist/esm/zappers/index.js +1 -1
- package/dist/types/adapters/{GearboxAdaptersPlugin.d.ts → AdaptersPlugin.d.ts} +1 -1
- package/dist/types/adapters/index.d.ts +1 -1
- package/dist/types/bots/BotsPlugin.d.ts +18 -0
- package/dist/types/bots/PartialLiquidationBotV300Contract.d.ts +223 -0
- package/dist/types/bots/abi/iPartialLiquidationBotV300.d.ts +210 -0
- package/dist/types/bots/abi/index.d.ts +1 -0
- package/dist/types/bots/index.d.ts +4 -0
- package/dist/types/bots/types.d.ts +23 -0
- package/dist/types/sdk/base/types.d.ts +0 -1
- package/dist/types/sdk/index.d.ts +0 -1
- package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +4 -0
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +6 -3
- package/dist/types/sdk/market/pricefeeds/RedstonePriceFeed.d.ts +2 -0
- package/dist/types/zappers/{GearboxZappersPlugin.d.ts → ZappersPlugin.d.ts} +1 -1
- package/dist/types/zappers/index.d.ts +1 -1
- package/package.json +6 -1
- package/dist/cjs/sdk/bots/BotsService.js +0 -100
- package/dist/esm/sdk/bots/BotsService.js +0 -76
- package/dist/esm/sdk/bots/index.js +0 -2
- package/dist/esm/sdk/bots/utils.js +0 -0
- package/dist/types/sdk/bots/BotsService.d.ts +0 -12
- package/dist/types/sdk/bots/index.d.ts +0 -2
- package/dist/types/sdk/bots/utils.d.ts +0 -13
|
@@ -27,6 +27,7 @@ var import_base = require("../../base/index.js");
|
|
|
27
27
|
var import_constants = require("../../constants/index.js");
|
|
28
28
|
var import_utils = require("../../utils/index.js");
|
|
29
29
|
var import_internal = require("../../utils/internal/index.js");
|
|
30
|
+
var import_AbstractPriceFeed = require("./AbstractPriceFeed.js");
|
|
30
31
|
var import_BalancerStablePriceFeed = require("./BalancerStablePriceFeed.js");
|
|
31
32
|
var import_BalancerWeightedPriceFeed = require("./BalancerWeightedPriceFeed.js");
|
|
32
33
|
var import_BoundedPriceFeed = require("./BoundedPriceFeed.js");
|
|
@@ -78,35 +79,55 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
78
79
|
return existing;
|
|
79
80
|
}
|
|
80
81
|
const feed = this.create(data);
|
|
82
|
+
if (!feed.loaded) {
|
|
83
|
+
throw new import_AbstractPriceFeed.PartialPriceFeedInitError({ ...data, abi: [], name: "" });
|
|
84
|
+
}
|
|
81
85
|
this.#feeds.upsert(data.baseParams.addr, feed);
|
|
82
86
|
return feed;
|
|
83
87
|
}
|
|
84
88
|
/**
|
|
85
89
|
* Loads PARTIAL information about all updatable price feeds from MarketCompressor
|
|
86
|
-
* This can later be used to load price feed updates
|
|
90
|
+
* This is not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
|
|
87
91
|
*/
|
|
88
|
-
async
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
async getPartialUpdatablePriceFeeds(marketConfigurators, pools) {
|
|
93
|
+
const marketCompressorAddress = this.sdk.addressProvider.getAddress(
|
|
94
|
+
import_constants.AP_MARKET_COMPRESSOR,
|
|
95
|
+
310
|
|
92
96
|
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
const configurators = marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
98
|
+
this.logger?.debug(
|
|
99
|
+
{ configurators, pools },
|
|
100
|
+
"calling getUpdatablePriceFeeds"
|
|
101
|
+
);
|
|
102
|
+
const result = await this.provider.publicClient.readContract({
|
|
103
|
+
address: marketCompressorAddress,
|
|
104
|
+
abi: import_compressors.iMarketCompressorAbi,
|
|
105
|
+
functionName: "getUpdatablePriceFeeds",
|
|
106
|
+
args: [
|
|
107
|
+
{
|
|
108
|
+
configurators,
|
|
109
|
+
pools: pools ?? [],
|
|
110
|
+
underlying: import_constants.ADDRESS_0X0
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
this.logger?.debug(`loaded ${result.length} partial updatable price feeds`);
|
|
115
|
+
return result.map((baseParams) => this.#createUpdatableProxy({ baseParams }));
|
|
97
116
|
}
|
|
98
117
|
/**
|
|
99
118
|
* Generates price update transaction via multicall3 without any market data knowledge
|
|
119
|
+
*
|
|
120
|
+
* @deprecated TODO: seems that it's not used anywhere
|
|
121
|
+
*
|
|
100
122
|
* @param marketConfigurators
|
|
101
123
|
* @param pools
|
|
102
124
|
* @returns
|
|
103
125
|
*/
|
|
104
126
|
async getUpdatePriceFeedsTx(marketConfigurators, pools) {
|
|
105
|
-
const
|
|
127
|
+
const feeds = await this.getPartialUpdatablePriceFeeds(
|
|
106
128
|
marketConfigurators,
|
|
107
129
|
pools
|
|
108
130
|
);
|
|
109
|
-
const feeds = feedsData.map((data) => this.create({ baseParams: data }));
|
|
110
131
|
const updates = await this.#generatePriceFeedsUpdateTxs(feeds);
|
|
111
132
|
return (0, import_utils.createRawTx)(
|
|
112
133
|
(0, import_viem.getChainContractAddress)({
|
|
@@ -130,7 +151,7 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
130
151
|
const txs = [];
|
|
131
152
|
const redstonePFs = [];
|
|
132
153
|
for (const pf of updateables) {
|
|
133
|
-
if (
|
|
154
|
+
if ((0, import_RedstonePriceFeed.isRedstone)(pf)) {
|
|
134
155
|
redstonePFs.push(pf);
|
|
135
156
|
}
|
|
136
157
|
}
|
|
@@ -157,34 +178,6 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
157
178
|
}
|
|
158
179
|
return result;
|
|
159
180
|
}
|
|
160
|
-
async #loadUpdatablePriceFeeds(marketConfigurators, pools) {
|
|
161
|
-
const marketCompressorAddress = this.sdk.addressProvider.getAddress(
|
|
162
|
-
import_constants.AP_MARKET_COMPRESSOR,
|
|
163
|
-
310
|
|
164
|
-
);
|
|
165
|
-
const configurators = marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
166
|
-
this.logger?.debug(
|
|
167
|
-
{ configurators, pools },
|
|
168
|
-
"calling getUpdatablePriceFeeds"
|
|
169
|
-
);
|
|
170
|
-
const result = await this.provider.publicClient.readContract({
|
|
171
|
-
address: marketCompressorAddress,
|
|
172
|
-
abi: import_compressors.iMarketCompressorAbi,
|
|
173
|
-
functionName: "getUpdatablePriceFeeds",
|
|
174
|
-
args: [
|
|
175
|
-
{
|
|
176
|
-
configurators,
|
|
177
|
-
pools: pools ?? [],
|
|
178
|
-
underlying: import_constants.ADDRESS_0X0
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
// It's passed as ...rest in viem readContract action, but this might change
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
// gas: 500_000_000n,
|
|
184
|
-
});
|
|
185
|
-
this.logger?.debug(`loaded ${result.length} updatable price feeds`);
|
|
186
|
-
return result;
|
|
187
|
-
}
|
|
188
181
|
create(data) {
|
|
189
182
|
const contractType = (0, import_utils.bytes32ToString)(
|
|
190
183
|
data.baseParams.contractType
|
|
@@ -234,6 +227,16 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
234
227
|
}
|
|
235
228
|
}
|
|
236
229
|
}
|
|
230
|
+
#createUpdatableProxy(data) {
|
|
231
|
+
return new Proxy(this.create(data), {
|
|
232
|
+
get(target, prop) {
|
|
233
|
+
if (prop === "updatableDependencies") {
|
|
234
|
+
return () => [];
|
|
235
|
+
}
|
|
236
|
+
return target[prop];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
237
240
|
}
|
|
238
241
|
// Annotate the CommonJS export names for ESM import in node:
|
|
239
242
|
0 && (module.exports = {
|
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var RedstonePriceFeed_exports = {};
|
|
20
20
|
__export(RedstonePriceFeed_exports, {
|
|
21
|
-
RedstonePriceFeedContract: () => RedstonePriceFeedContract
|
|
21
|
+
RedstonePriceFeedContract: () => RedstonePriceFeedContract,
|
|
22
|
+
isRedstone: () => isRedstone
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(RedstonePriceFeed_exports);
|
|
24
25
|
var import_viem = require("viem");
|
|
@@ -99,7 +100,11 @@ class RedstonePriceFeedContract extends import_AbstractPriceFeed.AbstractPriceFe
|
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
function isRedstone(pf) {
|
|
104
|
+
return pf.contractType === "PRICE_FEED::REDSTONE";
|
|
105
|
+
}
|
|
102
106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
107
|
0 && (module.exports = {
|
|
104
|
-
RedstonePriceFeedContract
|
|
108
|
+
RedstonePriceFeedContract,
|
|
109
|
+
isRedstone
|
|
105
110
|
});
|
|
@@ -16,15 +16,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var ZappersPlugin_exports = {};
|
|
20
|
+
__export(ZappersPlugin_exports, {
|
|
21
|
+
ZappersPlugin: () => ZappersPlugin
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(ZappersPlugin_exports);
|
|
24
24
|
var import_compressors = require("../abi/compressors.js");
|
|
25
25
|
var import_sdk = require("../sdk/index.js");
|
|
26
26
|
var import_sdk2 = require("../sdk/index.js");
|
|
27
|
-
class
|
|
27
|
+
class ZappersPlugin extends import_sdk.SDKConstruct {
|
|
28
28
|
#zappers;
|
|
29
29
|
async attach() {
|
|
30
30
|
await this.loadZappers();
|
|
@@ -90,5 +90,5 @@ class GearboxZappersPlugin extends import_sdk.SDKConstruct {
|
|
|
90
90
|
}
|
|
91
91
|
// Annotate the CommonJS export names for ESM import in node:
|
|
92
92
|
0 && (module.exports = {
|
|
93
|
-
|
|
93
|
+
ZappersPlugin
|
|
94
94
|
});
|
|
@@ -15,10 +15,10 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var zappers_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(zappers_exports);
|
|
18
|
-
__reExport(zappers_exports, require("./GearboxZappersPlugin.js"), module.exports);
|
|
19
18
|
__reExport(zappers_exports, require("./types.js"), module.exports);
|
|
19
|
+
__reExport(zappers_exports, require("./ZappersPlugin.js"), module.exports);
|
|
20
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
21
|
0 && (module.exports = {
|
|
22
|
-
...require("./
|
|
23
|
-
...require("./
|
|
22
|
+
...require("./types.js"),
|
|
23
|
+
...require("./ZappersPlugin.js")
|
|
24
24
|
});
|
|
@@ -22,7 +22,7 @@ import { UniswapV3AdapterContract } from "./UniswapV3AdapterContract.js";
|
|
|
22
22
|
import { VelodromeV2RouterAdapterContract } from "./VelodromeV2AdapterContract.js";
|
|
23
23
|
import { WstETHV1AdapterContract } from "./WstETHV1AdapterContract.js";
|
|
24
24
|
import { YearnV2RouterAdapterContract } from "./YearnV2AdapterContract.js";
|
|
25
|
-
class
|
|
25
|
+
class AdaptersPlugin extends SDKConstruct {
|
|
26
26
|
name = "Adapters";
|
|
27
27
|
createContract(data) {
|
|
28
28
|
const args = data;
|
|
@@ -93,5 +93,5 @@ class GearboxAdaptersPlugin extends SDKConstruct {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
export {
|
|
96
|
-
|
|
96
|
+
AdaptersPlugin
|
|
97
97
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./abi/index.js";
|
|
2
2
|
export * from "./AbstractAdapter.js";
|
|
3
|
+
export * from "./AdaptersPlugin.js";
|
|
3
4
|
export * from "./BalancerV2VaultAdapterContract.js";
|
|
4
5
|
export * from "./BalancerV3RouterAdapterContract.js";
|
|
5
6
|
export * from "./CamelotV3AdapterContract.js";
|
|
@@ -14,7 +15,6 @@ export * from "./CurveV1StableNGAdapterContract.js";
|
|
|
14
15
|
export * from "./DaiUsdsAdapterContract.js";
|
|
15
16
|
export * from "./EqualizerRouterAdapterContract.js";
|
|
16
17
|
export * from "./ERC4626AdapterContract.js";
|
|
17
|
-
export * from "./GearboxAdaptersPlugin.js";
|
|
18
18
|
export * from "./MellowERC4626VaultAdapterContract.js";
|
|
19
19
|
export * from "./MellowVaultAdapterContract.js";
|
|
20
20
|
export * from "./PendleRouterAdapterContract.js";
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { iPeripheryCompressorAbi } from "../abi/compressors.js";
|
|
2
|
+
import {
|
|
3
|
+
AddressMap,
|
|
4
|
+
AP_PERIPHERY_COMPRESSOR,
|
|
5
|
+
SDKConstruct,
|
|
6
|
+
TypedObjectUtils
|
|
7
|
+
} from "../sdk/index.js";
|
|
8
|
+
import { iPartialLiquidationBotV300Abi } from "./abi/index.js";
|
|
9
|
+
import { PartialLiquidationBotV300Contract } from "./PartialLiquidationBotV300Contract.js";
|
|
10
|
+
import { BOT_TYPES } from "./types.js";
|
|
11
|
+
class UnsupportedBotVersionError extends Error {
|
|
12
|
+
state;
|
|
13
|
+
constructor(state) {
|
|
14
|
+
super(
|
|
15
|
+
`unsupported bot version ${state.baseParams.version} for bot at ${state.baseParams.addr}`
|
|
16
|
+
);
|
|
17
|
+
this.state = state;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
class BotsPlugin extends SDKConstruct {
|
|
21
|
+
#logger;
|
|
22
|
+
#botsByMarket = new AddressMap();
|
|
23
|
+
constructor(sdk) {
|
|
24
|
+
super(sdk);
|
|
25
|
+
this.#logger = sdk.logger?.child?.({ name: "BotsPlugin" }) ?? sdk.logger;
|
|
26
|
+
}
|
|
27
|
+
async attach() {
|
|
28
|
+
await this.#load();
|
|
29
|
+
}
|
|
30
|
+
async syncState() {
|
|
31
|
+
await this.#load();
|
|
32
|
+
}
|
|
33
|
+
botsByMarketConfigurator(mc) {
|
|
34
|
+
return this.#botsByMarket.get(mc) ?? [];
|
|
35
|
+
}
|
|
36
|
+
get allBots() {
|
|
37
|
+
return this.#botsByMarket.values().flat();
|
|
38
|
+
}
|
|
39
|
+
async #load() {
|
|
40
|
+
this.#botsByMarket.clear();
|
|
41
|
+
const pcAddr = this.sdk.addressProvider.getAddress(
|
|
42
|
+
AP_PERIPHERY_COMPRESSOR,
|
|
43
|
+
310
|
|
44
|
+
);
|
|
45
|
+
this.#logger?.debug(`loading bots with periphery compressor ${pcAddr}`);
|
|
46
|
+
const mcs = this.sdk.marketRegister.marketConfigurators.map(
|
|
47
|
+
(mc) => mc.address
|
|
48
|
+
);
|
|
49
|
+
const botsData = await this.client.multicall({
|
|
50
|
+
contracts: mcs.map(
|
|
51
|
+
(mc) => ({
|
|
52
|
+
address: pcAddr,
|
|
53
|
+
abi: iPeripheryCompressorAbi,
|
|
54
|
+
functionName: "getBots",
|
|
55
|
+
args: [mc]
|
|
56
|
+
})
|
|
57
|
+
),
|
|
58
|
+
allowFailure: false
|
|
59
|
+
});
|
|
60
|
+
const botsByMcV300 = {};
|
|
61
|
+
for (let i = 0; i < mcs.length; i++) {
|
|
62
|
+
const mc = mcs[i];
|
|
63
|
+
const marketBotData = botsData[i];
|
|
64
|
+
const marketBots = [];
|
|
65
|
+
for (const bot of marketBotData) {
|
|
66
|
+
if (bot.baseParams.version === 300n) {
|
|
67
|
+
marketBots.push(bot);
|
|
68
|
+
} else {
|
|
69
|
+
this.#logger?.warn(new UnsupportedBotVersionError(bot));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (marketBots.length === 4) {
|
|
73
|
+
botsByMcV300[mc] = marketBots;
|
|
74
|
+
} else {
|
|
75
|
+
this.#logger?.warn(
|
|
76
|
+
`each market configurator should have 4 v300 bots, but ${mc} has ${marketBots.length}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const botAddrsV300 = Object.values(botsByMcV300).flatMap(
|
|
81
|
+
(b) => b.map((b2) => b2.baseParams.addr)
|
|
82
|
+
);
|
|
83
|
+
this.#logger?.debug(`loaded ${botAddrsV300.length} v300 bots`);
|
|
84
|
+
const params = await this.#getBotsV300Parameters(botAddrsV300);
|
|
85
|
+
for (const [mc, botStates] of TypedObjectUtils.entries(botsByMcV300)) {
|
|
86
|
+
this.#botsByMarket.upsert(
|
|
87
|
+
mc,
|
|
88
|
+
botStates.map((state, i) => ({
|
|
89
|
+
state,
|
|
90
|
+
params: params[state.baseParams.addr],
|
|
91
|
+
type: BOT_TYPES[i]
|
|
92
|
+
})).sort((a, b) => a.params.minHealthFactor - b.params.minHealthFactor).map(
|
|
93
|
+
({ state, params: params2, type }) => new PartialLiquidationBotV300Contract(
|
|
94
|
+
this.sdk,
|
|
95
|
+
state,
|
|
96
|
+
params2,
|
|
97
|
+
type
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async #getBotsV300Parameters(addresses) {
|
|
104
|
+
const BOT_INFO_LENGTH = 4;
|
|
105
|
+
const resp = await this.provider.publicClient.multicall({
|
|
106
|
+
allowFailure: false,
|
|
107
|
+
contracts: addresses.map(
|
|
108
|
+
(address) => [
|
|
109
|
+
{
|
|
110
|
+
address,
|
|
111
|
+
abi: iPartialLiquidationBotV300Abi,
|
|
112
|
+
functionName: "minHealthFactor",
|
|
113
|
+
args: []
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
address,
|
|
117
|
+
abi: iPartialLiquidationBotV300Abi,
|
|
118
|
+
functionName: "maxHealthFactor",
|
|
119
|
+
args: []
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
address,
|
|
123
|
+
abi: iPartialLiquidationBotV300Abi,
|
|
124
|
+
functionName: "premiumScaleFactor",
|
|
125
|
+
args: []
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
address,
|
|
129
|
+
abi: iPartialLiquidationBotV300Abi,
|
|
130
|
+
functionName: "feeScaleFactor",
|
|
131
|
+
args: []
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
).flat(1)
|
|
135
|
+
});
|
|
136
|
+
return addresses.reduce(
|
|
137
|
+
(acc, address, index) => {
|
|
138
|
+
const from = index * BOT_INFO_LENGTH;
|
|
139
|
+
const to = (index + 1) * BOT_INFO_LENGTH;
|
|
140
|
+
const [
|
|
141
|
+
minHealthFactor,
|
|
142
|
+
maxHealthFactor,
|
|
143
|
+
premiumScaleFactor,
|
|
144
|
+
feeScaleFactor
|
|
145
|
+
] = resp.slice(from, to);
|
|
146
|
+
acc[address] = {
|
|
147
|
+
minHealthFactor,
|
|
148
|
+
maxHealthFactor,
|
|
149
|
+
premiumScaleFactor,
|
|
150
|
+
feeScaleFactor
|
|
151
|
+
};
|
|
152
|
+
return acc;
|
|
153
|
+
},
|
|
154
|
+
{}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
stateHuman(raw) {
|
|
158
|
+
return {
|
|
159
|
+
bots: Object.fromEntries(
|
|
160
|
+
this.#botsByMarket.entries().map(([mc, bots]) => [
|
|
161
|
+
this.labelAddress(mc),
|
|
162
|
+
bots.map((b) => b.stateHuman(raw))
|
|
163
|
+
])
|
|
164
|
+
)
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
BotsPlugin,
|
|
170
|
+
UnsupportedBotVersionError
|
|
171
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseContract, formatPercentage } from "../sdk/index.js";
|
|
2
|
+
import { iPartialLiquidationBotV300Abi } from "./abi/index.js";
|
|
3
|
+
const abi = iPartialLiquidationBotV300Abi;
|
|
4
|
+
class PartialLiquidationBotV300Contract extends BaseContract {
|
|
5
|
+
requiredPermissions;
|
|
6
|
+
botType;
|
|
7
|
+
constructor(sdk, args, params, type) {
|
|
8
|
+
super(sdk, {
|
|
9
|
+
abi,
|
|
10
|
+
...args.baseParams,
|
|
11
|
+
name: `PartialLiquidationBotV300 (${type})`
|
|
12
|
+
});
|
|
13
|
+
this.requiredPermissions = args.requiredPermissions;
|
|
14
|
+
Object.assign(this, params);
|
|
15
|
+
this.botType = type;
|
|
16
|
+
}
|
|
17
|
+
stateHuman(raw) {
|
|
18
|
+
return {
|
|
19
|
+
...super.stateHuman(raw),
|
|
20
|
+
botType: this.botType,
|
|
21
|
+
minHealthFactor: formatPercentage(this.minHealthFactor),
|
|
22
|
+
maxHealthFactor: formatPercentage(this.maxHealthFactor),
|
|
23
|
+
premiumScaleFactor: formatPercentage(this.premiumScaleFactor),
|
|
24
|
+
feeScaleFactor: formatPercentage(this.feeScaleFactor),
|
|
25
|
+
requiredPermissions: this.requiredPermissions.toString(10)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
PartialLiquidationBotV300Contract
|
|
31
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const iPartialLiquidationBotV300Abi = [
|
|
2
|
+
{
|
|
3
|
+
type: "function",
|
|
4
|
+
name: "feeScaleFactor",
|
|
5
|
+
inputs: [],
|
|
6
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
7
|
+
stateMutability: "view"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
type: "function",
|
|
11
|
+
name: "liquidateExactCollateral",
|
|
12
|
+
inputs: [
|
|
13
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
14
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
15
|
+
{ name: "seizedAmount", type: "uint256", internalType: "uint256" },
|
|
16
|
+
{ name: "maxRepaidAmount", type: "uint256", internalType: "uint256" },
|
|
17
|
+
{ name: "to", type: "address", internalType: "address" },
|
|
18
|
+
{
|
|
19
|
+
name: "priceUpdates",
|
|
20
|
+
type: "tuple[]",
|
|
21
|
+
internalType: "struct IPartialLiquidationBotV3.PriceUpdate[]",
|
|
22
|
+
components: [
|
|
23
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
24
|
+
{ name: "reserve", type: "bool", internalType: "bool" },
|
|
25
|
+
{ name: "data", type: "bytes", internalType: "bytes" }
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
outputs: [
|
|
30
|
+
{ name: "repaidAmount", type: "uint256", internalType: "uint256" }
|
|
31
|
+
],
|
|
32
|
+
stateMutability: "nonpayable"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: "function",
|
|
36
|
+
name: "liquidateExactDebt",
|
|
37
|
+
inputs: [
|
|
38
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
39
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
40
|
+
{ name: "repaidAmount", type: "uint256", internalType: "uint256" },
|
|
41
|
+
{ name: "minSeizedAmount", type: "uint256", internalType: "uint256" },
|
|
42
|
+
{ name: "to", type: "address", internalType: "address" },
|
|
43
|
+
{
|
|
44
|
+
name: "priceUpdates",
|
|
45
|
+
type: "tuple[]",
|
|
46
|
+
internalType: "struct IPartialLiquidationBotV3.PriceUpdate[]",
|
|
47
|
+
components: [
|
|
48
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
49
|
+
{ name: "reserve", type: "bool", internalType: "bool" },
|
|
50
|
+
{ name: "data", type: "bytes", internalType: "bytes" }
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
outputs: [
|
|
55
|
+
{ name: "seizedAmount", type: "uint256", internalType: "uint256" }
|
|
56
|
+
],
|
|
57
|
+
stateMutability: "nonpayable"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "function",
|
|
61
|
+
name: "maxHealthFactor",
|
|
62
|
+
inputs: [],
|
|
63
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
64
|
+
stateMutability: "view"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: "function",
|
|
68
|
+
name: "minHealthFactor",
|
|
69
|
+
inputs: [],
|
|
70
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
71
|
+
stateMutability: "view"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: "function",
|
|
75
|
+
name: "premiumScaleFactor",
|
|
76
|
+
inputs: [],
|
|
77
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
78
|
+
stateMutability: "view"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "function",
|
|
82
|
+
name: "treasury",
|
|
83
|
+
inputs: [],
|
|
84
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
85
|
+
stateMutability: "view"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: "function",
|
|
89
|
+
name: "version",
|
|
90
|
+
inputs: [],
|
|
91
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
92
|
+
stateMutability: "view"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "event",
|
|
96
|
+
name: "LiquidatePartial",
|
|
97
|
+
inputs: [
|
|
98
|
+
{
|
|
99
|
+
name: "creditManager",
|
|
100
|
+
type: "address",
|
|
101
|
+
indexed: true,
|
|
102
|
+
internalType: "address"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "creditAccount",
|
|
106
|
+
type: "address",
|
|
107
|
+
indexed: true,
|
|
108
|
+
internalType: "address"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "token",
|
|
112
|
+
type: "address",
|
|
113
|
+
indexed: true,
|
|
114
|
+
internalType: "address"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "repaidDebt",
|
|
118
|
+
type: "uint256",
|
|
119
|
+
indexed: false,
|
|
120
|
+
internalType: "uint256"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "seizedCollateral",
|
|
124
|
+
type: "uint256",
|
|
125
|
+
indexed: false,
|
|
126
|
+
internalType: "uint256"
|
|
127
|
+
},
|
|
128
|
+
{ name: "fee", type: "uint256", indexed: false, internalType: "uint256" }
|
|
129
|
+
],
|
|
130
|
+
anonymous: false
|
|
131
|
+
},
|
|
132
|
+
{ type: "error", name: "LiquidatedLessThanNeededException", inputs: [] },
|
|
133
|
+
{ type: "error", name: "LiquidatedMoreThanNeededException", inputs: [] },
|
|
134
|
+
{ type: "error", name: "RepaidMoreThanAllowedException", inputs: [] },
|
|
135
|
+
{ type: "error", name: "SeizedLessThanRequiredException", inputs: [] },
|
|
136
|
+
{ type: "error", name: "UnderlyingNotLiquidatableException", inputs: [] }
|
|
137
|
+
];
|
|
138
|
+
export {
|
|
139
|
+
iPartialLiquidationBotV300Abi
|
|
140
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./iPartialLiquidationBotV300.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module","sideEffects":false}
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -53,11 +53,11 @@ class MarketRegister extends SDKConstruct {
|
|
|
53
53
|
);
|
|
54
54
|
let txs = [];
|
|
55
55
|
if (!ignoreUpdateablePrices) {
|
|
56
|
-
await this.sdk.priceFeeds.
|
|
56
|
+
const updatables = await this.sdk.priceFeeds.getPartialUpdatablePriceFeeds(
|
|
57
57
|
configurators,
|
|
58
58
|
pools
|
|
59
59
|
);
|
|
60
|
-
const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
|
|
60
|
+
const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(updatables);
|
|
61
61
|
txs = updates.txs;
|
|
62
62
|
}
|
|
63
63
|
this.#logger?.debug(
|