@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
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
export declare const iPartialLiquidationBotV300Abi: readonly [{
|
|
2
|
+
readonly type: "function";
|
|
3
|
+
readonly name: "feeScaleFactor";
|
|
4
|
+
readonly inputs: readonly [];
|
|
5
|
+
readonly outputs: readonly [{
|
|
6
|
+
readonly name: "";
|
|
7
|
+
readonly type: "uint16";
|
|
8
|
+
readonly internalType: "uint16";
|
|
9
|
+
}];
|
|
10
|
+
readonly stateMutability: "view";
|
|
11
|
+
}, {
|
|
12
|
+
readonly type: "function";
|
|
13
|
+
readonly name: "liquidateExactCollateral";
|
|
14
|
+
readonly inputs: readonly [{
|
|
15
|
+
readonly name: "creditAccount";
|
|
16
|
+
readonly type: "address";
|
|
17
|
+
readonly internalType: "address";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "token";
|
|
20
|
+
readonly type: "address";
|
|
21
|
+
readonly internalType: "address";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "seizedAmount";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
readonly internalType: "uint256";
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "maxRepaidAmount";
|
|
28
|
+
readonly type: "uint256";
|
|
29
|
+
readonly internalType: "uint256";
|
|
30
|
+
}, {
|
|
31
|
+
readonly name: "to";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
readonly internalType: "address";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "priceUpdates";
|
|
36
|
+
readonly type: "tuple[]";
|
|
37
|
+
readonly internalType: "struct IPartialLiquidationBotV3.PriceUpdate[]";
|
|
38
|
+
readonly components: readonly [{
|
|
39
|
+
readonly name: "token";
|
|
40
|
+
readonly type: "address";
|
|
41
|
+
readonly internalType: "address";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "reserve";
|
|
44
|
+
readonly type: "bool";
|
|
45
|
+
readonly internalType: "bool";
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "data";
|
|
48
|
+
readonly type: "bytes";
|
|
49
|
+
readonly internalType: "bytes";
|
|
50
|
+
}];
|
|
51
|
+
}];
|
|
52
|
+
readonly outputs: readonly [{
|
|
53
|
+
readonly name: "repaidAmount";
|
|
54
|
+
readonly type: "uint256";
|
|
55
|
+
readonly internalType: "uint256";
|
|
56
|
+
}];
|
|
57
|
+
readonly stateMutability: "nonpayable";
|
|
58
|
+
}, {
|
|
59
|
+
readonly type: "function";
|
|
60
|
+
readonly name: "liquidateExactDebt";
|
|
61
|
+
readonly inputs: readonly [{
|
|
62
|
+
readonly name: "creditAccount";
|
|
63
|
+
readonly type: "address";
|
|
64
|
+
readonly internalType: "address";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "token";
|
|
67
|
+
readonly type: "address";
|
|
68
|
+
readonly internalType: "address";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "repaidAmount";
|
|
71
|
+
readonly type: "uint256";
|
|
72
|
+
readonly internalType: "uint256";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "minSeizedAmount";
|
|
75
|
+
readonly type: "uint256";
|
|
76
|
+
readonly internalType: "uint256";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "to";
|
|
79
|
+
readonly type: "address";
|
|
80
|
+
readonly internalType: "address";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "priceUpdates";
|
|
83
|
+
readonly type: "tuple[]";
|
|
84
|
+
readonly internalType: "struct IPartialLiquidationBotV3.PriceUpdate[]";
|
|
85
|
+
readonly components: readonly [{
|
|
86
|
+
readonly name: "token";
|
|
87
|
+
readonly type: "address";
|
|
88
|
+
readonly internalType: "address";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "reserve";
|
|
91
|
+
readonly type: "bool";
|
|
92
|
+
readonly internalType: "bool";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "data";
|
|
95
|
+
readonly type: "bytes";
|
|
96
|
+
readonly internalType: "bytes";
|
|
97
|
+
}];
|
|
98
|
+
}];
|
|
99
|
+
readonly outputs: readonly [{
|
|
100
|
+
readonly name: "seizedAmount";
|
|
101
|
+
readonly type: "uint256";
|
|
102
|
+
readonly internalType: "uint256";
|
|
103
|
+
}];
|
|
104
|
+
readonly stateMutability: "nonpayable";
|
|
105
|
+
}, {
|
|
106
|
+
readonly type: "function";
|
|
107
|
+
readonly name: "maxHealthFactor";
|
|
108
|
+
readonly inputs: readonly [];
|
|
109
|
+
readonly outputs: readonly [{
|
|
110
|
+
readonly name: "";
|
|
111
|
+
readonly type: "uint16";
|
|
112
|
+
readonly internalType: "uint16";
|
|
113
|
+
}];
|
|
114
|
+
readonly stateMutability: "view";
|
|
115
|
+
}, {
|
|
116
|
+
readonly type: "function";
|
|
117
|
+
readonly name: "minHealthFactor";
|
|
118
|
+
readonly inputs: readonly [];
|
|
119
|
+
readonly outputs: readonly [{
|
|
120
|
+
readonly name: "";
|
|
121
|
+
readonly type: "uint16";
|
|
122
|
+
readonly internalType: "uint16";
|
|
123
|
+
}];
|
|
124
|
+
readonly stateMutability: "view";
|
|
125
|
+
}, {
|
|
126
|
+
readonly type: "function";
|
|
127
|
+
readonly name: "premiumScaleFactor";
|
|
128
|
+
readonly inputs: readonly [];
|
|
129
|
+
readonly outputs: readonly [{
|
|
130
|
+
readonly name: "";
|
|
131
|
+
readonly type: "uint16";
|
|
132
|
+
readonly internalType: "uint16";
|
|
133
|
+
}];
|
|
134
|
+
readonly stateMutability: "view";
|
|
135
|
+
}, {
|
|
136
|
+
readonly type: "function";
|
|
137
|
+
readonly name: "treasury";
|
|
138
|
+
readonly inputs: readonly [];
|
|
139
|
+
readonly outputs: readonly [{
|
|
140
|
+
readonly name: "";
|
|
141
|
+
readonly type: "address";
|
|
142
|
+
readonly internalType: "address";
|
|
143
|
+
}];
|
|
144
|
+
readonly stateMutability: "view";
|
|
145
|
+
}, {
|
|
146
|
+
readonly type: "function";
|
|
147
|
+
readonly name: "version";
|
|
148
|
+
readonly inputs: readonly [];
|
|
149
|
+
readonly outputs: readonly [{
|
|
150
|
+
readonly name: "";
|
|
151
|
+
readonly type: "uint256";
|
|
152
|
+
readonly internalType: "uint256";
|
|
153
|
+
}];
|
|
154
|
+
readonly stateMutability: "view";
|
|
155
|
+
}, {
|
|
156
|
+
readonly type: "event";
|
|
157
|
+
readonly name: "LiquidatePartial";
|
|
158
|
+
readonly inputs: readonly [{
|
|
159
|
+
readonly name: "creditManager";
|
|
160
|
+
readonly type: "address";
|
|
161
|
+
readonly indexed: true;
|
|
162
|
+
readonly internalType: "address";
|
|
163
|
+
}, {
|
|
164
|
+
readonly name: "creditAccount";
|
|
165
|
+
readonly type: "address";
|
|
166
|
+
readonly indexed: true;
|
|
167
|
+
readonly internalType: "address";
|
|
168
|
+
}, {
|
|
169
|
+
readonly name: "token";
|
|
170
|
+
readonly type: "address";
|
|
171
|
+
readonly indexed: true;
|
|
172
|
+
readonly internalType: "address";
|
|
173
|
+
}, {
|
|
174
|
+
readonly name: "repaidDebt";
|
|
175
|
+
readonly type: "uint256";
|
|
176
|
+
readonly indexed: false;
|
|
177
|
+
readonly internalType: "uint256";
|
|
178
|
+
}, {
|
|
179
|
+
readonly name: "seizedCollateral";
|
|
180
|
+
readonly type: "uint256";
|
|
181
|
+
readonly indexed: false;
|
|
182
|
+
readonly internalType: "uint256";
|
|
183
|
+
}, {
|
|
184
|
+
readonly name: "fee";
|
|
185
|
+
readonly type: "uint256";
|
|
186
|
+
readonly indexed: false;
|
|
187
|
+
readonly internalType: "uint256";
|
|
188
|
+
}];
|
|
189
|
+
readonly anonymous: false;
|
|
190
|
+
}, {
|
|
191
|
+
readonly type: "error";
|
|
192
|
+
readonly name: "LiquidatedLessThanNeededException";
|
|
193
|
+
readonly inputs: readonly [];
|
|
194
|
+
}, {
|
|
195
|
+
readonly type: "error";
|
|
196
|
+
readonly name: "LiquidatedMoreThanNeededException";
|
|
197
|
+
readonly inputs: readonly [];
|
|
198
|
+
}, {
|
|
199
|
+
readonly type: "error";
|
|
200
|
+
readonly name: "RepaidMoreThanAllowedException";
|
|
201
|
+
readonly inputs: readonly [];
|
|
202
|
+
}, {
|
|
203
|
+
readonly type: "error";
|
|
204
|
+
readonly name: "SeizedLessThanRequiredException";
|
|
205
|
+
readonly inputs: readonly [];
|
|
206
|
+
}, {
|
|
207
|
+
readonly type: "error";
|
|
208
|
+
readonly name: "UnderlyingNotLiquidatableException";
|
|
209
|
+
readonly inputs: readonly [];
|
|
210
|
+
}];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./iPartialLiquidationBotV300.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
|
|
2
|
+
import type { iPeripheryCompressorAbi } from "../abi/compressors.js";
|
|
3
|
+
import type { BaseContractStateHuman, Unarray } from "../sdk/index.js";
|
|
4
|
+
export type BotState = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof iPeripheryCompressorAbi, "getBots">["outputs"]>>;
|
|
5
|
+
export interface BotParameters {
|
|
6
|
+
minHealthFactor: number;
|
|
7
|
+
maxHealthFactor: number;
|
|
8
|
+
premiumScaleFactor: number;
|
|
9
|
+
feeScaleFactor: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const BOT_TYPES: readonly ["PARTIAL_LIQUIDATION_BOT", "DELEVERAGE_BOT_PEGGED", "DELEVERAGE_BOT_LV", "DELEVERAGE_BOT_HV"];
|
|
12
|
+
export type BotType = (typeof BOT_TYPES)[number];
|
|
13
|
+
export interface BotStateV300Human extends BaseContractStateHuman {
|
|
14
|
+
botType: BotType;
|
|
15
|
+
minHealthFactor: string;
|
|
16
|
+
maxHealthFactor: string;
|
|
17
|
+
premiumScaleFactor: string;
|
|
18
|
+
feeScaleFactor: string;
|
|
19
|
+
requiredPermissions: string;
|
|
20
|
+
}
|
|
21
|
+
export interface BotsPluginStateHuman {
|
|
22
|
+
bots: Record<string, BotStateV300Human[]>;
|
|
23
|
+
}
|
|
@@ -17,7 +17,6 @@ export type RewardInfo = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunctio
|
|
|
17
17
|
export type MarketData = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof iMarketCompressorAbi, "getMarkets">["outputs"]>>;
|
|
18
18
|
export type GaugeData = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof iGaugeCompressorAbi, "getGauge">["outputs"]>>;
|
|
19
19
|
export type ConnectedBotData = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof iPeripheryCompressorAbi, "getConnectedBots">["outputs"]>>;
|
|
20
|
-
export type BotData = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof iPeripheryCompressorAbi, "getBots">["outputs"]>>;
|
|
21
20
|
export type CreditManagerData = Unarray<MarketData["creditManagers"]>;
|
|
22
21
|
export type CreditManagerState = CreditManagerData["creditManager"];
|
|
23
22
|
export type CreditFacadeState = CreditManagerData["creditFacade"];
|
|
@@ -10,6 +10,10 @@ export type PriceFeedConstructorArgs<abi extends Abi | readonly unknown[]> = Par
|
|
|
10
10
|
abi: abi;
|
|
11
11
|
name: string;
|
|
12
12
|
};
|
|
13
|
+
export declare class PartialPriceFeedInitError extends Error {
|
|
14
|
+
readonly priceFeed: PriceFeedConstructorArgs<any>;
|
|
15
|
+
constructor(priceFeed: PriceFeedConstructorArgs<any>);
|
|
16
|
+
}
|
|
13
17
|
export declare abstract class AbstractPriceFeedContract<const abi extends Abi | readonly unknown[]> extends BaseContract<abi> implements IPriceFeedContract {
|
|
14
18
|
#private;
|
|
15
19
|
hasLowerBoundCap: boolean;
|
|
@@ -4,7 +4,7 @@ import { SDKConstruct } from "../../base/index.js";
|
|
|
4
4
|
import type { GearboxSDK } from "../../GearboxSDK.js";
|
|
5
5
|
import type { ILogger, RawTx } from "../../types/index.js";
|
|
6
6
|
import type { IHooks } from "../../utils/internal/index.js";
|
|
7
|
-
import type
|
|
7
|
+
import { type PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
|
|
8
8
|
import { RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
9
9
|
import type { IPriceFeedContract, UpdatePriceFeedsResult } from "./types.js";
|
|
10
10
|
export type PriceFeedRegisterHooks = {
|
|
@@ -37,11 +37,14 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
|
|
|
37
37
|
getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
|
|
38
38
|
/**
|
|
39
39
|
* Loads PARTIAL information about all updatable price feeds from MarketCompressor
|
|
40
|
-
* This can later be used to load price feed updates
|
|
40
|
+
* This is not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
getPartialUpdatablePriceFeeds(marketConfigurators?: Address[], pools?: Address[]): Promise<IPriceFeedContract[]>;
|
|
43
43
|
/**
|
|
44
44
|
* Generates price update transaction via multicall3 without any market data knowledge
|
|
45
|
+
*
|
|
46
|
+
* @deprecated TODO: seems that it's not used anywhere
|
|
47
|
+
*
|
|
45
48
|
* @param marketConfigurators
|
|
46
49
|
* @param pools
|
|
47
50
|
* @returns
|
|
@@ -4,6 +4,7 @@ import type { GearboxSDK } from "../../GearboxSDK.js";
|
|
|
4
4
|
import type { RedstonePriceFeedStateHuman } from "../../types/index.js";
|
|
5
5
|
import type { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
|
|
6
6
|
import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
|
|
7
|
+
import type { IPriceFeedContract } from "./types.js";
|
|
7
8
|
type abi = typeof redstonePriceFeedAbi;
|
|
8
9
|
export declare class RedstonePriceFeedContract extends AbstractPriceFeedContract<abi> {
|
|
9
10
|
readonly token: Address;
|
|
@@ -16,4 +17,5 @@ export declare class RedstonePriceFeedContract extends AbstractPriceFeedContract
|
|
|
16
17
|
constructor(sdk: GearboxSDK, args: PartialPriceFeedTreeNode);
|
|
17
18
|
stateHuman(raw?: boolean): Omit<RedstonePriceFeedStateHuman, "stalenessPeriod">;
|
|
18
19
|
}
|
|
20
|
+
export declare function isRedstone(pf: IPriceFeedContract): pf is RedstonePriceFeedContract;
|
|
19
21
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type IGearboxSDKPlugin, SDKConstruct } from "../sdk/index.js";
|
|
2
2
|
import { AddressMap } from "../sdk/index.js";
|
|
3
3
|
import type { ZapperDataFull, ZapperStateHuman } from "./types.js";
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class ZappersPlugin extends SDKConstruct implements IGearboxSDKPlugin {
|
|
5
5
|
#private;
|
|
6
6
|
attach(): Promise<void>;
|
|
7
7
|
loadZappers(): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-vfour.
|
|
3
|
+
"version": "3.0.0-vfour.312",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"import": "./dist/esm/adapters/index.js",
|
|
21
21
|
"default": "./dist/cjs/adapters/index.js"
|
|
22
22
|
},
|
|
23
|
+
"./bots": {
|
|
24
|
+
"types": "./dist/types/bots/index.d.ts",
|
|
25
|
+
"import": "./dist/esm/bots/index.js",
|
|
26
|
+
"default": "./dist/cjs/bots/index.js"
|
|
27
|
+
},
|
|
23
28
|
"./dev": {
|
|
24
29
|
"types": "./dist/types/dev/index.d.ts",
|
|
25
30
|
"import": "./dist/esm/dev/index.js",
|
|
@@ -1,100 +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 BotsService_exports = {};
|
|
20
|
-
__export(BotsService_exports, {
|
|
21
|
-
BotsService: () => BotsService
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(BotsService_exports);
|
|
24
|
-
var import_viem = require("viem");
|
|
25
|
-
var import_base = require("../base/index.js");
|
|
26
|
-
const iPartialLiquidationBotV3Abi = (0, import_viem.parseAbi)([
|
|
27
|
-
"function minHealthFactor() external view returns (uint16)",
|
|
28
|
-
"function maxHealthFactor() external view returns (uint16)",
|
|
29
|
-
"function premiumScaleFactor() external view returns (uint16)",
|
|
30
|
-
"function feeScaleFactor() external view returns (uint16)"
|
|
31
|
-
]);
|
|
32
|
-
class BotsService extends import_base.SDKConstruct {
|
|
33
|
-
/**
|
|
34
|
-
* Returns bots data payload
|
|
35
|
-
* @param addresses
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
async getBotsData(addresses) {
|
|
39
|
-
const addressesList = Object.entries(addresses);
|
|
40
|
-
const BOT_INFO_LENGTH = 4;
|
|
41
|
-
const infoResp = await this.provider.publicClient.multicall({
|
|
42
|
-
allowFailure: false,
|
|
43
|
-
contracts: addressesList.map(([, address]) => [
|
|
44
|
-
{
|
|
45
|
-
address,
|
|
46
|
-
abi: iPartialLiquidationBotV3Abi,
|
|
47
|
-
functionName: "minHealthFactor",
|
|
48
|
-
args: []
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
address,
|
|
52
|
-
abi: iPartialLiquidationBotV3Abi,
|
|
53
|
-
functionName: "maxHealthFactor",
|
|
54
|
-
args: []
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
address,
|
|
58
|
-
abi: iPartialLiquidationBotV3Abi,
|
|
59
|
-
functionName: "premiumScaleFactor",
|
|
60
|
-
args: []
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
address,
|
|
64
|
-
abi: iPartialLiquidationBotV3Abi,
|
|
65
|
-
functionName: "feeScaleFactor",
|
|
66
|
-
args: []
|
|
67
|
-
}
|
|
68
|
-
]).flat(1)
|
|
69
|
-
});
|
|
70
|
-
const currentType = "liquidationProtection";
|
|
71
|
-
const bots = addressesList.reduce(
|
|
72
|
-
(acc, [type, address], index) => {
|
|
73
|
-
const from = index * BOT_INFO_LENGTH;
|
|
74
|
-
const to = (index + 1) * BOT_INFO_LENGTH;
|
|
75
|
-
const [
|
|
76
|
-
minHealthFactor,
|
|
77
|
-
maxHealthFactor,
|
|
78
|
-
premiumScaleFactor,
|
|
79
|
-
feeScaleFactor
|
|
80
|
-
] = infoResp.slice(from, to);
|
|
81
|
-
acc[currentType].push({
|
|
82
|
-
address,
|
|
83
|
-
baseType: currentType,
|
|
84
|
-
detailedType: type,
|
|
85
|
-
minHealthFactor,
|
|
86
|
-
maxHealthFactor,
|
|
87
|
-
premiumScaleFactor,
|
|
88
|
-
feeScaleFactor
|
|
89
|
-
});
|
|
90
|
-
return acc;
|
|
91
|
-
},
|
|
92
|
-
{ liquidationProtection: [] }
|
|
93
|
-
);
|
|
94
|
-
return bots;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
-
0 && (module.exports = {
|
|
99
|
-
BotsService
|
|
100
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { parseAbi } from "viem";
|
|
2
|
-
import { SDKConstruct } from "../base/index.js";
|
|
3
|
-
const iPartialLiquidationBotV3Abi = parseAbi([
|
|
4
|
-
"function minHealthFactor() external view returns (uint16)",
|
|
5
|
-
"function maxHealthFactor() external view returns (uint16)",
|
|
6
|
-
"function premiumScaleFactor() external view returns (uint16)",
|
|
7
|
-
"function feeScaleFactor() external view returns (uint16)"
|
|
8
|
-
]);
|
|
9
|
-
class BotsService extends SDKConstruct {
|
|
10
|
-
/**
|
|
11
|
-
* Returns bots data payload
|
|
12
|
-
* @param addresses
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
async getBotsData(addresses) {
|
|
16
|
-
const addressesList = Object.entries(addresses);
|
|
17
|
-
const BOT_INFO_LENGTH = 4;
|
|
18
|
-
const infoResp = await this.provider.publicClient.multicall({
|
|
19
|
-
allowFailure: false,
|
|
20
|
-
contracts: addressesList.map(([, address]) => [
|
|
21
|
-
{
|
|
22
|
-
address,
|
|
23
|
-
abi: iPartialLiquidationBotV3Abi,
|
|
24
|
-
functionName: "minHealthFactor",
|
|
25
|
-
args: []
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
address,
|
|
29
|
-
abi: iPartialLiquidationBotV3Abi,
|
|
30
|
-
functionName: "maxHealthFactor",
|
|
31
|
-
args: []
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
address,
|
|
35
|
-
abi: iPartialLiquidationBotV3Abi,
|
|
36
|
-
functionName: "premiumScaleFactor",
|
|
37
|
-
args: []
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
address,
|
|
41
|
-
abi: iPartialLiquidationBotV3Abi,
|
|
42
|
-
functionName: "feeScaleFactor",
|
|
43
|
-
args: []
|
|
44
|
-
}
|
|
45
|
-
]).flat(1)
|
|
46
|
-
});
|
|
47
|
-
const currentType = "liquidationProtection";
|
|
48
|
-
const bots = addressesList.reduce(
|
|
49
|
-
(acc, [type, address], index) => {
|
|
50
|
-
const from = index * BOT_INFO_LENGTH;
|
|
51
|
-
const to = (index + 1) * BOT_INFO_LENGTH;
|
|
52
|
-
const [
|
|
53
|
-
minHealthFactor,
|
|
54
|
-
maxHealthFactor,
|
|
55
|
-
premiumScaleFactor,
|
|
56
|
-
feeScaleFactor
|
|
57
|
-
] = infoResp.slice(from, to);
|
|
58
|
-
acc[currentType].push({
|
|
59
|
-
address,
|
|
60
|
-
baseType: currentType,
|
|
61
|
-
detailedType: type,
|
|
62
|
-
minHealthFactor,
|
|
63
|
-
maxHealthFactor,
|
|
64
|
-
premiumScaleFactor,
|
|
65
|
-
feeScaleFactor
|
|
66
|
-
});
|
|
67
|
-
return acc;
|
|
68
|
-
},
|
|
69
|
-
{ liquidationProtection: [] }
|
|
70
|
-
);
|
|
71
|
-
return bots;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export {
|
|
75
|
-
BotsService
|
|
76
|
-
};
|
|
File without changes
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
2
|
-
import { SDKConstruct } from "../base/index.js";
|
|
3
|
-
import type { BotDataPayload, BotDetailedType } from "./utils.js";
|
|
4
|
-
export type BotAddresses = Partial<Record<BotDetailedType, Address>>;
|
|
5
|
-
export declare class BotsService extends SDKConstruct {
|
|
6
|
-
/**
|
|
7
|
-
* Returns bots data payload
|
|
8
|
-
* @param addresses
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
getBotsData(addresses: BotAddresses): Promise<Record<"liquidationProtection", BotDataPayload[]>>;
|
|
12
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
export type BotBaseType = "liquidationProtection";
|
|
3
|
-
export type LiquidationBotType = "deleverageBotPegged" | "deleverageBotLV" | "deleverageBotHV";
|
|
4
|
-
export type BotDetailedType = LiquidationBotType;
|
|
5
|
-
export interface BotDataPayload {
|
|
6
|
-
baseType: BotBaseType;
|
|
7
|
-
detailedType: BotDetailedType;
|
|
8
|
-
address: Address;
|
|
9
|
-
minHealthFactor: number;
|
|
10
|
-
maxHealthFactor: number;
|
|
11
|
-
premiumScaleFactor: number;
|
|
12
|
-
feeScaleFactor: number;
|
|
13
|
-
}
|