@gearbox-protocol/sdk 7.1.0 → 7.2.0
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/dev/AccountsCounterPlugin.js +101 -0
- package/dist/cjs/dev/index.js +2 -0
- package/dist/esm/dev/AccountsCounterPlugin.js +85 -0
- package/dist/esm/dev/index.js +1 -0
- package/dist/types/dev/AccountsCounterPlugin.d.ts +17 -0
- package/dist/types/dev/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
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 AccountsCounterPlugin_exports = {};
|
|
20
|
+
__export(AccountsCounterPlugin_exports, {
|
|
21
|
+
AccountsCounterPlugin: () => AccountsCounterPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(AccountsCounterPlugin_exports);
|
|
24
|
+
var import_compressors = require("../abi/compressors.js");
|
|
25
|
+
var import_sdk = require("../sdk/index.js");
|
|
26
|
+
class AccountsCounterPlugin extends import_sdk.SDKConstruct {
|
|
27
|
+
#accounts = new import_sdk.AddressMap();
|
|
28
|
+
version = 1;
|
|
29
|
+
async attach() {
|
|
30
|
+
await this.#load();
|
|
31
|
+
}
|
|
32
|
+
async syncState() {
|
|
33
|
+
await this.#load();
|
|
34
|
+
}
|
|
35
|
+
async #load() {
|
|
36
|
+
const [compressor] = this.sdk.addressProvider.mustGetLatest(
|
|
37
|
+
import_sdk.AP_CREDIT_ACCOUNT_COMPRESSOR,
|
|
38
|
+
import_sdk.VERSION_RANGE_310
|
|
39
|
+
);
|
|
40
|
+
const cms = this.sdk.marketRegister.creditManagers;
|
|
41
|
+
const count = await this.sdk.provider.publicClient.multicall({
|
|
42
|
+
contracts: cms.flatMap(
|
|
43
|
+
(cm) => [
|
|
44
|
+
{
|
|
45
|
+
abi: import_compressors.iCreditAccountCompressorAbi,
|
|
46
|
+
address: compressor,
|
|
47
|
+
functionName: "countCreditAccounts",
|
|
48
|
+
args: [
|
|
49
|
+
cm.creditManager.address,
|
|
50
|
+
{
|
|
51
|
+
owner: import_sdk.ADDRESS_0X0,
|
|
52
|
+
includeZeroDebt: false,
|
|
53
|
+
maxHealthFactor: import_sdk.MAX_UINT256,
|
|
54
|
+
minHealthFactor: 0n,
|
|
55
|
+
reverting: false
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
abi: import_compressors.iCreditAccountCompressorAbi,
|
|
61
|
+
address: compressor,
|
|
62
|
+
functionName: "countCreditAccounts",
|
|
63
|
+
args: [
|
|
64
|
+
cm.creditManager.address,
|
|
65
|
+
{
|
|
66
|
+
owner: import_sdk.ADDRESS_0X0,
|
|
67
|
+
includeZeroDebt: false,
|
|
68
|
+
maxHealthFactor: import_sdk.MAX_UINT256,
|
|
69
|
+
minHealthFactor: 0n,
|
|
70
|
+
reverting: true
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
),
|
|
76
|
+
allowFailure: false
|
|
77
|
+
});
|
|
78
|
+
this.#accounts.clear();
|
|
79
|
+
for (let i = 0; i < cms.length; i++) {
|
|
80
|
+
const cm = cms[i];
|
|
81
|
+
const [reverting, nonReverting] = [count[2 * i], count[2 * i + 1]];
|
|
82
|
+
this.#accounts.upsert(cm.creditManager.address, reverting + nonReverting);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
get state() {
|
|
86
|
+
return {
|
|
87
|
+
version: this.version,
|
|
88
|
+
accounts: this.#accounts.asRecord()
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
hydrate(state) {
|
|
92
|
+
this.#accounts.clear();
|
|
93
|
+
for (const [addr, count] of import_sdk.TypedObjectUtils.entries(state.accounts)) {
|
|
94
|
+
this.#accounts.upsert(addr, count);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
AccountsCounterPlugin
|
|
101
|
+
});
|
package/dist/cjs/dev/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var dev_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(dev_exports);
|
|
18
18
|
__reExport(dev_exports, require("./AccountOpener.js"), module.exports);
|
|
19
|
+
__reExport(dev_exports, require("./AccountsCounterPlugin.js"), module.exports);
|
|
19
20
|
__reExport(dev_exports, require("./calcLiquidatableLTs.js"), module.exports);
|
|
20
21
|
__reExport(dev_exports, require("./create2.js"), module.exports);
|
|
21
22
|
__reExport(dev_exports, require("./createAnvilClient.js"), module.exports);
|
|
@@ -26,6 +27,7 @@ __reExport(dev_exports, require("./migrateFaucet.js"), module.exports);
|
|
|
26
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
28
|
0 && (module.exports = {
|
|
28
29
|
...require("./AccountOpener.js"),
|
|
30
|
+
...require("./AccountsCounterPlugin.js"),
|
|
29
31
|
...require("./calcLiquidatableLTs.js"),
|
|
30
32
|
...require("./create2.js"),
|
|
31
33
|
...require("./createAnvilClient.js"),
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { iCreditAccountCompressorAbi } from "../abi/compressors.js";
|
|
2
|
+
import {
|
|
3
|
+
ADDRESS_0X0,
|
|
4
|
+
AddressMap,
|
|
5
|
+
AP_CREDIT_ACCOUNT_COMPRESSOR,
|
|
6
|
+
MAX_UINT256,
|
|
7
|
+
SDKConstruct,
|
|
8
|
+
TypedObjectUtils,
|
|
9
|
+
VERSION_RANGE_310
|
|
10
|
+
} from "../sdk/index.js";
|
|
11
|
+
class AccountsCounterPlugin extends SDKConstruct {
|
|
12
|
+
#accounts = new AddressMap();
|
|
13
|
+
version = 1;
|
|
14
|
+
async attach() {
|
|
15
|
+
await this.#load();
|
|
16
|
+
}
|
|
17
|
+
async syncState() {
|
|
18
|
+
await this.#load();
|
|
19
|
+
}
|
|
20
|
+
async #load() {
|
|
21
|
+
const [compressor] = this.sdk.addressProvider.mustGetLatest(
|
|
22
|
+
AP_CREDIT_ACCOUNT_COMPRESSOR,
|
|
23
|
+
VERSION_RANGE_310
|
|
24
|
+
);
|
|
25
|
+
const cms = this.sdk.marketRegister.creditManagers;
|
|
26
|
+
const count = await this.sdk.provider.publicClient.multicall({
|
|
27
|
+
contracts: cms.flatMap(
|
|
28
|
+
(cm) => [
|
|
29
|
+
{
|
|
30
|
+
abi: iCreditAccountCompressorAbi,
|
|
31
|
+
address: compressor,
|
|
32
|
+
functionName: "countCreditAccounts",
|
|
33
|
+
args: [
|
|
34
|
+
cm.creditManager.address,
|
|
35
|
+
{
|
|
36
|
+
owner: ADDRESS_0X0,
|
|
37
|
+
includeZeroDebt: false,
|
|
38
|
+
maxHealthFactor: MAX_UINT256,
|
|
39
|
+
minHealthFactor: 0n,
|
|
40
|
+
reverting: false
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
abi: iCreditAccountCompressorAbi,
|
|
46
|
+
address: compressor,
|
|
47
|
+
functionName: "countCreditAccounts",
|
|
48
|
+
args: [
|
|
49
|
+
cm.creditManager.address,
|
|
50
|
+
{
|
|
51
|
+
owner: ADDRESS_0X0,
|
|
52
|
+
includeZeroDebt: false,
|
|
53
|
+
maxHealthFactor: MAX_UINT256,
|
|
54
|
+
minHealthFactor: 0n,
|
|
55
|
+
reverting: true
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
),
|
|
61
|
+
allowFailure: false
|
|
62
|
+
});
|
|
63
|
+
this.#accounts.clear();
|
|
64
|
+
for (let i = 0; i < cms.length; i++) {
|
|
65
|
+
const cm = cms[i];
|
|
66
|
+
const [reverting, nonReverting] = [count[2 * i], count[2 * i + 1]];
|
|
67
|
+
this.#accounts.upsert(cm.creditManager.address, reverting + nonReverting);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
get state() {
|
|
71
|
+
return {
|
|
72
|
+
version: this.version,
|
|
73
|
+
accounts: this.#accounts.asRecord()
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
hydrate(state) {
|
|
77
|
+
this.#accounts.clear();
|
|
78
|
+
for (const [addr, count] of TypedObjectUtils.entries(state.accounts)) {
|
|
79
|
+
this.#accounts.upsert(addr, count);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
AccountsCounterPlugin
|
|
85
|
+
};
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { IGearboxSDKPlugin, IPluginState } from "../sdk/index.js";
|
|
3
|
+
import { SDKConstruct } from "../sdk/index.js";
|
|
4
|
+
export interface AccountsCounterPluginState extends IPluginState {
|
|
5
|
+
/**
|
|
6
|
+
* Mapping of credit manager addresses to the number of accounts
|
|
7
|
+
*/
|
|
8
|
+
accounts: Record<Address, bigint>;
|
|
9
|
+
}
|
|
10
|
+
export declare class AccountsCounterPlugin extends SDKConstruct implements IGearboxSDKPlugin<AccountsCounterPluginState> {
|
|
11
|
+
#private;
|
|
12
|
+
readonly version = 1;
|
|
13
|
+
attach(): Promise<void>;
|
|
14
|
+
syncState(): Promise<void>;
|
|
15
|
+
get state(): AccountsCounterPluginState;
|
|
16
|
+
hydrate(state: AccountsCounterPluginState): void;
|
|
17
|
+
}
|