@gearbox-protocol/sdk 8.24.1 → 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/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +3 -0
- package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +3 -0
- package/dist/esm/plugins/zappers/ZappersPlugin.js +18 -8
- package/dist/esm/sdk/core/BotListV3Contract.js +3 -1
- package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +3 -0
- package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +3 -0
- 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) {
|
|
@@ -70,6 +70,9 @@ class PythUpdater extends import_base.SDKConstruct {
|
|
|
70
70
|
const ts = opts.historicTimestamp;
|
|
71
71
|
if (ts) {
|
|
72
72
|
this.#historicalTimestamp = ts === true ? Number(this.sdk.timestamp) : ts;
|
|
73
|
+
this.#logger?.debug(
|
|
74
|
+
`using historical timestamp ${this.#historicalTimestamp}`
|
|
75
|
+
);
|
|
73
76
|
}
|
|
74
77
|
this.#cache = new import_PriceUpdatesCache.PriceUpdatesCache({
|
|
75
78
|
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
@@ -76,6 +76,9 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
76
76
|
if (ts) {
|
|
77
77
|
ts = ts === true ? Number(this.sdk.timestamp) * 1e3 : ts;
|
|
78
78
|
this.#historicalTimestampMs = 6e4 * Math.floor(ts / 6e4);
|
|
79
|
+
this.#logger?.debug(
|
|
80
|
+
`using historical timestamp ${this.#historicalTimestampMs}`
|
|
81
|
+
);
|
|
79
82
|
}
|
|
80
83
|
this.#cache = new import_PriceUpdatesCache.PriceUpdatesCache({
|
|
81
84
|
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
@@ -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
|
}
|
|
@@ -50,6 +50,9 @@ class PythUpdater extends SDKConstruct {
|
|
|
50
50
|
const ts = opts.historicTimestamp;
|
|
51
51
|
if (ts) {
|
|
52
52
|
this.#historicalTimestamp = ts === true ? Number(this.sdk.timestamp) : ts;
|
|
53
|
+
this.#logger?.debug(
|
|
54
|
+
`using historical timestamp ${this.#historicalTimestamp}`
|
|
55
|
+
);
|
|
53
56
|
}
|
|
54
57
|
this.#cache = new PriceUpdatesCache({
|
|
55
58
|
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
@@ -52,6 +52,9 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
52
52
|
if (ts) {
|
|
53
53
|
ts = ts === true ? Number(this.sdk.timestamp) * 1e3 : ts;
|
|
54
54
|
this.#historicalTimestampMs = 6e4 * Math.floor(ts / 6e4);
|
|
55
|
+
this.#logger?.debug(
|
|
56
|
+
`using historical timestamp ${this.#historicalTimestampMs}`
|
|
57
|
+
);
|
|
55
58
|
}
|
|
56
59
|
this.#cache = new PriceUpdatesCache({
|
|
57
60
|
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
@@ -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[];
|