@gearbox-protocol/sdk 11.11.3 → 11.12.1
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/plugins/bots/BotsPlugin.js +26 -111
- package/dist/cjs/plugins/bots/PartialLiquidationBotV310Contract.js +38 -6
- package/dist/cjs/plugins/bots/config.js +2 -5
- package/dist/cjs/plugins/bots/index.js +0 -2
- package/dist/cjs/plugins/bots/types.js +3 -11
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +38 -9
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +16 -1
- package/dist/esm/plugins/bots/BotsPlugin.js +28 -121
- package/dist/esm/plugins/bots/PartialLiquidationBotV310Contract.js +41 -6
- package/dist/esm/plugins/bots/config.js +2 -5
- package/dist/esm/plugins/bots/index.js +0 -1
- package/dist/esm/plugins/bots/types.js +2 -9
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +38 -9
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +17 -2
- package/dist/types/plugins/bots/BotsPlugin.d.ts +3 -13
- package/dist/types/plugins/bots/PartialLiquidationBotV310Contract.d.ts +19 -6
- package/dist/types/plugins/bots/config.d.ts +1 -1
- package/dist/types/plugins/bots/index.d.ts +0 -1
- package/dist/types/plugins/bots/types.d.ts +10 -25
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +5 -6
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +8 -6
- package/package.json +1 -1
- package/dist/cjs/plugins/bots/PartialLiquidationBotBaseContract.js +0 -75
- package/dist/cjs/plugins/bots/PartialLiquidationBotV300Contract.js +0 -65
- package/dist/esm/plugins/bots/PartialLiquidationBotBaseContract.js +0 -53
- package/dist/esm/plugins/bots/PartialLiquidationBotV300Contract.js +0 -41
- package/dist/types/plugins/bots/PartialLiquidationBotBaseContract.d.ts +0 -25
- package/dist/types/plugins/bots/PartialLiquidationBotV300Contract.d.ts +0 -227
|
@@ -1,15 +1,50 @@
|
|
|
1
|
+
import { decodeAbiParameters, stringToHex } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
BaseContract,
|
|
4
|
+
formatPercentage
|
|
5
|
+
} from "../../sdk/index.js";
|
|
1
6
|
import { iPartialLiquidationBotV310Abi } from "./abi/index.js";
|
|
2
|
-
import {
|
|
7
|
+
import { BOT_PARAMS_ABI } from "./types.js";
|
|
3
8
|
const abi = iPartialLiquidationBotV310Abi;
|
|
4
|
-
class PartialLiquidationBotV310Contract extends
|
|
5
|
-
|
|
9
|
+
class PartialLiquidationBotV310Contract extends BaseContract {
|
|
10
|
+
treasury;
|
|
11
|
+
minHealthFactor;
|
|
12
|
+
maxHealthFactor;
|
|
13
|
+
premiumScaleFactor;
|
|
14
|
+
feeScaleFactor;
|
|
15
|
+
#serializedParams;
|
|
16
|
+
constructor(sdk, args) {
|
|
6
17
|
super(sdk, {
|
|
18
|
+
...args,
|
|
7
19
|
abi,
|
|
8
|
-
...args.baseParams,
|
|
9
|
-
requiredPermissions: args.requiredPermissions,
|
|
10
|
-
marketConfigurator,
|
|
11
20
|
name: "PartialLiquidationBotV310"
|
|
12
21
|
});
|
|
22
|
+
[
|
|
23
|
+
this.treasury,
|
|
24
|
+
this.minHealthFactor,
|
|
25
|
+
this.maxHealthFactor,
|
|
26
|
+
this.premiumScaleFactor,
|
|
27
|
+
this.feeScaleFactor
|
|
28
|
+
] = decodeAbiParameters(BOT_PARAMS_ABI, args.serializedParams);
|
|
29
|
+
this.#serializedParams = args.serializedParams;
|
|
30
|
+
}
|
|
31
|
+
stateHuman(raw) {
|
|
32
|
+
return {
|
|
33
|
+
...super.stateHuman(raw),
|
|
34
|
+
treasury: this.treasury,
|
|
35
|
+
minHealthFactor: formatPercentage(this.minHealthFactor),
|
|
36
|
+
maxHealthFactor: formatPercentage(this.maxHealthFactor),
|
|
37
|
+
premiumScaleFactor: formatPercentage(this.premiumScaleFactor),
|
|
38
|
+
feeScaleFactor: formatPercentage(this.feeScaleFactor)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
get state() {
|
|
42
|
+
return {
|
|
43
|
+
addr: this.address,
|
|
44
|
+
version: BigInt(this.version),
|
|
45
|
+
contractType: stringToHex(this.contractType, { size: 32 }),
|
|
46
|
+
serializedParams: this.#serializedParams
|
|
47
|
+
};
|
|
13
48
|
}
|
|
14
49
|
}
|
|
15
50
|
export {
|
|
@@ -33,13 +33,10 @@ const LEGACY_MIGRATION_BOT = {
|
|
|
33
33
|
address: ACCOUNT_MIGRATOR_BOT,
|
|
34
34
|
previewer: ACCOUNT_MIGRATOR_PREVIEWER,
|
|
35
35
|
version: 310,
|
|
36
|
-
|
|
36
|
+
baseType: "LEGACY_MIGRATION"
|
|
37
37
|
};
|
|
38
38
|
const PERMISSION_BY_TYPE = {
|
|
39
|
-
|
|
40
|
-
BotPermissions.ADD_COLLATERAL | BotPermissions.WITHDRAW_COLLATERAL | BotPermissions.DECREASE_DEBT
|
|
41
|
-
),
|
|
42
|
-
MIGRATION: BigInt(
|
|
39
|
+
LEGACY_MIGRATION: BigInt(
|
|
43
40
|
BotPermissions.EXTERNAL_CALLS | BotPermissions.UPDATE_QUOTA | BotPermissions.DECREASE_DEBT
|
|
44
41
|
)
|
|
45
42
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
|
|
1
2
|
const BOT_PARAMS_ABI = [
|
|
2
3
|
{ type: "address", name: "treasury" },
|
|
3
4
|
{ type: "uint16", name: "minHealthFactor" },
|
|
@@ -5,15 +6,7 @@ const BOT_PARAMS_ABI = [
|
|
|
5
6
|
{ type: "uint16", name: "premiumScaleFactor" },
|
|
6
7
|
{ type: "uint16", name: "feeScaleFactor" }
|
|
7
8
|
];
|
|
8
|
-
const LIQUIDATION_BOT_TYPES = [
|
|
9
|
-
"PARTIAL_LIQUIDATION_BOT",
|
|
10
|
-
"DELEVERAGE_BOT_PEGGED",
|
|
11
|
-
"DELEVERAGE_BOT_LV",
|
|
12
|
-
"DELEVERAGE_BOT_HV"
|
|
13
|
-
];
|
|
14
|
-
const MIGRATION_BOT_TYPES = ["MIGRATION_BOT"];
|
|
15
9
|
export {
|
|
16
10
|
BOT_PARAMS_ABI,
|
|
17
|
-
|
|
18
|
-
MIGRATION_BOT_TYPES
|
|
11
|
+
BOT_PARTIAL_LIQUIDATION
|
|
19
12
|
};
|
|
@@ -195,12 +195,12 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
197
197
|
* Method to get all connected bots for credit account
|
|
198
|
-
* @param {Array<
|
|
198
|
+
* @param {Array<AccountToCheck>} accountsToCheck - list of credit accounts
|
|
199
199
|
and their credit managers to check connected bots on
|
|
200
200
|
* @returns call result of getConnectedBots for each credit account
|
|
201
201
|
*/
|
|
202
|
-
async getConnectedBots(accountsToCheck, legacyMigrationBot) {
|
|
203
|
-
const [resp, migration] = await Promise.all([
|
|
202
|
+
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
203
|
+
const [resp, migration, additional] = await Promise.all([
|
|
204
204
|
this.client.multicall({
|
|
205
205
|
contracts: accountsToCheck.map((o) => {
|
|
206
206
|
const pool = this.sdk.marketRegister.findByCreditManager(
|
|
@@ -215,12 +215,41 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
215
215
|
}),
|
|
216
216
|
allowFailure: true
|
|
217
217
|
}),
|
|
218
|
-
this.getActiveMigrationBots(accountsToCheck, legacyMigrationBot)
|
|
218
|
+
this.getActiveMigrationBots(accountsToCheck, legacyMigrationBot),
|
|
219
|
+
this.getActiveBots(accountsToCheck, additionalBots)
|
|
219
220
|
]);
|
|
220
|
-
return {
|
|
221
|
+
return {
|
|
222
|
+
legacy: resp,
|
|
223
|
+
additionalBots: additional,
|
|
224
|
+
legacyMigration: migration
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
async getActiveBots(accountsToCheck, bots) {
|
|
228
|
+
const result = await this.client.multicall({
|
|
229
|
+
contracts: accountsToCheck.flatMap((ca) => {
|
|
230
|
+
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
231
|
+
return bots.map((bot) => {
|
|
232
|
+
return {
|
|
233
|
+
abi: isV300(cm.creditFacade.version) ? iBotListV300Abi : iBotListV310Abi,
|
|
234
|
+
address: cm.creditFacade.botList,
|
|
235
|
+
functionName: "getBotStatus",
|
|
236
|
+
args: isV300(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
}),
|
|
240
|
+
allowFailure: true
|
|
241
|
+
});
|
|
242
|
+
const botsByCAIndex = accountsToCheck.reduce((acc, _, index) => {
|
|
243
|
+
const r = result.slice(index * bots.length, (index + 1) * bots.length);
|
|
244
|
+
acc.push({
|
|
245
|
+
result: r
|
|
246
|
+
});
|
|
247
|
+
return acc;
|
|
248
|
+
}, []);
|
|
249
|
+
return botsByCAIndex;
|
|
221
250
|
}
|
|
222
|
-
async getActiveMigrationBots(accountsToCheck,
|
|
223
|
-
if (
|
|
251
|
+
async getActiveMigrationBots(accountsToCheck, bot) {
|
|
252
|
+
if (bot) {
|
|
224
253
|
const result = await this.client.multicall({
|
|
225
254
|
contracts: accountsToCheck.map((ca) => {
|
|
226
255
|
const cm = this.sdk.marketRegister.findCreditManager(
|
|
@@ -230,12 +259,12 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
230
259
|
abi: isV300(cm.creditFacade.version) ? iBotListV300Abi : iBotListV310Abi,
|
|
231
260
|
address: cm.creditFacade.botList,
|
|
232
261
|
functionName: "getBotStatus",
|
|
233
|
-
args: isV300(cm.creditFacade.version) ? [
|
|
262
|
+
args: isV300(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
234
263
|
};
|
|
235
264
|
}),
|
|
236
265
|
allowFailure: true
|
|
237
266
|
});
|
|
238
|
-
return { result, botAddress:
|
|
267
|
+
return { result, botAddress: bot };
|
|
239
268
|
}
|
|
240
269
|
return void 0;
|
|
241
270
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { encodeFunctionData } from "viem";
|
|
1
|
+
import { encodeFunctionData, getContract } from "viem";
|
|
2
2
|
import { iCreditFacadeMulticallV310Abi } from "../../abi/310/generated.js";
|
|
3
3
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
4
4
|
import { AbstractCreditAccountService } from "./AbstractCreditAccountsService.js";
|
|
@@ -8,7 +8,7 @@ class CreditAccountServiceV310 extends AbstractCreditAccountService {
|
|
|
8
8
|
*/
|
|
9
9
|
async setBot({
|
|
10
10
|
botAddress,
|
|
11
|
-
permissions,
|
|
11
|
+
permissions: defaultPermissions,
|
|
12
12
|
targetContract
|
|
13
13
|
}) {
|
|
14
14
|
const cm = this.sdk.marketRegister.findCreditManager(
|
|
@@ -18,6 +18,21 @@ class CreditAccountServiceV310 extends AbstractCreditAccountService {
|
|
|
18
18
|
creditManager: targetContract.creditManager,
|
|
19
19
|
creditAccount: targetContract
|
|
20
20
|
}) : [];
|
|
21
|
+
const permissions = defaultPermissions !== null ? defaultPermissions : await getContract({
|
|
22
|
+
address: botAddress,
|
|
23
|
+
client: this.sdk.client,
|
|
24
|
+
abi: [
|
|
25
|
+
{
|
|
26
|
+
type: "function",
|
|
27
|
+
name: "requiredPermissions",
|
|
28
|
+
inputs: [],
|
|
29
|
+
outputs: [
|
|
30
|
+
{ name: "", type: "uint192", internalType: "uint192" }
|
|
31
|
+
],
|
|
32
|
+
stateMutability: "view"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}).read.requiredPermissions();
|
|
21
36
|
const addBotCall = {
|
|
22
37
|
target: cm.creditFacade.address,
|
|
23
38
|
callData: encodeFunctionData({
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
2
1
|
import type { IGearboxSDKPlugin } from "../../sdk/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import { PartialLiquidationBotV300Contract } from "./PartialLiquidationBotV300Contract.js";
|
|
2
|
+
import { BasePlugin } from "../../sdk/index.js";
|
|
5
3
|
import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
|
|
6
|
-
import { type
|
|
7
|
-
export declare class UnsupportedBotVersionError extends Error {
|
|
8
|
-
readonly state: BotState;
|
|
9
|
-
constructor(state: BotState);
|
|
10
|
-
}
|
|
11
|
-
export type PartialLiquidationBotContract = PartialLiquidationBotV300Contract | PartialLiquidationBotV310Contract;
|
|
4
|
+
import { type BotsPluginState, type BotsPluginStateHuman, type MigrationBotState } from "./types.js";
|
|
12
5
|
export declare class BotsPlugin extends BasePlugin<BotsPluginState> implements IGearboxSDKPlugin<BotsPluginState> {
|
|
13
6
|
#private;
|
|
14
7
|
get loaded(): boolean;
|
|
8
|
+
get bots(): PartialLiquidationBotV310Contract[];
|
|
15
9
|
load(force?: boolean): Promise<BotsPluginState>;
|
|
16
|
-
findDeployedPartialLiquidationBots(): Promise<AddressMap<BotParameters>>;
|
|
17
10
|
stateHuman(raw?: boolean): BotsPluginStateHuman;
|
|
18
|
-
get botsByMarket(): AddressMap<PartialLiquidationBotContract[]>;
|
|
19
|
-
botsByMarketConfigurator(mc: Address): PartialLiquidationBotContract[];
|
|
20
|
-
get allBots(): PartialLiquidationBotContract[];
|
|
21
11
|
get state(): BotsPluginState;
|
|
22
12
|
hydrate(state: BotsPluginState): void;
|
|
23
13
|
static getMigrationBotData(chainId: number): MigrationBotState | undefined;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
4
|
-
import type { BotState } from "./types.js";
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import { BaseContract, type GearboxSDK } from "../../sdk/index.js";
|
|
3
|
+
import { type BotStateV310Human } from "./types.js";
|
|
5
4
|
declare const abi: readonly [{
|
|
6
5
|
readonly type: "function";
|
|
7
6
|
readonly name: "contractType";
|
|
@@ -193,7 +192,21 @@ declare const abi: readonly [{
|
|
|
193
192
|
readonly inputs: readonly [];
|
|
194
193
|
}];
|
|
195
194
|
type abi = typeof abi;
|
|
196
|
-
export
|
|
197
|
-
|
|
195
|
+
export interface PartialLiquidationBotV310Params {
|
|
196
|
+
addr: Address;
|
|
197
|
+
version: bigint;
|
|
198
|
+
contractType: string;
|
|
199
|
+
serializedParams: Hex;
|
|
200
|
+
}
|
|
201
|
+
export declare class PartialLiquidationBotV310Contract extends BaseContract<abi> {
|
|
202
|
+
#private;
|
|
203
|
+
readonly treasury: Address;
|
|
204
|
+
readonly minHealthFactor: number;
|
|
205
|
+
readonly maxHealthFactor: number;
|
|
206
|
+
readonly premiumScaleFactor: number;
|
|
207
|
+
readonly feeScaleFactor: number;
|
|
208
|
+
constructor(sdk: GearboxSDK, args: PartialLiquidationBotV310Params);
|
|
209
|
+
stateHuman(raw?: boolean): BotStateV310Human;
|
|
210
|
+
get state(): PartialLiquidationBotV310Params;
|
|
198
211
|
}
|
|
199
212
|
export {};
|
|
@@ -5,4 +5,4 @@ export declare const PARTIAL_LIQUIDATION_BOT_CONFIGS: Partial<Record<NetworkType
|
|
|
5
5
|
export declare const PARTIAL_LIQUIDATION_BOT_SALT = "GEARBOX";
|
|
6
6
|
export declare const PARTIAL_LIQUIDATION_BOT_DEPLOYER: Address;
|
|
7
7
|
export declare const LEGACY_MIGRATION_BOT: MigrationBotState;
|
|
8
|
-
export declare const PERMISSION_BY_TYPE: Record<BotBaseType, bigint>;
|
|
8
|
+
export declare const PERMISSION_BY_TYPE: Record<Extract<BotBaseType, "LEGACY_MIGRATION">, bigint>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
|
|
2
1
|
import type { Address } from "viem";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
export type BotState = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof peripheryCompressorAbi, "getBots">["outputs"]>>;
|
|
2
|
+
import type { BaseContractStateHuman } from "../../sdk/index.js";
|
|
3
|
+
import type { PartialLiquidationBotV310Params } from "./PartialLiquidationBotV310Contract.js";
|
|
6
4
|
export interface BotParameters {
|
|
7
5
|
treasury: Address;
|
|
8
6
|
minHealthFactor: number;
|
|
@@ -10,6 +8,7 @@ export interface BotParameters {
|
|
|
10
8
|
premiumScaleFactor: number;
|
|
11
9
|
feeScaleFactor: number;
|
|
12
10
|
}
|
|
11
|
+
export declare const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
|
|
13
12
|
export declare const BOT_PARAMS_ABI: readonly [{
|
|
14
13
|
readonly type: "address";
|
|
15
14
|
readonly name: "treasury";
|
|
@@ -26,39 +25,25 @@ export declare const BOT_PARAMS_ABI: readonly [{
|
|
|
26
25
|
readonly type: "uint16";
|
|
27
26
|
readonly name: "feeScaleFactor";
|
|
28
27
|
}];
|
|
29
|
-
export
|
|
30
|
-
export type LiquidationBotType = (typeof LIQUIDATION_BOT_TYPES)[number];
|
|
31
|
-
export interface BotStateBaseHuman extends BaseContractStateHuman {
|
|
28
|
+
export interface BotStateV310Human extends BaseContractStateHuman {
|
|
32
29
|
treasury: Address;
|
|
33
30
|
minHealthFactor: string;
|
|
34
31
|
maxHealthFactor: string;
|
|
35
32
|
premiumScaleFactor: string;
|
|
36
33
|
feeScaleFactor: string;
|
|
37
|
-
requiredPermissions: string;
|
|
38
34
|
}
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
export type BotStateV310Human = BotStateBaseHuman;
|
|
43
|
-
export type BotStateHuman = BotStateV300Human | BotStateV310Human;
|
|
35
|
+
export type BotStateHuman = BotStateV310Human;
|
|
36
|
+
export type BotState = PartialLiquidationBotV310Params;
|
|
44
37
|
export interface BotsPluginStateHuman {
|
|
45
|
-
|
|
46
|
-
* Mapping market configurator to bot states
|
|
47
|
-
*/
|
|
48
|
-
bots: Record<string, BotStateHuman[]>;
|
|
38
|
+
bots: BotStateHuman[];
|
|
49
39
|
}
|
|
50
40
|
export interface BotsPluginState {
|
|
51
|
-
|
|
52
|
-
* Mapping market configurator address to bot states
|
|
53
|
-
*/
|
|
54
|
-
bots: Record<Address, BotState[]>;
|
|
41
|
+
bots: BotState[];
|
|
55
42
|
}
|
|
56
|
-
export type BotBaseType = "LIQUIDATION_PROTECTION" | "
|
|
57
|
-
export declare const MIGRATION_BOT_TYPES: readonly ["MIGRATION_BOT"];
|
|
58
|
-
export type MigrationBotType = (typeof MIGRATION_BOT_TYPES)[number];
|
|
43
|
+
export type BotBaseType = "LIQUIDATION_PROTECTION" | "LEGACY_MIGRATION";
|
|
59
44
|
export type MigrationBotState = {
|
|
60
45
|
address: Address;
|
|
61
46
|
version: 310;
|
|
62
47
|
previewer: Address;
|
|
63
|
-
|
|
48
|
+
baseType: Extract<BotBaseType, "LEGACY_MIGRATION">;
|
|
64
49
|
};
|
|
@@ -5,7 +5,7 @@ import type { GearboxSDK } from "../GearboxSDK.js";
|
|
|
5
5
|
import type { OnDemandPriceUpdates, PriceUpdateV300, PriceUpdateV310, UpdatePriceFeedsResult } from "../market/index.js";
|
|
6
6
|
import { type Asset, type RouterCASlice } from "../router/index.js";
|
|
7
7
|
import type { MultiCall } from "../types/index.js";
|
|
8
|
-
import type { AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, EnableTokensProps, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, PriceUpdatesOptions, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
|
|
8
|
+
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, EnableTokensProps, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, PriceUpdatesOptions, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
|
|
9
9
|
export interface CreditAccountServiceOptions {
|
|
10
10
|
batchSize?: number;
|
|
11
11
|
}
|
|
@@ -39,17 +39,16 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
39
39
|
getRewards(creditAccount: Address): Promise<Array<Rewards>>;
|
|
40
40
|
/**
|
|
41
41
|
* Method to get all connected bots for credit account
|
|
42
|
-
* @param {Array<
|
|
42
|
+
* @param {Array<AccountToCheck>} accountsToCheck - list of credit accounts
|
|
43
43
|
and their credit managers to check connected bots on
|
|
44
44
|
* @returns call result of getConnectedBots for each credit account
|
|
45
45
|
*/
|
|
46
|
-
getConnectedBots(accountsToCheck: Array<{
|
|
47
|
-
creditAccount: Address;
|
|
48
|
-
creditManager: Address;
|
|
49
|
-
}>, legacyMigrationBot: Address | undefined): Promise<{
|
|
46
|
+
getConnectedBots(accountsToCheck: Array<AccountToCheck>, legacyMigrationBot: Address | undefined, additionalBots: Array<Address>): Promise<{
|
|
50
47
|
legacy: GetConnectedBotsResult;
|
|
51
48
|
legacyMigration: GetConnectedMigrationBotsResult;
|
|
49
|
+
additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
|
|
52
50
|
}>;
|
|
51
|
+
private getActiveBots;
|
|
53
52
|
private getActiveMigrationBots;
|
|
54
53
|
/**
|
|
55
54
|
* Generates transaction to liquidate credit account
|
|
@@ -4,7 +4,7 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
|
|
|
4
4
|
/**
|
|
5
5
|
* Implements {@link ICreditAccountsService.setBot}
|
|
6
6
|
*/
|
|
7
|
-
setBot({ botAddress, permissions, targetContract, }: SetBotProps): Promise<CreditAccountOperationResult | CreditManagerOperationResult>;
|
|
7
|
+
setBot({ botAddress, permissions: defaultPermissions, targetContract, }: SetBotProps): Promise<CreditAccountOperationResult | CreditManagerOperationResult>;
|
|
8
8
|
/**
|
|
9
9
|
* Implements {@link ICreditAccountsService.withdrawCollateral}
|
|
10
10
|
*/
|
|
@@ -164,6 +164,10 @@ export interface WithdrawCollateralProps extends PrepareUpdateQuotasProps {
|
|
|
164
164
|
*/
|
|
165
165
|
creditAccount: RouterCASlice;
|
|
166
166
|
}
|
|
167
|
+
export type AccountToCheck = {
|
|
168
|
+
creditAccount: Address;
|
|
169
|
+
creditManager: Address;
|
|
170
|
+
};
|
|
167
171
|
export interface ExecuteSwapProps extends PrepareUpdateQuotasProps {
|
|
168
172
|
/**
|
|
169
173
|
* Array of MultiCall from router methods getSingleSwap or getAllSwaps
|
|
@@ -376,7 +380,7 @@ export interface SetBotProps {
|
|
|
376
380
|
/**
|
|
377
381
|
* Permissions to set for the bot
|
|
378
382
|
*/
|
|
379
|
-
permissions: bigint;
|
|
383
|
+
permissions: bigint | null;
|
|
380
384
|
/**
|
|
381
385
|
* Minimal credit account data {@link RouterCASlice} on which operation is performed; if omitted, credit manager data is used
|
|
382
386
|
* Minimal credit manager data {@link CMSlice} on which operation is performed; used only if credit account is omitted
|
|
@@ -434,17 +438,15 @@ export interface ICreditAccountsService extends SDKConstruct {
|
|
|
434
438
|
getRewards(creditAccount: Address): Promise<Array<Rewards>>;
|
|
435
439
|
/**
|
|
436
440
|
* Method to get all connected bots for credit account
|
|
437
|
-
* @param {Array<
|
|
441
|
+
* @param {Array<AccountToCheck>} accountsToCheck - list of credit accounts
|
|
438
442
|
* @param {Address | undefined} legacyMigrationBot - address of the bot to check connected bots on
|
|
439
443
|
* and their credit managers to check connected bots on
|
|
440
444
|
* @returns call result of getConnectedBots for each credit account
|
|
441
445
|
*/
|
|
442
|
-
getConnectedBots(accountsToCheck: Array<{
|
|
443
|
-
creditAccount: Address;
|
|
444
|
-
creditManager: Address;
|
|
445
|
-
}>, legacyMigrationBot: Address | undefined): Promise<{
|
|
446
|
+
getConnectedBots(accountsToCheck: Array<AccountToCheck>, legacyMigrationBot: Address | undefined, additionalBots: Array<Address>): Promise<{
|
|
446
447
|
legacy: GetConnectedBotsResult;
|
|
447
448
|
legacyMigration: GetConnectedMigrationBotsResult;
|
|
449
|
+
additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
|
|
448
450
|
}>;
|
|
449
451
|
/**
|
|
450
452
|
* V3.1 method, throws in V3. Connects/disables a bot and updates prices
|
package/package.json
CHANGED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var PartialLiquidationBotBaseContract_exports = {};
|
|
20
|
-
__export(PartialLiquidationBotBaseContract_exports, {
|
|
21
|
-
PartialLiquidationBotBaseContract: () => PartialLiquidationBotBaseContract
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(PartialLiquidationBotBaseContract_exports);
|
|
24
|
-
var import_viem = require("viem");
|
|
25
|
-
var import_sdk = require("../../sdk/index.js");
|
|
26
|
-
var import_types = require("./types.js");
|
|
27
|
-
class PartialLiquidationBotBaseContract extends import_sdk.BaseContract {
|
|
28
|
-
requiredPermissions;
|
|
29
|
-
marketConfigurator;
|
|
30
|
-
#serializedParams;
|
|
31
|
-
constructor(sdk, args) {
|
|
32
|
-
super(sdk, args);
|
|
33
|
-
this.#serializedParams = args.serializedParams;
|
|
34
|
-
const [
|
|
35
|
-
treasury,
|
|
36
|
-
minHealthFactor,
|
|
37
|
-
maxHealthFactor,
|
|
38
|
-
premiumScaleFactor,
|
|
39
|
-
feeScaleFactor
|
|
40
|
-
] = (0, import_viem.decodeAbiParameters)(import_types.BOT_PARAMS_ABI, args.serializedParams);
|
|
41
|
-
this.treasury = treasury;
|
|
42
|
-
this.minHealthFactor = minHealthFactor;
|
|
43
|
-
this.maxHealthFactor = maxHealthFactor;
|
|
44
|
-
this.premiumScaleFactor = premiumScaleFactor;
|
|
45
|
-
this.feeScaleFactor = feeScaleFactor;
|
|
46
|
-
this.marketConfigurator = args.marketConfigurator;
|
|
47
|
-
this.requiredPermissions = args.requiredPermissions;
|
|
48
|
-
}
|
|
49
|
-
stateHuman(raw) {
|
|
50
|
-
return {
|
|
51
|
-
...super.stateHuman(raw),
|
|
52
|
-
treasury: this.treasury,
|
|
53
|
-
minHealthFactor: (0, import_sdk.formatPercentage)(this.minHealthFactor),
|
|
54
|
-
maxHealthFactor: (0, import_sdk.formatPercentage)(this.maxHealthFactor),
|
|
55
|
-
premiumScaleFactor: (0, import_sdk.formatPercentage)(this.premiumScaleFactor),
|
|
56
|
-
feeScaleFactor: (0, import_sdk.formatPercentage)(this.feeScaleFactor),
|
|
57
|
-
requiredPermissions: this.requiredPermissions.toString(10)
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
get state() {
|
|
61
|
-
return {
|
|
62
|
-
baseParams: {
|
|
63
|
-
addr: this.address,
|
|
64
|
-
version: BigInt(this.version),
|
|
65
|
-
contractType: this.contractType,
|
|
66
|
-
serializedParams: this.#serializedParams
|
|
67
|
-
},
|
|
68
|
-
requiredPermissions: this.requiredPermissions
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
-
0 && (module.exports = {
|
|
74
|
-
PartialLiquidationBotBaseContract
|
|
75
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var PartialLiquidationBotV300Contract_exports = {};
|
|
20
|
-
__export(PartialLiquidationBotV300Contract_exports, {
|
|
21
|
-
PartialLiquidationBotV300Contract: () => PartialLiquidationBotV300Contract
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(PartialLiquidationBotV300Contract_exports);
|
|
24
|
-
var import_abi = require("./abi/index.js");
|
|
25
|
-
var import_PartialLiquidationBotBaseContract = require("./PartialLiquidationBotBaseContract.js");
|
|
26
|
-
const abi = import_abi.iPartialLiquidationBotV300Abi;
|
|
27
|
-
class PartialLiquidationBotV300Contract extends import_PartialLiquidationBotBaseContract.PartialLiquidationBotBaseContract {
|
|
28
|
-
#botType;
|
|
29
|
-
constructor(sdk, args, marketConfigurator) {
|
|
30
|
-
super(sdk, {
|
|
31
|
-
abi,
|
|
32
|
-
...args.baseParams,
|
|
33
|
-
requiredPermissions: args.requiredPermissions,
|
|
34
|
-
marketConfigurator,
|
|
35
|
-
name: "PartialLiquidationBotV300"
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
stateHuman(raw) {
|
|
39
|
-
return {
|
|
40
|
-
...super.stateHuman(raw),
|
|
41
|
-
botType: this.botType
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Set the bot type
|
|
46
|
-
* This method should only be called once from BotsPlugin
|
|
47
|
-
*/
|
|
48
|
-
set botType(type) {
|
|
49
|
-
if (this.#botType) {
|
|
50
|
-
throw new Error("bot type already set");
|
|
51
|
-
}
|
|
52
|
-
this.#botType = type;
|
|
53
|
-
this.name = `PartialLiquidationBotV300 (${type})`;
|
|
54
|
-
}
|
|
55
|
-
get botType() {
|
|
56
|
-
if (!this.#botType) {
|
|
57
|
-
throw new Error("bot type not set");
|
|
58
|
-
}
|
|
59
|
-
return this.#botType;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
-
0 && (module.exports = {
|
|
64
|
-
PartialLiquidationBotV300Contract
|
|
65
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { decodeAbiParameters } from "viem";
|
|
2
|
-
import { BaseContract, formatPercentage } from "../../sdk/index.js";
|
|
3
|
-
import {
|
|
4
|
-
BOT_PARAMS_ABI
|
|
5
|
-
} from "./types.js";
|
|
6
|
-
class PartialLiquidationBotBaseContract extends BaseContract {
|
|
7
|
-
requiredPermissions;
|
|
8
|
-
marketConfigurator;
|
|
9
|
-
#serializedParams;
|
|
10
|
-
constructor(sdk, args) {
|
|
11
|
-
super(sdk, args);
|
|
12
|
-
this.#serializedParams = args.serializedParams;
|
|
13
|
-
const [
|
|
14
|
-
treasury,
|
|
15
|
-
minHealthFactor,
|
|
16
|
-
maxHealthFactor,
|
|
17
|
-
premiumScaleFactor,
|
|
18
|
-
feeScaleFactor
|
|
19
|
-
] = decodeAbiParameters(BOT_PARAMS_ABI, args.serializedParams);
|
|
20
|
-
this.treasury = treasury;
|
|
21
|
-
this.minHealthFactor = minHealthFactor;
|
|
22
|
-
this.maxHealthFactor = maxHealthFactor;
|
|
23
|
-
this.premiumScaleFactor = premiumScaleFactor;
|
|
24
|
-
this.feeScaleFactor = feeScaleFactor;
|
|
25
|
-
this.marketConfigurator = args.marketConfigurator;
|
|
26
|
-
this.requiredPermissions = args.requiredPermissions;
|
|
27
|
-
}
|
|
28
|
-
stateHuman(raw) {
|
|
29
|
-
return {
|
|
30
|
-
...super.stateHuman(raw),
|
|
31
|
-
treasury: this.treasury,
|
|
32
|
-
minHealthFactor: formatPercentage(this.minHealthFactor),
|
|
33
|
-
maxHealthFactor: formatPercentage(this.maxHealthFactor),
|
|
34
|
-
premiumScaleFactor: formatPercentage(this.premiumScaleFactor),
|
|
35
|
-
feeScaleFactor: formatPercentage(this.feeScaleFactor),
|
|
36
|
-
requiredPermissions: this.requiredPermissions.toString(10)
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
get state() {
|
|
40
|
-
return {
|
|
41
|
-
baseParams: {
|
|
42
|
-
addr: this.address,
|
|
43
|
-
version: BigInt(this.version),
|
|
44
|
-
contractType: this.contractType,
|
|
45
|
-
serializedParams: this.#serializedParams
|
|
46
|
-
},
|
|
47
|
-
requiredPermissions: this.requiredPermissions
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
PartialLiquidationBotBaseContract
|
|
53
|
-
};
|