@gearbox-protocol/sdk 8.24.2 → 8.24.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/plugins/zappers/ZappersPlugin.js +18 -8
- package/dist/cjs/sdk/core/BotListV3Contract.js +3 -1
- package/dist/esm/plugins/zappers/ZappersPlugin.js +18 -8
- package/dist/esm/sdk/core/BotListV3Contract.js +3 -1
- package/dist/types/plugins/zappers/ZappersPlugin.d.ts +1 -0
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ class ZappersPlugin extends import_sdk.BasePlugin {
|
|
|
28
28
|
#extraZappers;
|
|
29
29
|
constructor(extraZappers = [], loadOnAttach = false) {
|
|
30
30
|
super(loadOnAttach);
|
|
31
|
-
this.#extraZappers = extraZappers;
|
|
31
|
+
this.#extraZappers = this.#addExtraZappers(extraZappers);
|
|
32
32
|
}
|
|
33
33
|
async load(force) {
|
|
34
34
|
if (!force && this.loaded) {
|
|
@@ -65,17 +65,19 @@ class ZappersPlugin extends import_sdk.BasePlugin {
|
|
|
65
65
|
);
|
|
66
66
|
} else {
|
|
67
67
|
this.sdk.logger?.error(
|
|
68
|
-
`failed to load zapper for market configurator ${this.labelAddress(
|
|
68
|
+
`failed to load zapper for market configurator ${this.labelAddress(
|
|
69
|
+
marketConfigurator
|
|
70
|
+
)} and pool ${this.labelAddress(pool)}: ${error}`
|
|
69
71
|
);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
|
-
this.#addExtraZappers();
|
|
73
74
|
this.#loadZapperTokens();
|
|
74
75
|
return this.state;
|
|
75
76
|
}
|
|
76
|
-
#addExtraZappers() {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
#addExtraZappers(extraZappers) {
|
|
78
|
+
const zappers = new import_sdk.AddressMap();
|
|
79
|
+
for (const z of extraZappers) {
|
|
80
|
+
const existing = zappers?.get(z.pool);
|
|
79
81
|
if (existing) {
|
|
80
82
|
const hasZapper = existing.some(
|
|
81
83
|
(zz) => (0, import_sdk.hexEq)(zz.baseParams.addr, z.baseParams.addr)
|
|
@@ -84,9 +86,16 @@ class ZappersPlugin extends import_sdk.BasePlugin {
|
|
|
84
86
|
existing.push(z);
|
|
85
87
|
}
|
|
86
88
|
} else {
|
|
87
|
-
|
|
89
|
+
zappers?.upsert(z.pool, [z]);
|
|
88
90
|
}
|
|
89
91
|
}
|
|
92
|
+
return zappers;
|
|
93
|
+
}
|
|
94
|
+
get extraZappers() {
|
|
95
|
+
if (!this.#extraZappers) {
|
|
96
|
+
throw new Error("zappers plugin not attached");
|
|
97
|
+
}
|
|
98
|
+
return this.#extraZappers;
|
|
90
99
|
}
|
|
91
100
|
get zappers() {
|
|
92
101
|
if (!this.#zappers) {
|
|
@@ -119,7 +128,8 @@ class ZappersPlugin extends import_sdk.BasePlugin {
|
|
|
119
128
|
}
|
|
120
129
|
#loadZapperTokens() {
|
|
121
130
|
const zappersTokens = this.zappers.values().flatMap((l) => l.flatMap((z) => [z.tokenIn, z.tokenOut]));
|
|
122
|
-
|
|
131
|
+
const extraZappersTokens = this.extraZappers.values().flatMap((l) => l.flatMap((z) => [z.tokenIn, z.tokenOut]));
|
|
132
|
+
for (const t of [...zappersTokens, ...extraZappersTokens]) {
|
|
123
133
|
this.sdk.tokensMeta.upsert(t.addr, t);
|
|
124
134
|
this.sdk.provider.addressLabels.set(t.addr, t.symbol);
|
|
125
135
|
}
|
|
@@ -57,7 +57,9 @@ class BotListContract extends import_base.BaseContract {
|
|
|
57
57
|
fromBlock: this.#currentBlock,
|
|
58
58
|
toBlock
|
|
59
59
|
});
|
|
60
|
-
logs.forEach((e) =>
|
|
60
|
+
logs.forEach((e) => {
|
|
61
|
+
this.processLog(e);
|
|
62
|
+
});
|
|
61
63
|
this.#currentBlock = toBlock;
|
|
62
64
|
}
|
|
63
65
|
processLog(log) {
|
|
@@ -11,7 +11,7 @@ class ZappersPlugin extends BasePlugin {
|
|
|
11
11
|
#extraZappers;
|
|
12
12
|
constructor(extraZappers = [], loadOnAttach = false) {
|
|
13
13
|
super(loadOnAttach);
|
|
14
|
-
this.#extraZappers = extraZappers;
|
|
14
|
+
this.#extraZappers = this.#addExtraZappers(extraZappers);
|
|
15
15
|
}
|
|
16
16
|
async load(force) {
|
|
17
17
|
if (!force && this.loaded) {
|
|
@@ -48,17 +48,19 @@ class ZappersPlugin extends BasePlugin {
|
|
|
48
48
|
);
|
|
49
49
|
} else {
|
|
50
50
|
this.sdk.logger?.error(
|
|
51
|
-
`failed to load zapper for market configurator ${this.labelAddress(
|
|
51
|
+
`failed to load zapper for market configurator ${this.labelAddress(
|
|
52
|
+
marketConfigurator
|
|
53
|
+
)} and pool ${this.labelAddress(pool)}: ${error}`
|
|
52
54
|
);
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
this.#addExtraZappers();
|
|
56
57
|
this.#loadZapperTokens();
|
|
57
58
|
return this.state;
|
|
58
59
|
}
|
|
59
|
-
#addExtraZappers() {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
#addExtraZappers(extraZappers) {
|
|
61
|
+
const zappers = new AddressMap();
|
|
62
|
+
for (const z of extraZappers) {
|
|
63
|
+
const existing = zappers?.get(z.pool);
|
|
62
64
|
if (existing) {
|
|
63
65
|
const hasZapper = existing.some(
|
|
64
66
|
(zz) => hexEq(zz.baseParams.addr, z.baseParams.addr)
|
|
@@ -67,9 +69,16 @@ class ZappersPlugin extends BasePlugin {
|
|
|
67
69
|
existing.push(z);
|
|
68
70
|
}
|
|
69
71
|
} else {
|
|
70
|
-
|
|
72
|
+
zappers?.upsert(z.pool, [z]);
|
|
71
73
|
}
|
|
72
74
|
}
|
|
75
|
+
return zappers;
|
|
76
|
+
}
|
|
77
|
+
get extraZappers() {
|
|
78
|
+
if (!this.#extraZappers) {
|
|
79
|
+
throw new Error("zappers plugin not attached");
|
|
80
|
+
}
|
|
81
|
+
return this.#extraZappers;
|
|
73
82
|
}
|
|
74
83
|
get zappers() {
|
|
75
84
|
if (!this.#zappers) {
|
|
@@ -102,7 +111,8 @@ class ZappersPlugin extends BasePlugin {
|
|
|
102
111
|
}
|
|
103
112
|
#loadZapperTokens() {
|
|
104
113
|
const zappersTokens = this.zappers.values().flatMap((l) => l.flatMap((z) => [z.tokenIn, z.tokenOut]));
|
|
105
|
-
|
|
114
|
+
const extraZappersTokens = this.extraZappers.values().flatMap((l) => l.flatMap((z) => [z.tokenIn, z.tokenOut]));
|
|
115
|
+
for (const t of [...zappersTokens, ...extraZappersTokens]) {
|
|
106
116
|
this.sdk.tokensMeta.upsert(t.addr, t);
|
|
107
117
|
this.sdk.provider.addressLabels.set(t.addr, t.symbol);
|
|
108
118
|
}
|
|
@@ -9,6 +9,7 @@ export declare class ZappersPlugin extends BasePlugin<ZappersPluginState> implem
|
|
|
9
9
|
#private;
|
|
10
10
|
constructor(extraZappers?: ZapperDataFull[], loadOnAttach?: boolean);
|
|
11
11
|
load(force?: boolean): Promise<ZappersPluginState>;
|
|
12
|
+
get extraZappers(): AddressMap<ZapperDataFull[]>;
|
|
12
13
|
get zappers(): AddressMap<ZapperDataFull[]>;
|
|
13
14
|
get loaded(): boolean;
|
|
14
15
|
stateHuman(_?: boolean): ZapperStateHuman[];
|