@gearbox-protocol/sdk 4.2.0-next.2 → 4.2.0-next.3
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/AdaptersPlugin.js +8 -0
- package/dist/cjs/bots/BotsPlugin.js +45 -95
- package/dist/cjs/bots/PartialLiquidationBotBaseContract.js +83 -0
- package/dist/cjs/bots/PartialLiquidationBotV300Contract.js +25 -17
- package/dist/cjs/bots/PartialLiquidationBotV310Contract.js +41 -0
- package/dist/cjs/bots/abi/iPartialLiquidationBotV310.js +164 -0
- package/dist/cjs/bots/abi/index.js +3 -1
- package/dist/cjs/sdk/GearboxSDK.js +21 -8
- package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +51 -18
- package/dist/cjs/sdk/plugins/{defaultPlugins.js → errors.js} +12 -6
- package/dist/cjs/sdk/plugins/index.js +2 -2
- package/dist/cjs/zappers/ZappersPlugin.js +29 -15
- package/dist/esm/adapters/AdaptersPlugin.js +8 -0
- package/dist/esm/bots/BotsPlugin.js +50 -96
- package/dist/esm/bots/PartialLiquidationBotBaseContract.js +59 -0
- package/dist/esm/bots/PartialLiquidationBotV300Contract.js +25 -17
- package/dist/esm/bots/PartialLiquidationBotV310Contract.js +17 -0
- package/dist/esm/bots/abi/iPartialLiquidationBotV310.js +140 -0
- package/dist/esm/bots/abi/index.js +1 -0
- package/dist/esm/sdk/GearboxSDK.js +22 -9
- package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +52 -19
- package/dist/esm/sdk/plugins/errors.js +10 -0
- package/dist/esm/sdk/plugins/index.js +1 -1
- package/dist/esm/zappers/ZappersPlugin.js +29 -14
- package/dist/types/adapters/AdaptersPlugin.d.ts +5 -2
- package/dist/types/bots/BotsPlugin.d.ts +9 -4
- package/dist/types/bots/PartialLiquidationBotBaseContract.d.ts +25 -0
- package/dist/types/bots/PartialLiquidationBotV300Contract.d.ts +11 -9
- package/dist/types/bots/PartialLiquidationBotV310Contract.d.ts +199 -0
- package/dist/types/bots/abi/iPartialLiquidationBotV310.d.ts +190 -0
- package/dist/types/bots/abi/index.d.ts +1 -0
- package/dist/types/bots/types.d.ts +20 -4
- package/dist/types/sdk/GearboxSDK.d.ts +9 -9
- package/dist/types/sdk/base/SDKConstruct.d.ts +4 -3
- package/dist/types/sdk/market/adapters/factory.d.ts +2 -2
- package/dist/types/sdk/plugins/V300StalenessPeriodPlugin.d.ts +16 -2
- package/dist/types/sdk/plugins/errors.d.ts +4 -0
- package/dist/types/sdk/plugins/index.d.ts +1 -1
- package/dist/types/sdk/plugins/types.d.ts +42 -6
- package/dist/types/sdk/types/state.d.ts +3 -1
- package/dist/types/zappers/ZappersPlugin.d.ts +10 -3
- package/package.json +1 -1
- package/dist/esm/sdk/plugins/defaultPlugins.js +0 -4
- package/dist/types/sdk/plugins/defaultPlugins.d.ts +0 -2
|
@@ -47,6 +47,7 @@ var import_WstETHV1AdapterContract = require("./WstETHV1AdapterContract.js");
|
|
|
47
47
|
var import_YearnV2AdapterContract = require("./YearnV2AdapterContract.js");
|
|
48
48
|
class AdaptersPlugin extends import_sdk.SDKConstruct {
|
|
49
49
|
name = "Adapters";
|
|
50
|
+
version = 1;
|
|
50
51
|
createContract(data) {
|
|
51
52
|
const args = data;
|
|
52
53
|
const adapterType = (0, import_sdk.bytes32ToString)(
|
|
@@ -114,6 +115,13 @@ class AdaptersPlugin extends import_sdk.SDKConstruct {
|
|
|
114
115
|
stateHuman(_) {
|
|
115
116
|
return {};
|
|
116
117
|
}
|
|
118
|
+
get state() {
|
|
119
|
+
return {
|
|
120
|
+
version: this.version
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
hydrate(_) {
|
|
124
|
+
}
|
|
117
125
|
}
|
|
118
126
|
// Annotate the CommonJS export names for ESM import in node:
|
|
119
127
|
0 && (module.exports = {
|
|
@@ -24,8 +24,8 @@ __export(BotsPlugin_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(BotsPlugin_exports);
|
|
25
25
|
var import_compressors = require("../abi/compressors.js");
|
|
26
26
|
var import_sdk = require("../sdk/index.js");
|
|
27
|
-
var import_abi = require("./abi/index.js");
|
|
28
27
|
var import_PartialLiquidationBotV300Contract = require("./PartialLiquidationBotV300Contract.js");
|
|
28
|
+
var import_PartialLiquidationBotV310Contract = require("./PartialLiquidationBotV310Contract.js");
|
|
29
29
|
var import_types = require("./types.js");
|
|
30
30
|
class UnsupportedBotVersionError extends Error {
|
|
31
31
|
state;
|
|
@@ -38,6 +38,7 @@ class UnsupportedBotVersionError extends Error {
|
|
|
38
38
|
}
|
|
39
39
|
class BotsPlugin extends import_sdk.SDKConstruct {
|
|
40
40
|
#logger;
|
|
41
|
+
version = 1;
|
|
41
42
|
#botsByMarket = new import_sdk.AddressMap();
|
|
42
43
|
constructor(sdk) {
|
|
43
44
|
super(sdk);
|
|
@@ -76,106 +77,23 @@ class BotsPlugin extends import_sdk.SDKConstruct {
|
|
|
76
77
|
),
|
|
77
78
|
allowFailure: false
|
|
78
79
|
});
|
|
79
|
-
const botsByMcV300 = {};
|
|
80
80
|
for (let i = 0; i < mcs.length; i++) {
|
|
81
81
|
const mc = mcs[i];
|
|
82
82
|
const marketBotData = botsData[i];
|
|
83
|
-
|
|
84
|
-
for (const bot of marketBotData) {
|
|
85
|
-
if (bot.baseParams.version === 300n) {
|
|
86
|
-
marketBotsV300.push(bot);
|
|
87
|
-
} else {
|
|
88
|
-
this.#logger?.warn(new UnsupportedBotVersionError(bot));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (marketBotsV300.length === 4) {
|
|
92
|
-
botsByMcV300[mc] = marketBotsV300;
|
|
93
|
-
} else if (marketBotsV300.length > 0) {
|
|
94
|
-
this.#logger?.warn(
|
|
95
|
-
`each market configurator should have 4 v300 bots, but ${mc} has ${marketBotsV300.length}`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const botAddrsV300 = Object.values(botsByMcV300).flatMap(
|
|
100
|
-
(b) => b.map((b2) => b2.baseParams.addr)
|
|
101
|
-
);
|
|
102
|
-
this.#logger?.debug(`loaded ${botAddrsV300.length} v300 bots`);
|
|
103
|
-
const params = await this.#getBotsV300Parameters(botAddrsV300);
|
|
104
|
-
for (const [mc, botStates] of import_sdk.TypedObjectUtils.entries(botsByMcV300)) {
|
|
105
|
-
this.#botsByMarket.upsert(
|
|
106
|
-
mc,
|
|
107
|
-
botStates.map((state, i) => ({
|
|
108
|
-
state,
|
|
109
|
-
params: params[state.baseParams.addr],
|
|
110
|
-
type: import_types.BOT_TYPES[i]
|
|
111
|
-
})).sort((a, b) => a.params.minHealthFactor - b.params.minHealthFactor).map(
|
|
112
|
-
({ state, params: params2, type }) => new import_PartialLiquidationBotV300Contract.PartialLiquidationBotV300Contract(
|
|
113
|
-
this.sdk,
|
|
114
|
-
state,
|
|
115
|
-
params2,
|
|
116
|
-
type,
|
|
117
|
-
mc
|
|
118
|
-
)
|
|
119
|
-
)
|
|
120
|
-
);
|
|
83
|
+
this.#loadStateMarketState(mc, marketBotData);
|
|
121
84
|
}
|
|
122
85
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
86
|
+
#loadStateMarketState(mc, state) {
|
|
87
|
+
const bots = state.map((state2) => this.#createBot(mc, state2)).sort((a, b) => a.minHealthFactor - b.minHealthFactor);
|
|
88
|
+
if (bots.length && (0, import_sdk.isV300)(Number(bots[0].version))) {
|
|
89
|
+
if (bots.length !== 4) {
|
|
90
|
+
throw new Error(`expected 4 bots v300 for market configurator ${mc}`);
|
|
91
|
+
}
|
|
92
|
+
for (let i = 0; i < bots.length; i++) {
|
|
93
|
+
bots[i].botType = import_types.BOT_TYPES[i];
|
|
94
|
+
}
|
|
126
95
|
}
|
|
127
|
-
|
|
128
|
-
const resp = await this.provider.publicClient.multicall({
|
|
129
|
-
allowFailure: false,
|
|
130
|
-
contracts: addresses.map(
|
|
131
|
-
(address) => [
|
|
132
|
-
{
|
|
133
|
-
address,
|
|
134
|
-
abi: import_abi.iPartialLiquidationBotV300Abi,
|
|
135
|
-
functionName: "minHealthFactor",
|
|
136
|
-
args: []
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
address,
|
|
140
|
-
abi: import_abi.iPartialLiquidationBotV300Abi,
|
|
141
|
-
functionName: "maxHealthFactor",
|
|
142
|
-
args: []
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
address,
|
|
146
|
-
abi: import_abi.iPartialLiquidationBotV300Abi,
|
|
147
|
-
functionName: "premiumScaleFactor",
|
|
148
|
-
args: []
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
address,
|
|
152
|
-
abi: import_abi.iPartialLiquidationBotV300Abi,
|
|
153
|
-
functionName: "feeScaleFactor",
|
|
154
|
-
args: []
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
).flat(1)
|
|
158
|
-
});
|
|
159
|
-
return addresses.reduce(
|
|
160
|
-
(acc, address, index) => {
|
|
161
|
-
const from = index * BOT_INFO_LENGTH;
|
|
162
|
-
const to = (index + 1) * BOT_INFO_LENGTH;
|
|
163
|
-
const [
|
|
164
|
-
minHealthFactor,
|
|
165
|
-
maxHealthFactor,
|
|
166
|
-
premiumScaleFactor,
|
|
167
|
-
feeScaleFactor
|
|
168
|
-
] = resp.slice(from, to);
|
|
169
|
-
acc[address] = {
|
|
170
|
-
minHealthFactor,
|
|
171
|
-
maxHealthFactor,
|
|
172
|
-
premiumScaleFactor,
|
|
173
|
-
feeScaleFactor
|
|
174
|
-
};
|
|
175
|
-
return acc;
|
|
176
|
-
},
|
|
177
|
-
{}
|
|
178
|
-
);
|
|
96
|
+
this.#botsByMarket.upsert(mc, bots);
|
|
179
97
|
}
|
|
180
98
|
stateHuman(raw) {
|
|
181
99
|
return {
|
|
@@ -187,6 +105,38 @@ class BotsPlugin extends import_sdk.SDKConstruct {
|
|
|
187
105
|
)
|
|
188
106
|
};
|
|
189
107
|
}
|
|
108
|
+
get state() {
|
|
109
|
+
return {
|
|
110
|
+
version: this.version,
|
|
111
|
+
bots: import_sdk.TypedObjectUtils.fromEntries(
|
|
112
|
+
this.#botsByMarket.entries().map(([mc, bots]) => [mc, bots.map((b) => b.state)])
|
|
113
|
+
)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
hydrate(state) {
|
|
117
|
+
this.#botsByMarket.clear();
|
|
118
|
+
for (const [mc, botStates] of import_sdk.TypedObjectUtils.entries(state.bots)) {
|
|
119
|
+
this.#loadStateMarketState(mc, botStates);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
#createBot(marketConfigurator, data) {
|
|
123
|
+
const v = Number(data.baseParams.version);
|
|
124
|
+
if ((0, import_sdk.isV300)(v)) {
|
|
125
|
+
return new import_PartialLiquidationBotV300Contract.PartialLiquidationBotV300Contract(
|
|
126
|
+
this.sdk,
|
|
127
|
+
data,
|
|
128
|
+
marketConfigurator
|
|
129
|
+
);
|
|
130
|
+
} else if ((0, import_sdk.isV310)(v)) {
|
|
131
|
+
return new import_PartialLiquidationBotV310Contract.PartialLiquidationBotV310Contract(
|
|
132
|
+
this.sdk,
|
|
133
|
+
data,
|
|
134
|
+
marketConfigurator
|
|
135
|
+
);
|
|
136
|
+
} else {
|
|
137
|
+
throw new Error(`unsupported bot version: ${v}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
190
140
|
}
|
|
191
141
|
// Annotate the CommonJS export names for ESM import in node:
|
|
192
142
|
0 && (module.exports = {
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
class PartialLiquidationBotBaseContract extends import_sdk.BaseContract {
|
|
27
|
+
requiredPermissions;
|
|
28
|
+
marketConfigurator;
|
|
29
|
+
#serializedParams;
|
|
30
|
+
constructor(sdk, args) {
|
|
31
|
+
super(sdk, args);
|
|
32
|
+
this.#serializedParams = args.serializedParams;
|
|
33
|
+
const [
|
|
34
|
+
treasury,
|
|
35
|
+
minHealthFactor,
|
|
36
|
+
maxHealthFactor,
|
|
37
|
+
premiumScaleFactor,
|
|
38
|
+
feeScaleFactor
|
|
39
|
+
] = (0, import_viem.decodeAbiParameters)(
|
|
40
|
+
[
|
|
41
|
+
{ name: "treasury", type: "address" },
|
|
42
|
+
{ name: "minHealthFactor", type: "uint16" },
|
|
43
|
+
{ name: "maxHealthFactor", type: "uint16" },
|
|
44
|
+
{ name: "premiumScaleFactor", type: "uint16" },
|
|
45
|
+
{ name: "feeScaleFactor", type: "uint16" }
|
|
46
|
+
],
|
|
47
|
+
args.serializedParams
|
|
48
|
+
);
|
|
49
|
+
this.treasury = treasury;
|
|
50
|
+
this.minHealthFactor = minHealthFactor;
|
|
51
|
+
this.maxHealthFactor = maxHealthFactor;
|
|
52
|
+
this.premiumScaleFactor = premiumScaleFactor;
|
|
53
|
+
this.feeScaleFactor = feeScaleFactor;
|
|
54
|
+
this.marketConfigurator = args.marketConfigurator;
|
|
55
|
+
this.requiredPermissions = args.requiredPermissions;
|
|
56
|
+
}
|
|
57
|
+
stateHuman(raw) {
|
|
58
|
+
return {
|
|
59
|
+
...super.stateHuman(raw),
|
|
60
|
+
treasury: this.treasury,
|
|
61
|
+
minHealthFactor: (0, import_sdk.formatPercentage)(this.minHealthFactor),
|
|
62
|
+
maxHealthFactor: (0, import_sdk.formatPercentage)(this.maxHealthFactor),
|
|
63
|
+
premiumScaleFactor: (0, import_sdk.formatPercentage)(this.premiumScaleFactor),
|
|
64
|
+
feeScaleFactor: (0, import_sdk.formatPercentage)(this.feeScaleFactor),
|
|
65
|
+
requiredPermissions: this.requiredPermissions.toString(10)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
get state() {
|
|
69
|
+
return {
|
|
70
|
+
baseParams: {
|
|
71
|
+
addr: this.address,
|
|
72
|
+
version: BigInt(this.version),
|
|
73
|
+
contractType: this.contractType,
|
|
74
|
+
serializedParams: this.#serializedParams
|
|
75
|
+
},
|
|
76
|
+
requiredPermissions: this.requiredPermissions
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
PartialLiquidationBotBaseContract
|
|
83
|
+
});
|
|
@@ -21,35 +21,43 @@ __export(PartialLiquidationBotV300Contract_exports, {
|
|
|
21
21
|
PartialLiquidationBotV300Contract: () => PartialLiquidationBotV300Contract
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(PartialLiquidationBotV300Contract_exports);
|
|
24
|
-
var import_sdk = require("../sdk/index.js");
|
|
25
24
|
var import_abi = require("./abi/index.js");
|
|
25
|
+
var import_PartialLiquidationBotBaseContract = require("./PartialLiquidationBotBaseContract.js");
|
|
26
26
|
const abi = import_abi.iPartialLiquidationBotV300Abi;
|
|
27
|
-
class PartialLiquidationBotV300Contract extends
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
marketConfigurator;
|
|
31
|
-
constructor(sdk, args, params, type, marketConfigurator) {
|
|
27
|
+
class PartialLiquidationBotV300Contract extends import_PartialLiquidationBotBaseContract.PartialLiquidationBotBaseContract {
|
|
28
|
+
#botType;
|
|
29
|
+
constructor(sdk, args, marketConfigurator) {
|
|
32
30
|
super(sdk, {
|
|
33
31
|
abi,
|
|
34
32
|
...args.baseParams,
|
|
35
|
-
|
|
33
|
+
requiredPermissions: args.requiredPermissions,
|
|
34
|
+
marketConfigurator,
|
|
35
|
+
name: "PartialLiquidationBotV300"
|
|
36
36
|
});
|
|
37
|
-
this.marketConfigurator = marketConfigurator;
|
|
38
|
-
this.requiredPermissions = args.requiredPermissions;
|
|
39
|
-
Object.assign(this, params);
|
|
40
|
-
this.botType = type;
|
|
41
37
|
}
|
|
42
38
|
stateHuman(raw) {
|
|
43
39
|
return {
|
|
44
40
|
...super.stateHuman(raw),
|
|
45
|
-
botType: this.botType
|
|
46
|
-
minHealthFactor: (0, import_sdk.formatPercentage)(this.minHealthFactor),
|
|
47
|
-
maxHealthFactor: (0, import_sdk.formatPercentage)(this.maxHealthFactor),
|
|
48
|
-
premiumScaleFactor: (0, import_sdk.formatPercentage)(this.premiumScaleFactor),
|
|
49
|
-
feeScaleFactor: (0, import_sdk.formatPercentage)(this.feeScaleFactor),
|
|
50
|
-
requiredPermissions: this.requiredPermissions.toString(10)
|
|
41
|
+
botType: this.botType
|
|
51
42
|
};
|
|
52
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
|
+
}
|
|
53
61
|
}
|
|
54
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
63
|
0 && (module.exports = {
|
|
@@ -0,0 +1,41 @@
|
|
|
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 PartialLiquidationBotV310Contract_exports = {};
|
|
20
|
+
__export(PartialLiquidationBotV310Contract_exports, {
|
|
21
|
+
PartialLiquidationBotV310Contract: () => PartialLiquidationBotV310Contract
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(PartialLiquidationBotV310Contract_exports);
|
|
24
|
+
var import_abi = require("./abi/index.js");
|
|
25
|
+
var import_PartialLiquidationBotBaseContract = require("./PartialLiquidationBotBaseContract.js");
|
|
26
|
+
const abi = import_abi.iPartialLiquidationBotV310Abi;
|
|
27
|
+
class PartialLiquidationBotV310Contract extends import_PartialLiquidationBotBaseContract.PartialLiquidationBotBaseContract {
|
|
28
|
+
constructor(sdk, args, marketConfigurator) {
|
|
29
|
+
super(sdk, {
|
|
30
|
+
abi,
|
|
31
|
+
...args.baseParams,
|
|
32
|
+
requiredPermissions: args.requiredPermissions,
|
|
33
|
+
marketConfigurator,
|
|
34
|
+
name: "PartialLiquidationBotV310"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
PartialLiquidationBotV310Contract
|
|
41
|
+
});
|
|
@@ -0,0 +1,164 @@
|
|
|
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 iPartialLiquidationBotV310_exports = {};
|
|
20
|
+
__export(iPartialLiquidationBotV310_exports, {
|
|
21
|
+
iPartialLiquidationBotV310Abi: () => iPartialLiquidationBotV310Abi
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(iPartialLiquidationBotV310_exports);
|
|
24
|
+
const iPartialLiquidationBotV310Abi = [
|
|
25
|
+
{
|
|
26
|
+
type: "function",
|
|
27
|
+
name: "contractType",
|
|
28
|
+
inputs: [],
|
|
29
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
30
|
+
stateMutability: "view"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "function",
|
|
34
|
+
name: "feeScaleFactor",
|
|
35
|
+
inputs: [],
|
|
36
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
37
|
+
stateMutability: "view"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: "function",
|
|
41
|
+
name: "maxHealthFactor",
|
|
42
|
+
inputs: [],
|
|
43
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
44
|
+
stateMutability: "view"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "function",
|
|
48
|
+
name: "minHealthFactor",
|
|
49
|
+
inputs: [],
|
|
50
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
51
|
+
stateMutability: "view"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: "function",
|
|
55
|
+
name: "partiallyLiquidate",
|
|
56
|
+
inputs: [
|
|
57
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
58
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
59
|
+
{ name: "repaidAmount", type: "uint256", internalType: "uint256" },
|
|
60
|
+
{ name: "minSeizedAmount", type: "uint256", internalType: "uint256" },
|
|
61
|
+
{ name: "to", type: "address", internalType: "address" },
|
|
62
|
+
{
|
|
63
|
+
name: "priceUpdates",
|
|
64
|
+
type: "tuple[]",
|
|
65
|
+
internalType: "struct PriceUpdate[]",
|
|
66
|
+
components: [
|
|
67
|
+
{ name: "priceFeed", type: "address", internalType: "address" },
|
|
68
|
+
{ name: "data", type: "bytes", internalType: "bytes" }
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
outputs: [
|
|
73
|
+
{ name: "seizedAmount", type: "uint256", internalType: "uint256" }
|
|
74
|
+
],
|
|
75
|
+
stateMutability: "nonpayable"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "function",
|
|
79
|
+
name: "premiumScaleFactor",
|
|
80
|
+
inputs: [],
|
|
81
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
82
|
+
stateMutability: "view"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: "function",
|
|
86
|
+
name: "requiredPermissions",
|
|
87
|
+
inputs: [],
|
|
88
|
+
outputs: [{ name: "", type: "uint192", internalType: "uint192" }],
|
|
89
|
+
stateMutability: "view"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: "function",
|
|
93
|
+
name: "serialize",
|
|
94
|
+
inputs: [],
|
|
95
|
+
outputs: [{ name: "serializedData", type: "bytes", internalType: "bytes" }],
|
|
96
|
+
stateMutability: "view"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: "function",
|
|
100
|
+
name: "treasury",
|
|
101
|
+
inputs: [],
|
|
102
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
103
|
+
stateMutability: "view"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
type: "function",
|
|
107
|
+
name: "version",
|
|
108
|
+
inputs: [],
|
|
109
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
110
|
+
stateMutability: "view"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: "event",
|
|
114
|
+
name: "PartiallyLiquidate",
|
|
115
|
+
inputs: [
|
|
116
|
+
{
|
|
117
|
+
name: "creditManager",
|
|
118
|
+
type: "address",
|
|
119
|
+
indexed: true,
|
|
120
|
+
internalType: "address"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "creditAccount",
|
|
124
|
+
type: "address",
|
|
125
|
+
indexed: true,
|
|
126
|
+
internalType: "address"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "token",
|
|
130
|
+
type: "address",
|
|
131
|
+
indexed: true,
|
|
132
|
+
internalType: "address"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "liquidator",
|
|
136
|
+
type: "address",
|
|
137
|
+
indexed: false,
|
|
138
|
+
internalType: "address"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "repaidDebt",
|
|
142
|
+
type: "uint256",
|
|
143
|
+
indexed: false,
|
|
144
|
+
internalType: "uint256"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "seizedCollateral",
|
|
148
|
+
type: "uint256",
|
|
149
|
+
indexed: false,
|
|
150
|
+
internalType: "uint256"
|
|
151
|
+
},
|
|
152
|
+
{ name: "fee", type: "uint256", indexed: false, internalType: "uint256" }
|
|
153
|
+
],
|
|
154
|
+
anonymous: false
|
|
155
|
+
},
|
|
156
|
+
{ type: "error", name: "LiquidatedLessThanNeededException", inputs: [] },
|
|
157
|
+
{ type: "error", name: "LiquidatedMoreThanNeededException", inputs: [] },
|
|
158
|
+
{ type: "error", name: "SeizedLessThanRequiredException", inputs: [] },
|
|
159
|
+
{ type: "error", name: "UnderlyingNotLiquidatableException", inputs: [] }
|
|
160
|
+
];
|
|
161
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
+
0 && (module.exports = {
|
|
163
|
+
iPartialLiquidationBotV310Abi
|
|
164
|
+
});
|
|
@@ -16,7 +16,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var abi_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(abi_exports);
|
|
18
18
|
__reExport(abi_exports, require("./iPartialLiquidationBotV300.js"), module.exports);
|
|
19
|
+
__reExport(abi_exports, require("./iPartialLiquidationBotV310.js"), module.exports);
|
|
19
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
21
|
0 && (module.exports = {
|
|
21
|
-
...require("./iPartialLiquidationBotV300.js")
|
|
22
|
+
...require("./iPartialLiquidationBotV300.js"),
|
|
23
|
+
...require("./iPartialLiquidationBotV310.js")
|
|
22
24
|
});
|
|
@@ -118,13 +118,13 @@ class GearboxSDK {
|
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
static hydrate(options, state) {
|
|
121
|
-
const { logger, ...rest } = options;
|
|
121
|
+
const { logger, plugins, ...rest } = options;
|
|
122
122
|
const provider = new import_chain.Provider({
|
|
123
123
|
...rest,
|
|
124
124
|
chainId: state.chainId,
|
|
125
125
|
networkType: state.network
|
|
126
126
|
});
|
|
127
|
-
return new GearboxSDK({ provider, logger }).#hydrate(rest, state);
|
|
127
|
+
return new GearboxSDK({ provider, plugins, logger }).#hydrate(rest, state);
|
|
128
128
|
}
|
|
129
129
|
constructor(options) {
|
|
130
130
|
this.#provider = options.provider;
|
|
@@ -132,11 +132,9 @@ class GearboxSDK {
|
|
|
132
132
|
this.priceFeeds = new import_pricefeeds.PriceFeedRegister(this);
|
|
133
133
|
this.strictContractTypes = options.strictContractTypes ?? false;
|
|
134
134
|
const pluginsInstances = {};
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
139
|
-
for (const [name, Plugin] of import_utils.TypedObjectUtils.entries(pluginConstructros)) {
|
|
135
|
+
for (const [name, Plugin] of import_utils.TypedObjectUtils.entries(
|
|
136
|
+
options.plugins ?? {}
|
|
137
|
+
)) {
|
|
140
138
|
pluginsInstances[name] = new Plugin(this);
|
|
141
139
|
}
|
|
142
140
|
this.plugins = pluginsInstances;
|
|
@@ -232,6 +230,15 @@ class GearboxSDK {
|
|
|
232
230
|
),
|
|
233
231
|
blockNumber: this.currentBlock
|
|
234
232
|
};
|
|
233
|
+
for (const [name, plugin] of import_utils.TypedObjectUtils.entries(this.plugins)) {
|
|
234
|
+
const pluginState = state.plugins[name];
|
|
235
|
+
if (plugin.hydrate && pluginState) {
|
|
236
|
+
if (pluginState.version !== plugin.version) {
|
|
237
|
+
throw new import_plugins.PluginStateVersionError(plugin, pluginState);
|
|
238
|
+
}
|
|
239
|
+
plugin.hydrate(pluginState);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
235
242
|
return this;
|
|
236
243
|
}
|
|
237
244
|
#confugureRedstone(opts) {
|
|
@@ -328,7 +335,13 @@ class GearboxSDK {
|
|
|
328
335
|
currentBlock: this.currentBlock,
|
|
329
336
|
timestamp: this.timestamp,
|
|
330
337
|
addressProvider: this.addressProvider.state,
|
|
331
|
-
markets: this.marketRegister.state
|
|
338
|
+
markets: this.marketRegister.state,
|
|
339
|
+
plugins: Object.fromEntries(
|
|
340
|
+
import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
|
|
341
|
+
name,
|
|
342
|
+
plugin.state
|
|
343
|
+
])
|
|
344
|
+
)
|
|
332
345
|
};
|
|
333
346
|
}
|
|
334
347
|
/**
|