@gearbox-protocol/sdk 16.3.1-next.1 → 16.3.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.
Files changed (27) hide show
  1. package/dist/cjs/plugins/bots/BotsPlugin.js +107 -0
  2. package/dist/cjs/plugins/bots/PartialLiquidationBotV310Contract.js +47 -0
  3. package/dist/cjs/plugins/bots/abi/iPartialLiquidationBotV310.js +225 -0
  4. package/dist/cjs/plugins/bots/abi/index.js +3 -0
  5. package/dist/cjs/plugins/bots/config.js +39 -0
  6. package/dist/cjs/plugins/bots/deserializePartialLiquidationBotParams.js +39 -0
  7. package/dist/cjs/plugins/bots/index.js +17 -0
  8. package/dist/cjs/plugins/bots/package.json +1 -0
  9. package/dist/cjs/plugins/bots/types.js +28 -0
  10. package/dist/esm/plugins/bots/BotsPlugin.js +106 -0
  11. package/dist/esm/plugins/bots/PartialLiquidationBotV310Contract.js +46 -0
  12. package/dist/esm/plugins/bots/abi/iPartialLiquidationBotV310.js +224 -0
  13. package/dist/esm/plugins/bots/abi/index.js +2 -0
  14. package/dist/esm/plugins/bots/config.js +34 -0
  15. package/dist/esm/plugins/bots/deserializePartialLiquidationBotParams.js +35 -0
  16. package/dist/esm/plugins/bots/index.js +7 -0
  17. package/dist/esm/plugins/bots/package.json +1 -0
  18. package/dist/esm/plugins/bots/types.js +26 -0
  19. package/dist/types/plugins/bots/BotsPlugin.d.ts +18 -0
  20. package/dist/types/plugins/bots/PartialLiquidationBotV310Contract.d.ts +216 -0
  21. package/dist/types/plugins/bots/abi/iPartialLiquidationBotV310.d.ts +193 -0
  22. package/dist/types/plugins/bots/abi/index.d.ts +2 -0
  23. package/dist/types/plugins/bots/config.d.ts +12 -0
  24. package/dist/types/plugins/bots/deserializePartialLiquidationBotParams.d.ts +7 -0
  25. package/dist/types/plugins/bots/index.d.ts +7 -0
  26. package/dist/types/plugins/bots/types.d.ts +53 -0
  27. package/package.json +1 -1
@@ -0,0 +1,224 @@
1
+ //#region src/plugins/bots/abi/iPartialLiquidationBotV310.ts
2
+ const iPartialLiquidationBotV310Abi = [
3
+ {
4
+ type: "function",
5
+ name: "contractType",
6
+ inputs: [],
7
+ outputs: [{
8
+ name: "",
9
+ type: "bytes32",
10
+ internalType: "bytes32"
11
+ }],
12
+ stateMutability: "view"
13
+ },
14
+ {
15
+ type: "function",
16
+ name: "feeScaleFactor",
17
+ inputs: [],
18
+ outputs: [{
19
+ name: "",
20
+ type: "uint16",
21
+ internalType: "uint16"
22
+ }],
23
+ stateMutability: "view"
24
+ },
25
+ {
26
+ type: "function",
27
+ name: "maxHealthFactor",
28
+ inputs: [],
29
+ outputs: [{
30
+ name: "",
31
+ type: "uint16",
32
+ internalType: "uint16"
33
+ }],
34
+ stateMutability: "view"
35
+ },
36
+ {
37
+ type: "function",
38
+ name: "minHealthFactor",
39
+ inputs: [],
40
+ outputs: [{
41
+ name: "",
42
+ type: "uint16",
43
+ internalType: "uint16"
44
+ }],
45
+ stateMutability: "view"
46
+ },
47
+ {
48
+ type: "function",
49
+ name: "partiallyLiquidate",
50
+ inputs: [
51
+ {
52
+ name: "creditAccount",
53
+ type: "address",
54
+ internalType: "address"
55
+ },
56
+ {
57
+ name: "token",
58
+ type: "address",
59
+ internalType: "address"
60
+ },
61
+ {
62
+ name: "repaidAmount",
63
+ type: "uint256",
64
+ internalType: "uint256"
65
+ },
66
+ {
67
+ name: "minSeizedAmount",
68
+ type: "uint256",
69
+ internalType: "uint256"
70
+ },
71
+ {
72
+ name: "to",
73
+ type: "address",
74
+ internalType: "address"
75
+ },
76
+ {
77
+ name: "priceUpdates",
78
+ type: "tuple[]",
79
+ internalType: "struct PriceUpdate[]",
80
+ components: [{
81
+ name: "priceFeed",
82
+ type: "address",
83
+ internalType: "address"
84
+ }, {
85
+ name: "data",
86
+ type: "bytes",
87
+ internalType: "bytes"
88
+ }]
89
+ }
90
+ ],
91
+ outputs: [{
92
+ name: "seizedAmount",
93
+ type: "uint256",
94
+ internalType: "uint256"
95
+ }],
96
+ stateMutability: "nonpayable"
97
+ },
98
+ {
99
+ type: "function",
100
+ name: "premiumScaleFactor",
101
+ inputs: [],
102
+ outputs: [{
103
+ name: "",
104
+ type: "uint16",
105
+ internalType: "uint16"
106
+ }],
107
+ stateMutability: "view"
108
+ },
109
+ {
110
+ type: "function",
111
+ name: "requiredPermissions",
112
+ inputs: [],
113
+ outputs: [{
114
+ name: "",
115
+ type: "uint192",
116
+ internalType: "uint192"
117
+ }],
118
+ stateMutability: "view"
119
+ },
120
+ {
121
+ type: "function",
122
+ name: "serialize",
123
+ inputs: [],
124
+ outputs: [{
125
+ name: "serializedData",
126
+ type: "bytes",
127
+ internalType: "bytes"
128
+ }],
129
+ stateMutability: "view"
130
+ },
131
+ {
132
+ type: "function",
133
+ name: "treasury",
134
+ inputs: [],
135
+ outputs: [{
136
+ name: "",
137
+ type: "address",
138
+ internalType: "address"
139
+ }],
140
+ stateMutability: "view"
141
+ },
142
+ {
143
+ type: "function",
144
+ name: "version",
145
+ inputs: [],
146
+ outputs: [{
147
+ name: "",
148
+ type: "uint256",
149
+ internalType: "uint256"
150
+ }],
151
+ stateMutability: "view"
152
+ },
153
+ {
154
+ type: "event",
155
+ name: "PartiallyLiquidate",
156
+ inputs: [
157
+ {
158
+ name: "creditManager",
159
+ type: "address",
160
+ indexed: true,
161
+ internalType: "address"
162
+ },
163
+ {
164
+ name: "creditAccount",
165
+ type: "address",
166
+ indexed: true,
167
+ internalType: "address"
168
+ },
169
+ {
170
+ name: "token",
171
+ type: "address",
172
+ indexed: true,
173
+ internalType: "address"
174
+ },
175
+ {
176
+ name: "liquidator",
177
+ type: "address",
178
+ indexed: false,
179
+ internalType: "address"
180
+ },
181
+ {
182
+ name: "repaidDebt",
183
+ type: "uint256",
184
+ indexed: false,
185
+ internalType: "uint256"
186
+ },
187
+ {
188
+ name: "seizedCollateral",
189
+ type: "uint256",
190
+ indexed: false,
191
+ internalType: "uint256"
192
+ },
193
+ {
194
+ name: "fee",
195
+ type: "uint256",
196
+ indexed: false,
197
+ internalType: "uint256"
198
+ }
199
+ ],
200
+ anonymous: false
201
+ },
202
+ {
203
+ type: "error",
204
+ name: "LiquidatedLessThanNeededException",
205
+ inputs: []
206
+ },
207
+ {
208
+ type: "error",
209
+ name: "LiquidatedMoreThanNeededException",
210
+ inputs: []
211
+ },
212
+ {
213
+ type: "error",
214
+ name: "SeizedLessThanRequiredException",
215
+ inputs: []
216
+ },
217
+ {
218
+ type: "error",
219
+ name: "UnderlyingNotLiquidatableException",
220
+ inputs: []
221
+ }
222
+ ];
223
+ //#endregion
224
+ export { iPartialLiquidationBotV310Abi };
@@ -0,0 +1,2 @@
1
+ import { iPartialLiquidationBotV310Abi } from "./iPartialLiquidationBotV310.js";
2
+ export { iPartialLiquidationBotV310Abi };
@@ -0,0 +1,34 @@
1
+ import "../../onchain/constants/bot-permissions.js";
2
+ import "../../onchain/index.js";
3
+ //#region src/plugins/bots/config.ts
4
+ const PARTIAL_LIQUIDATION_BOT_CONFIGS = {
5
+ Mainnet: [{
6
+ minHealthFactor: 10300,
7
+ maxHealthFactor: 10700,
8
+ premiumScaleFactor: 1e4,
9
+ feeScaleFactor: 1e4
10
+ }],
11
+ Monad: [{
12
+ minHealthFactor: 10300,
13
+ maxHealthFactor: 10700,
14
+ premiumScaleFactor: 1e4,
15
+ feeScaleFactor: 1e4
16
+ }],
17
+ Plasma: [{
18
+ minHealthFactor: 10300,
19
+ maxHealthFactor: 10700,
20
+ premiumScaleFactor: 1e4,
21
+ feeScaleFactor: 1e4
22
+ }]
23
+ };
24
+ const PARTIAL_LIQUIDATION_BOT_SALT = "GEARBOX";
25
+ const PARTIAL_LIQUIDATION_BOT_DEPLOYER = "0xc93155E0a835Cf4E17a19463Fa67ed43c164d06a";
26
+ const LEGACY_MIGRATION_BOT = {
27
+ address: "0x286Fe53994f5668D56538Aa10eaa3Ac36f878e9C".toLowerCase(),
28
+ previewer: "0x6523B8c9daB92eea7944a79b4Dbb598c7934DCca".toLowerCase(),
29
+ version: 310,
30
+ baseType: "LEGACY_MIGRATION"
31
+ };
32
+ const PERMISSION_BY_TYPE = { LEGACY_MIGRATION: BigInt(65604) };
33
+ //#endregion
34
+ export { LEGACY_MIGRATION_BOT, PARTIAL_LIQUIDATION_BOT_CONFIGS, PARTIAL_LIQUIDATION_BOT_DEPLOYER, PARTIAL_LIQUIDATION_BOT_SALT, PERMISSION_BY_TYPE };
@@ -0,0 +1,35 @@
1
+ import { decodeAbiParameters } from "viem";
2
+ //#region src/plugins/bots/deserializePartialLiquidationBotParams.ts
3
+ function deserializePartialLiquidationBotParams(params) {
4
+ const [treasury, minHealthFactor, maxHealthFactor, premiumScaleFactor, feeScaleFactor] = decodeAbiParameters([
5
+ {
6
+ name: "treasury",
7
+ type: "address"
8
+ },
9
+ {
10
+ name: "minHealthFactor",
11
+ type: "uint16"
12
+ },
13
+ {
14
+ name: "maxHealthFactor",
15
+ type: "uint16"
16
+ },
17
+ {
18
+ name: "premiumScaleFactor",
19
+ type: "uint16"
20
+ },
21
+ {
22
+ name: "feeScaleFactor",
23
+ type: "uint16"
24
+ }
25
+ ], params.serializedParams);
26
+ return {
27
+ treasury,
28
+ minHealthFactor,
29
+ maxHealthFactor,
30
+ premiumScaleFactor,
31
+ feeScaleFactor
32
+ };
33
+ }
34
+ //#endregion
35
+ export { deserializePartialLiquidationBotParams as default };
@@ -0,0 +1,7 @@
1
+ import { iPartialLiquidationBotV310Abi } from "./abi/iPartialLiquidationBotV310.js";
2
+ import { LEGACY_MIGRATION_BOT, PARTIAL_LIQUIDATION_BOT_CONFIGS, PARTIAL_LIQUIDATION_BOT_DEPLOYER, PARTIAL_LIQUIDATION_BOT_SALT, PERMISSION_BY_TYPE } from "./config.js";
3
+ import "./abi/index.js";
4
+ import { BOT_PARAMS_ABI, BOT_PARTIAL_LIQUIDATION } from "./types.js";
5
+ import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
6
+ import { BotsPlugin } from "./BotsPlugin.js";
7
+ export { BOT_PARAMS_ABI, BOT_PARTIAL_LIQUIDATION, BotsPlugin, LEGACY_MIGRATION_BOT, PARTIAL_LIQUIDATION_BOT_CONFIGS, PARTIAL_LIQUIDATION_BOT_DEPLOYER, PARTIAL_LIQUIDATION_BOT_SALT, PERMISSION_BY_TYPE, PartialLiquidationBotV310Contract, iPartialLiquidationBotV310Abi };
@@ -0,0 +1 @@
1
+ {"type": "module","sideEffects":false}
@@ -0,0 +1,26 @@
1
+ //#region src/plugins/bots/types.ts
2
+ const BOT_PARTIAL_LIQUIDATION = "BOT::PARTIAL_LIQUIDATION";
3
+ const BOT_PARAMS_ABI = [
4
+ {
5
+ type: "address",
6
+ name: "treasury"
7
+ },
8
+ {
9
+ type: "uint16",
10
+ name: "minHealthFactor"
11
+ },
12
+ {
13
+ type: "uint16",
14
+ name: "maxHealthFactor"
15
+ },
16
+ {
17
+ type: "uint16",
18
+ name: "premiumScaleFactor"
19
+ },
20
+ {
21
+ type: "uint16",
22
+ name: "feeScaleFactor"
23
+ }
24
+ ];
25
+ //#endregion
26
+ export { BOT_PARAMS_ABI, BOT_PARTIAL_LIQUIDATION };
@@ -0,0 +1,18 @@
1
+ import { BasePlugin } from "../../onchain/plugins/BasePlugin.js";
2
+ import { IOnchainSDKPlugin } from "../../onchain/plugins/types.js";
3
+ import "../../onchain/index.js";
4
+ import { BotsPluginState, BotsPluginStateHuman, MigrationBotState } from "./types.js";
5
+ import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
6
+ //#region src/plugins/bots/BotsPlugin.d.ts
7
+ declare class BotsPlugin extends BasePlugin<BotsPluginState> implements IOnchainSDKPlugin<BotsPluginState> {
8
+ #private;
9
+ get loaded(): boolean;
10
+ get bots(): PartialLiquidationBotV310Contract[];
11
+ load(force?: boolean): Promise<BotsPluginState>;
12
+ stateHuman(raw?: boolean): BotsPluginStateHuman;
13
+ get state(): BotsPluginState;
14
+ hydrate(state: BotsPluginState): void;
15
+ static getMigrationBotData(chainId: number): MigrationBotState | undefined;
16
+ }
17
+ //#endregion
18
+ export { BotsPlugin };
@@ -0,0 +1,216 @@
1
+ import { OnchainSDK } from "../../onchain/OnchainSDK.js";
2
+ import { BaseContract } from "../../onchain/base/BaseContract.js";
3
+ import "../../onchain/index.js";
4
+ import { BotStateV310Human } from "./types.js";
5
+ import { Address, Hex } from "viem";
6
+ //#region src/plugins/bots/PartialLiquidationBotV310Contract.d.ts
7
+ declare const abi: readonly [{
8
+ readonly type: "function";
9
+ readonly name: "contractType";
10
+ readonly inputs: readonly [];
11
+ readonly outputs: readonly [{
12
+ readonly name: "";
13
+ readonly type: "bytes32";
14
+ readonly internalType: "bytes32";
15
+ }];
16
+ readonly stateMutability: "view";
17
+ }, {
18
+ readonly type: "function";
19
+ readonly name: "feeScaleFactor";
20
+ readonly inputs: readonly [];
21
+ readonly outputs: readonly [{
22
+ readonly name: "";
23
+ readonly type: "uint16";
24
+ readonly internalType: "uint16";
25
+ }];
26
+ readonly stateMutability: "view";
27
+ }, {
28
+ readonly type: "function";
29
+ readonly name: "maxHealthFactor";
30
+ readonly inputs: readonly [];
31
+ readonly outputs: readonly [{
32
+ readonly name: "";
33
+ readonly type: "uint16";
34
+ readonly internalType: "uint16";
35
+ }];
36
+ readonly stateMutability: "view";
37
+ }, {
38
+ readonly type: "function";
39
+ readonly name: "minHealthFactor";
40
+ readonly inputs: readonly [];
41
+ readonly outputs: readonly [{
42
+ readonly name: "";
43
+ readonly type: "uint16";
44
+ readonly internalType: "uint16";
45
+ }];
46
+ readonly stateMutability: "view";
47
+ }, {
48
+ readonly type: "function";
49
+ readonly name: "partiallyLiquidate";
50
+ readonly inputs: readonly [{
51
+ readonly name: "creditAccount";
52
+ readonly type: "address";
53
+ readonly internalType: "address";
54
+ }, {
55
+ readonly name: "token";
56
+ readonly type: "address";
57
+ readonly internalType: "address";
58
+ }, {
59
+ readonly name: "repaidAmount";
60
+ readonly type: "uint256";
61
+ readonly internalType: "uint256";
62
+ }, {
63
+ readonly name: "minSeizedAmount";
64
+ readonly type: "uint256";
65
+ readonly internalType: "uint256";
66
+ }, {
67
+ readonly name: "to";
68
+ readonly type: "address";
69
+ readonly internalType: "address";
70
+ }, {
71
+ readonly name: "priceUpdates";
72
+ readonly type: "tuple[]";
73
+ readonly internalType: "struct PriceUpdate[]";
74
+ readonly components: readonly [{
75
+ readonly name: "priceFeed";
76
+ readonly type: "address";
77
+ readonly internalType: "address";
78
+ }, {
79
+ readonly name: "data";
80
+ readonly type: "bytes";
81
+ readonly internalType: "bytes";
82
+ }];
83
+ }];
84
+ readonly outputs: readonly [{
85
+ readonly name: "seizedAmount";
86
+ readonly type: "uint256";
87
+ readonly internalType: "uint256";
88
+ }];
89
+ readonly stateMutability: "nonpayable";
90
+ }, {
91
+ readonly type: "function";
92
+ readonly name: "premiumScaleFactor";
93
+ readonly inputs: readonly [];
94
+ readonly outputs: readonly [{
95
+ readonly name: "";
96
+ readonly type: "uint16";
97
+ readonly internalType: "uint16";
98
+ }];
99
+ readonly stateMutability: "view";
100
+ }, {
101
+ readonly type: "function";
102
+ readonly name: "requiredPermissions";
103
+ readonly inputs: readonly [];
104
+ readonly outputs: readonly [{
105
+ readonly name: "";
106
+ readonly type: "uint192";
107
+ readonly internalType: "uint192";
108
+ }];
109
+ readonly stateMutability: "view";
110
+ }, {
111
+ readonly type: "function";
112
+ readonly name: "serialize";
113
+ readonly inputs: readonly [];
114
+ readonly outputs: readonly [{
115
+ readonly name: "serializedData";
116
+ readonly type: "bytes";
117
+ readonly internalType: "bytes";
118
+ }];
119
+ readonly stateMutability: "view";
120
+ }, {
121
+ readonly type: "function";
122
+ readonly name: "treasury";
123
+ readonly inputs: readonly [];
124
+ readonly outputs: readonly [{
125
+ readonly name: "";
126
+ readonly type: "address";
127
+ readonly internalType: "address";
128
+ }];
129
+ readonly stateMutability: "view";
130
+ }, {
131
+ readonly type: "function";
132
+ readonly name: "version";
133
+ readonly inputs: readonly [];
134
+ readonly outputs: readonly [{
135
+ readonly name: "";
136
+ readonly type: "uint256";
137
+ readonly internalType: "uint256";
138
+ }];
139
+ readonly stateMutability: "view";
140
+ }, {
141
+ readonly type: "event";
142
+ readonly name: "PartiallyLiquidate";
143
+ readonly inputs: readonly [{
144
+ readonly name: "creditManager";
145
+ readonly type: "address";
146
+ readonly indexed: true;
147
+ readonly internalType: "address";
148
+ }, {
149
+ readonly name: "creditAccount";
150
+ readonly type: "address";
151
+ readonly indexed: true;
152
+ readonly internalType: "address";
153
+ }, {
154
+ readonly name: "token";
155
+ readonly type: "address";
156
+ readonly indexed: true;
157
+ readonly internalType: "address";
158
+ }, {
159
+ readonly name: "liquidator";
160
+ readonly type: "address";
161
+ readonly indexed: false;
162
+ readonly internalType: "address";
163
+ }, {
164
+ readonly name: "repaidDebt";
165
+ readonly type: "uint256";
166
+ readonly indexed: false;
167
+ readonly internalType: "uint256";
168
+ }, {
169
+ readonly name: "seizedCollateral";
170
+ readonly type: "uint256";
171
+ readonly indexed: false;
172
+ readonly internalType: "uint256";
173
+ }, {
174
+ readonly name: "fee";
175
+ readonly type: "uint256";
176
+ readonly indexed: false;
177
+ readonly internalType: "uint256";
178
+ }];
179
+ readonly anonymous: false;
180
+ }, {
181
+ readonly type: "error";
182
+ readonly name: "LiquidatedLessThanNeededException";
183
+ readonly inputs: readonly [];
184
+ }, {
185
+ readonly type: "error";
186
+ readonly name: "LiquidatedMoreThanNeededException";
187
+ readonly inputs: readonly [];
188
+ }, {
189
+ readonly type: "error";
190
+ readonly name: "SeizedLessThanRequiredException";
191
+ readonly inputs: readonly [];
192
+ }, {
193
+ readonly type: "error";
194
+ readonly name: "UnderlyingNotLiquidatableException";
195
+ readonly inputs: readonly [];
196
+ }];
197
+ type abi = typeof abi;
198
+ interface PartialLiquidationBotV310Params {
199
+ addr: Address;
200
+ version: bigint;
201
+ contractType: string;
202
+ serializedParams: Hex;
203
+ }
204
+ declare class PartialLiquidationBotV310Contract extends BaseContract<abi> {
205
+ #private;
206
+ readonly treasury: Address;
207
+ readonly minHealthFactor: number;
208
+ readonly maxHealthFactor: number;
209
+ readonly premiumScaleFactor: number;
210
+ readonly feeScaleFactor: number;
211
+ constructor(sdk: OnchainSDK, args: PartialLiquidationBotV310Params);
212
+ stateHuman(raw?: boolean): BotStateV310Human;
213
+ get state(): PartialLiquidationBotV310Params;
214
+ }
215
+ //#endregion
216
+ export { PartialLiquidationBotV310Contract, PartialLiquidationBotV310Params };