@steerprotocol/data-connector-loader 3.1.0 → 3.2.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/README.md +30 -1
- package/lib/bundle/bundleBase.d.ts +10 -5
- package/lib/bundle/bundleBase.js +65 -11
- package/lib/bundle/bundleDataConnector.d.ts +11 -4
- package/lib/bundle/bundleDataConnector.js +49 -13
- package/lib/esm/bundle/bundleBase.d.ts +10 -5
- package/lib/esm/bundle/bundleBase.js +60 -11
- package/lib/esm/bundle/bundleDataConnector.d.ts +11 -4
- package/lib/esm/bundle/bundleDataConnector.js +46 -11
- package/lib/esm/execution/executionApp.d.ts +52 -7
- package/lib/esm/execution/executionApp.js +557 -113
- package/lib/esm/execution/executionBase.d.ts +4 -4
- package/lib/esm/execution/executionBase.js +11 -12
- package/lib/esm/execution/executionDataConnector.d.ts +4 -2
- package/lib/esm/execution/executionDataConnector.js +56 -25
- package/lib/esm/index.d.ts +6 -4
- package/lib/esm/index.js +3 -4
- package/lib/esm/types.d.ts +17 -4
- package/lib/esm/utils/blockFinder.d.ts +1 -1
- package/lib/esm/utils/consts.js +43 -1
- package/lib/esm/utils/pluginManager.d.ts +1 -1
- package/lib/esm/utils/providerUtils.d.ts +4 -0
- package/lib/esm/utils/providerUtils.js +37 -0
- package/lib/esm/utils/replace-old-subgraphs.d.ts +23 -0
- package/lib/esm/utils/replace-old-subgraphs.js +123 -0
- package/lib/esm/utils/utils.d.ts +7 -6
- package/lib/esm/utils/utils.js +8 -9
- package/lib/execution/executionApp.d.ts +52 -7
- package/lib/execution/executionApp.js +556 -117
- package/lib/execution/executionBase.d.ts +4 -4
- package/lib/execution/executionBase.js +11 -12
- package/lib/execution/executionDataConnector.d.ts +4 -2
- package/lib/execution/executionDataConnector.js +61 -29
- package/lib/index.d.ts +6 -4
- package/lib/index.js +6 -21
- package/lib/types.d.ts +17 -4
- package/lib/utils/blockFinder.d.ts +1 -1
- package/lib/utils/consts.js +43 -1
- package/lib/utils/pluginManager.d.ts +1 -1
- package/lib/utils/providerUtils.d.ts +4 -0
- package/lib/utils/providerUtils.js +43 -0
- package/lib/utils/replace-old-subgraphs.d.ts +23 -0
- package/lib/utils/replace-old-subgraphs.js +129 -0
- package/lib/utils/utils.d.ts +7 -6
- package/lib/utils/utils.js +15 -16
- package/package.json +13 -4
|
@@ -10,12 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ExecutionApp = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
class ExecutionApp extends
|
|
17
|
-
constructor(
|
|
18
|
-
|
|
13
|
+
const bundleDataConnector_js_1 = require("../bundle/bundleDataConnector.js");
|
|
14
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
15
|
+
const executionBase_js_1 = require("./executionBase.js");
|
|
16
|
+
class ExecutionApp extends executionBase_js_1.ExecutionBase {
|
|
17
|
+
constructor(config) {
|
|
18
|
+
var _a;
|
|
19
|
+
super((_a = config.maxRetries) !== null && _a !== void 0 ? _a : 3);
|
|
19
20
|
this.getSlot0 = (pool, currentExecutionContext, provider, rpc) => __awaiter(this, void 0, void 0, function* () {
|
|
20
21
|
const slot0Abi = [
|
|
21
22
|
{
|
|
@@ -42,12 +43,12 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
42
43
|
type: 'function',
|
|
43
44
|
},
|
|
44
45
|
];
|
|
45
|
-
const slot0 = yield (0,
|
|
46
|
+
const slot0 = yield (0, utils_js_1.readContract)({
|
|
46
47
|
address: pool,
|
|
47
48
|
abi: slot0Abi,
|
|
48
49
|
currentExecutionContext,
|
|
49
50
|
functionName: 'slot0',
|
|
50
|
-
provider
|
|
51
|
+
provider,
|
|
51
52
|
rpc,
|
|
52
53
|
chainId: this.chainId,
|
|
53
54
|
});
|
|
@@ -61,110 +62,392 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
61
62
|
unlocked: slot0[6],
|
|
62
63
|
};
|
|
63
64
|
});
|
|
64
|
-
this.
|
|
65
|
+
this.getSlot0Aerodrome = (pool, currentExecutionContext, provider, rpc) => __awaiter(this, void 0, void 0, function* () {
|
|
65
66
|
const slot0Abi = [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
type: 'bool',
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
stateMutability: 'view',
|
|
108
|
-
type: 'function',
|
|
109
|
-
}
|
|
110
|
-
: {
|
|
111
|
-
inputs: [],
|
|
112
|
-
name: 'globalState',
|
|
113
|
-
outputs: [
|
|
114
|
-
{
|
|
115
|
-
internalType: 'uint160',
|
|
116
|
-
name: 'price',
|
|
117
|
-
type: 'uint160',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
internalType: 'int24',
|
|
121
|
-
name: 'tick',
|
|
122
|
-
type: 'int24',
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
internalType: 'uint16',
|
|
126
|
-
name: 'feeZto',
|
|
127
|
-
type: 'uint16',
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
internalType: 'uint16',
|
|
131
|
-
name: 'feeOtz',
|
|
132
|
-
type: 'uint16',
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
internalType: 'uint16',
|
|
136
|
-
name: 'timepointIndex',
|
|
137
|
-
type: 'uint16',
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
internalType: 'uint8',
|
|
141
|
-
name: 'communityFeeToken0',
|
|
142
|
-
type: 'uint8',
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
internalType: 'uint8',
|
|
146
|
-
name: 'communityFeeToken1',
|
|
147
|
-
type: 'uint8',
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
internalType: 'bool',
|
|
151
|
-
name: 'unlocked',
|
|
152
|
-
type: 'bool',
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
stateMutability: 'view',
|
|
156
|
-
type: 'function',
|
|
157
|
-
},
|
|
67
|
+
{
|
|
68
|
+
inputs: [],
|
|
69
|
+
name: 'slot0',
|
|
70
|
+
outputs: [
|
|
71
|
+
{
|
|
72
|
+
internalType: 'uint160',
|
|
73
|
+
name: 'sqrtPriceX96',
|
|
74
|
+
type: 'uint160',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
internalType: 'int24',
|
|
78
|
+
name: 'tick',
|
|
79
|
+
type: 'int24',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
internalType: 'uint16',
|
|
83
|
+
name: 'observationIndex',
|
|
84
|
+
type: 'uint16',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
internalType: 'uint16',
|
|
88
|
+
name: 'observationCardinality',
|
|
89
|
+
type: 'uint16',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
internalType: 'uint16',
|
|
93
|
+
name: 'observationCardinalityNext',
|
|
94
|
+
type: 'uint16',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
internalType: 'bool',
|
|
98
|
+
name: 'unlocked',
|
|
99
|
+
type: 'bool',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
stateMutability: 'view',
|
|
103
|
+
type: 'function',
|
|
104
|
+
},
|
|
158
105
|
];
|
|
159
|
-
const slot0 = yield (0,
|
|
106
|
+
const slot0 = yield (0, utils_js_1.readContract)({
|
|
107
|
+
address: pool,
|
|
108
|
+
abi: slot0Abi,
|
|
109
|
+
currentExecutionContext,
|
|
110
|
+
functionName: 'slot0',
|
|
111
|
+
provider,
|
|
112
|
+
rpc,
|
|
113
|
+
chainId: this.chainId,
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
sqrtPriceX96: slot0[0],
|
|
117
|
+
tick: slot0[1],
|
|
118
|
+
observationIndex: slot0[2],
|
|
119
|
+
observationCardinality: slot0[3],
|
|
120
|
+
observationCardinalityNext: slot0[4],
|
|
121
|
+
unlocked: slot0[5],
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
this.getGlobalStateAbi = () => {
|
|
125
|
+
if (this.isAlgebraIntegralPool) {
|
|
126
|
+
return {
|
|
127
|
+
inputs: [],
|
|
128
|
+
name: 'globalState',
|
|
129
|
+
outputs: [
|
|
130
|
+
{
|
|
131
|
+
internalType: 'uint160',
|
|
132
|
+
name: 'price',
|
|
133
|
+
type: 'uint160',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
internalType: 'int24',
|
|
137
|
+
name: 'tick',
|
|
138
|
+
type: 'int24',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
internalType: 'uint16',
|
|
142
|
+
name: 'lastFee',
|
|
143
|
+
type: 'uint16',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
internalType: 'uint8',
|
|
147
|
+
name: 'pluginConfig',
|
|
148
|
+
type: 'uint8',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
internalType: 'uint16',
|
|
152
|
+
name: 'communityFee',
|
|
153
|
+
type: 'uint16',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
internalType: 'bool',
|
|
157
|
+
name: 'unlocked',
|
|
158
|
+
type: 'bool',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
stateMutability: 'view',
|
|
162
|
+
type: 'function',
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
else if (this.isDirectionalPool) {
|
|
166
|
+
return {
|
|
167
|
+
inputs: [],
|
|
168
|
+
name: 'globalState',
|
|
169
|
+
outputs: [
|
|
170
|
+
{
|
|
171
|
+
internalType: 'uint160',
|
|
172
|
+
name: 'price',
|
|
173
|
+
type: 'uint160',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
internalType: 'int24',
|
|
177
|
+
name: 'tick',
|
|
178
|
+
type: 'int24',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
internalType: 'uint16',
|
|
182
|
+
name: 'feeZto',
|
|
183
|
+
type: 'uint16',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
internalType: 'uint16',
|
|
187
|
+
name: 'feeOtz',
|
|
188
|
+
type: 'uint16',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
internalType: 'uint16',
|
|
192
|
+
name: 'timepointIndex',
|
|
193
|
+
type: 'uint16',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
internalType: 'uint8',
|
|
197
|
+
name: 'communityFeeToken0',
|
|
198
|
+
type: 'uint8',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
internalType: 'uint8',
|
|
202
|
+
name: 'communityFeeToken1',
|
|
203
|
+
type: 'uint8',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
internalType: 'bool',
|
|
207
|
+
name: 'unlocked',
|
|
208
|
+
type: 'bool',
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
stateMutability: 'view',
|
|
212
|
+
type: 'function',
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
else if (this.isPoolSharkPool) {
|
|
216
|
+
return {
|
|
217
|
+
inputs: [],
|
|
218
|
+
name: 'globalState',
|
|
219
|
+
outputs: [
|
|
220
|
+
{
|
|
221
|
+
components: [
|
|
222
|
+
{
|
|
223
|
+
components: [
|
|
224
|
+
{
|
|
225
|
+
internalType: 'uint16',
|
|
226
|
+
name: 'index',
|
|
227
|
+
type: 'uint16',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
internalType: 'uint16',
|
|
231
|
+
name: 'count',
|
|
232
|
+
type: 'uint16',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
internalType: 'uint16',
|
|
236
|
+
name: 'countMax',
|
|
237
|
+
type: 'uint16',
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
internalType: 'struct PoolsharkStructs.SampleState',
|
|
241
|
+
name: 'samples',
|
|
242
|
+
type: 'tuple',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
internalType: 'uint200',
|
|
246
|
+
name: 'feeGrowthGlobal0',
|
|
247
|
+
type: 'uint200',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
internalType: 'uint200',
|
|
251
|
+
name: 'feeGrowthGlobal1',
|
|
252
|
+
type: 'uint200',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
internalType: 'uint160',
|
|
256
|
+
name: 'secondsPerLiquidityAccum',
|
|
257
|
+
type: 'uint160',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
internalType: 'uint160',
|
|
261
|
+
name: 'price',
|
|
262
|
+
type: 'uint160',
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
internalType: 'uint128',
|
|
266
|
+
name: 'liquidity',
|
|
267
|
+
type: 'uint128',
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
internalType: 'int56',
|
|
271
|
+
name: 'tickSecondsAccum',
|
|
272
|
+
type: 'int56',
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
internalType: 'int24',
|
|
276
|
+
name: 'tickAtPrice',
|
|
277
|
+
type: 'int24',
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
internalType: 'uint16',
|
|
281
|
+
name: 'protocolSwapFee0',
|
|
282
|
+
type: 'uint16',
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
internalType: 'uint16',
|
|
286
|
+
name: 'protocolSwapFee1',
|
|
287
|
+
type: 'uint16',
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
internalType: 'struct PoolsharkStructs.RangePoolState',
|
|
291
|
+
name: 'pool',
|
|
292
|
+
type: 'tuple',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
components: [
|
|
296
|
+
{
|
|
297
|
+
internalType: 'uint160',
|
|
298
|
+
name: 'price',
|
|
299
|
+
type: 'uint160',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
internalType: 'uint128',
|
|
303
|
+
name: 'liquidity',
|
|
304
|
+
type: 'uint128',
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
internalType: 'uint128',
|
|
308
|
+
name: 'protocolFees',
|
|
309
|
+
type: 'uint128',
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
internalType: 'uint16',
|
|
313
|
+
name: 'protocolFillFee',
|
|
314
|
+
type: 'uint16',
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
internalType: 'int24',
|
|
318
|
+
name: 'tickAtPrice',
|
|
319
|
+
type: 'int24',
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
internalType: 'struct PoolsharkStructs.LimitPoolState',
|
|
323
|
+
name: 'pool0',
|
|
324
|
+
type: 'tuple',
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
components: [
|
|
328
|
+
{
|
|
329
|
+
internalType: 'uint160',
|
|
330
|
+
name: 'price',
|
|
331
|
+
type: 'uint160',
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
internalType: 'uint128',
|
|
335
|
+
name: 'liquidity',
|
|
336
|
+
type: 'uint128',
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
internalType: 'uint128',
|
|
340
|
+
name: 'protocolFees',
|
|
341
|
+
type: 'uint128',
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
internalType: 'uint16',
|
|
345
|
+
name: 'protocolFillFee',
|
|
346
|
+
type: 'uint16',
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
internalType: 'int24',
|
|
350
|
+
name: 'tickAtPrice',
|
|
351
|
+
type: 'int24',
|
|
352
|
+
},
|
|
353
|
+
],
|
|
354
|
+
internalType: 'struct PoolsharkStructs.LimitPoolState',
|
|
355
|
+
name: 'pool1',
|
|
356
|
+
type: 'tuple',
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
internalType: 'uint128',
|
|
360
|
+
name: 'liquidityGlobal',
|
|
361
|
+
type: 'uint128',
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
internalType: 'uint32',
|
|
365
|
+
name: 'positionIdNext',
|
|
366
|
+
type: 'uint32',
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
internalType: 'uint32',
|
|
370
|
+
name: 'epoch',
|
|
371
|
+
type: 'uint32',
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
internalType: 'uint8',
|
|
375
|
+
name: 'unlocked',
|
|
376
|
+
type: 'uint8',
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
stateMutability: 'view',
|
|
380
|
+
type: 'function',
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
return {
|
|
385
|
+
inputs: [],
|
|
386
|
+
name: 'globalState',
|
|
387
|
+
outputs: [
|
|
388
|
+
{
|
|
389
|
+
internalType: 'uint160',
|
|
390
|
+
name: 'price',
|
|
391
|
+
type: 'uint160',
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
internalType: 'int24',
|
|
395
|
+
name: 'tick',
|
|
396
|
+
type: 'int24',
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
internalType: 'int24',
|
|
400
|
+
name: 'prevInitializedTick',
|
|
401
|
+
type: 'int24',
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
internalType: 'uint16',
|
|
405
|
+
name: 'fee',
|
|
406
|
+
type: 'uint16',
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
internalType: 'uint16',
|
|
410
|
+
name: 'timepointIndex',
|
|
411
|
+
type: 'uint16',
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
internalType: 'uint8',
|
|
415
|
+
name: 'communityFee',
|
|
416
|
+
type: 'uint8',
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
internalType: 'bool',
|
|
420
|
+
name: 'unlocked',
|
|
421
|
+
type: 'bool',
|
|
422
|
+
},
|
|
423
|
+
],
|
|
424
|
+
stateMutability: 'view',
|
|
425
|
+
type: 'function',
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
this.getGlobalState = (pool, currentExecutionContext, provider, rpc) => __awaiter(this, void 0, void 0, function* () {
|
|
430
|
+
const slot0Abi = [this.getGlobalStateAbi()];
|
|
431
|
+
const slot0 = yield (0, utils_js_1.readContract)({
|
|
160
432
|
address: pool,
|
|
161
433
|
abi: slot0Abi,
|
|
162
434
|
currentExecutionContext,
|
|
163
435
|
functionName: 'globalState',
|
|
164
|
-
provider
|
|
436
|
+
provider,
|
|
165
437
|
rpc,
|
|
166
438
|
chainId: this.chainId,
|
|
167
439
|
});
|
|
440
|
+
if (this.isPoolSharkPool) {
|
|
441
|
+
return {
|
|
442
|
+
price: slot0[0][5],
|
|
443
|
+
tick: slot0[0][7],
|
|
444
|
+
observationIndex: slot0[2],
|
|
445
|
+
observationCardinality: slot0[3],
|
|
446
|
+
observationCardinalityNext: slot0[4],
|
|
447
|
+
feeProtocol: slot0[5],
|
|
448
|
+
unlocked: slot0[6],
|
|
449
|
+
};
|
|
450
|
+
}
|
|
168
451
|
return this.isDirectionalPool
|
|
169
452
|
? {
|
|
170
453
|
price: slot0[0],
|
|
@@ -185,15 +468,21 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
185
468
|
unlocked: slot0[6],
|
|
186
469
|
};
|
|
187
470
|
});
|
|
188
|
-
this.
|
|
189
|
-
this.
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
471
|
+
this.vault = config.vault;
|
|
472
|
+
this.steerSubgraph = config.steerSubgraph;
|
|
473
|
+
this.chainId = config.chainId;
|
|
474
|
+
this.isAlgebraPool = config.poolType.isAlgebraPool;
|
|
475
|
+
this.isAlgebraIntegralPool = config.poolType.isAlgebraIntegralPool;
|
|
476
|
+
this.isDirectionalPool = config.poolType.isDirectionalPool;
|
|
477
|
+
this.isPoolSharkPool = config.poolType.isPoolSharkPool;
|
|
478
|
+
this.isAerodromePool = config.poolType.isAerodromePool;
|
|
479
|
+
this.subgraphStudioKey = config.apiKeys.subgraphStudioKey;
|
|
480
|
+
this.sentioApiKey = config.apiKeys.sentioApiKey;
|
|
481
|
+
this.config = config;
|
|
193
482
|
}
|
|
194
|
-
execute(_wasmFile, _vaultConfig, _data, _identity, _etherRpcConfig) {
|
|
483
|
+
execute(_wasmFile, _vaultConfig, _data, _identity, _etherRpcConfig, forceDeposit) {
|
|
195
484
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
-
const dataConnector = new
|
|
485
|
+
const dataConnector = new bundleDataConnector_js_1.DataConnector(_wasmFile, _vaultConfig, this.config, _identity, _etherRpcConfig);
|
|
197
486
|
yield dataConnector.loadSync();
|
|
198
487
|
const executionContext = yield this.getExecutionContext(dataConnector, JSON.parse(_vaultConfig));
|
|
199
488
|
let rpc = '';
|
|
@@ -201,12 +490,39 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
201
490
|
rpc = _etherRpcConfig[this.chainId.toString()].url;
|
|
202
491
|
}
|
|
203
492
|
const smartPoolExecutionContext = yield this.getSmartPoolExecutionContext(executionContext, dataConnector, JSON.parse(_vaultConfig), rpc);
|
|
204
|
-
dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), smartPoolExecutionContext));
|
|
493
|
+
dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), smartPoolExecutionContext), forceDeposit);
|
|
205
494
|
_data = _data.map((element) => JSON.stringify(element));
|
|
206
495
|
const result = yield dataConnector.executeBundle(_data);
|
|
207
496
|
return JSON.parse(result);
|
|
208
497
|
});
|
|
209
498
|
}
|
|
499
|
+
executeStabilityVault(_wasmFile, _vaultConfig, _data, _identity, _etherRpcConfig, forceDeposit) {
|
|
500
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
501
|
+
const dataConnector = new bundleDataConnector_js_1.DataConnector(_wasmFile, _vaultConfig, this.config, _identity, _etherRpcConfig);
|
|
502
|
+
yield dataConnector.loadSync();
|
|
503
|
+
const executionContext = yield this.getExecutionContext(dataConnector, JSON.parse(_vaultConfig));
|
|
504
|
+
const dynamicJobExecutionContext = {};
|
|
505
|
+
dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), dynamicJobExecutionContext), forceDeposit);
|
|
506
|
+
_data = _data.map((element) => JSON.stringify(element));
|
|
507
|
+
const result = yield dataConnector.executeDynamicJobBundle(_data);
|
|
508
|
+
return JSON.parse(result);
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
executeDynamicJobs(_wasmFile, _vaultConfig, _data, _job, _identity, _etherRpcConfig, forceDeposit) {
|
|
512
|
+
var _a;
|
|
513
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
514
|
+
const dataConnector = new bundleDataConnector_js_1.DataConnector(_wasmFile, _vaultConfig, this.config, _identity, _etherRpcConfig);
|
|
515
|
+
yield dataConnector.loadSync();
|
|
516
|
+
const executionContext = yield this.getExecutionContext(dataConnector, JSON.parse(_vaultConfig));
|
|
517
|
+
const dynamicJobExecutionContext = {
|
|
518
|
+
smartRewardsContractAddress: (_a = _job.targetAddresses) === null || _a === void 0 ? void 0 : _a[0],
|
|
519
|
+
};
|
|
520
|
+
dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), dynamicJobExecutionContext), forceDeposit);
|
|
521
|
+
_data = _data.map((element) => JSON.stringify(element));
|
|
522
|
+
const result = yield dataConnector.executeDynamicJobBundle(_data);
|
|
523
|
+
return JSON.parse(result);
|
|
524
|
+
});
|
|
525
|
+
}
|
|
210
526
|
getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig, rpc) {
|
|
211
527
|
var _a, _b, _c, _d, _e, _f;
|
|
212
528
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -214,6 +530,9 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
214
530
|
const request = {
|
|
215
531
|
method: 'POST',
|
|
216
532
|
url: this.steerSubgraph,
|
|
533
|
+
headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
534
|
+
? 'application/json'
|
|
535
|
+
: 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
|
|
217
536
|
data: {
|
|
218
537
|
query: `
|
|
219
538
|
{
|
|
@@ -231,11 +550,14 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
231
550
|
`,
|
|
232
551
|
},
|
|
233
552
|
};
|
|
234
|
-
const response = yield (0,
|
|
553
|
+
const response = yield (0, utils_js_1.fetchData)(request, 4);
|
|
235
554
|
this.log('Subgraph response vault positions :', response);
|
|
236
555
|
const requestSnapshot = {
|
|
237
556
|
method: 'POST',
|
|
238
557
|
url: this.steerSubgraph,
|
|
558
|
+
headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
559
|
+
? 'application/json'
|
|
560
|
+
: 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
|
|
239
561
|
data: {
|
|
240
562
|
query: `
|
|
241
563
|
{
|
|
@@ -250,7 +572,7 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
250
572
|
`,
|
|
251
573
|
},
|
|
252
574
|
};
|
|
253
|
-
const responseSnapshot = yield (0,
|
|
575
|
+
const responseSnapshot = yield (0, utils_js_1.fetchData)(requestSnapshot, 4);
|
|
254
576
|
this.log('Subgraph response current snapshot', responseSnapshot);
|
|
255
577
|
const positions = [];
|
|
256
578
|
if (((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.vaultPositions) && ((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.vaultPositions.length) > 0) {
|
|
@@ -282,23 +604,137 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
282
604
|
}
|
|
283
605
|
const poolAddress = yield this.getVaultPoolAddress();
|
|
284
606
|
const currentTick = yield this.getPoolCurrentTick(poolAddress, provider, currentExecutionContext, rpc);
|
|
607
|
+
const tickSpacing = yield this.getTickSpacing(poolAddress, provider, rpc, currentExecutionContext);
|
|
608
|
+
const totalAmounts = yield this.getTotalAmounts(this.vault, currentExecutionContext, provider, rpc);
|
|
609
|
+
// Handle both bigint and serialized bigint from centralized API
|
|
610
|
+
smartPoolExecutionContext.totalAmount0 = this.convertToString(totalAmounts.total0);
|
|
611
|
+
smartPoolExecutionContext.totalAmount1 = this.convertToString(totalAmounts.total1);
|
|
285
612
|
smartPoolExecutionContext.currentTick = currentTick;
|
|
613
|
+
smartPoolExecutionContext.tickSpacing = tickSpacing;
|
|
286
614
|
// "currentTick": 10,
|
|
287
615
|
return smartPoolExecutionContext;
|
|
288
616
|
});
|
|
289
617
|
}
|
|
290
618
|
getPoolCurrentTick(poolAddress, provider, currentExecutionContext, rpc) {
|
|
291
619
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
if (
|
|
293
|
-
const slot0 = yield this.
|
|
620
|
+
if (this.isAlgebraPool || this.isPoolSharkPool) {
|
|
621
|
+
const slot0 = yield this.getGlobalState(poolAddress, currentExecutionContext, provider, rpc);
|
|
622
|
+
return slot0.tick;
|
|
623
|
+
}
|
|
624
|
+
else if (this.isAerodromePool) {
|
|
625
|
+
const slot0 = yield this.getSlot0Aerodrome(poolAddress, currentExecutionContext, provider, rpc);
|
|
294
626
|
return slot0.tick;
|
|
295
627
|
}
|
|
296
628
|
else {
|
|
297
|
-
const slot0 = yield this.
|
|
629
|
+
const slot0 = yield this.getSlot0(poolAddress, currentExecutionContext, provider, rpc);
|
|
298
630
|
return slot0.tick;
|
|
299
631
|
}
|
|
300
632
|
});
|
|
301
633
|
}
|
|
634
|
+
getTickSpacing(poolAddress, provider, rpc, currentExecutionContext) {
|
|
635
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
636
|
+
const tickSpacingAbi = [
|
|
637
|
+
this.isPoolSharkPool
|
|
638
|
+
? {
|
|
639
|
+
inputs: [],
|
|
640
|
+
name: 'tickSpacing',
|
|
641
|
+
outputs: [
|
|
642
|
+
{
|
|
643
|
+
internalType: 'int24',
|
|
644
|
+
name: '',
|
|
645
|
+
type: 'int24',
|
|
646
|
+
},
|
|
647
|
+
],
|
|
648
|
+
stateMutability: 'view',
|
|
649
|
+
type: 'function',
|
|
650
|
+
}
|
|
651
|
+
: {
|
|
652
|
+
inputs: [],
|
|
653
|
+
name: 'tickSpacing',
|
|
654
|
+
outputs: [
|
|
655
|
+
{
|
|
656
|
+
internalType: 'int16',
|
|
657
|
+
name: '',
|
|
658
|
+
type: 'int16',
|
|
659
|
+
},
|
|
660
|
+
],
|
|
661
|
+
stateMutability: 'pure',
|
|
662
|
+
type: 'function',
|
|
663
|
+
},
|
|
664
|
+
];
|
|
665
|
+
const tickSpacing = yield (0, utils_js_1.readContract)({
|
|
666
|
+
address: poolAddress,
|
|
667
|
+
abi: tickSpacingAbi,
|
|
668
|
+
currentExecutionContext,
|
|
669
|
+
functionName: 'tickSpacing',
|
|
670
|
+
provider,
|
|
671
|
+
rpc,
|
|
672
|
+
chainId: this.chainId,
|
|
673
|
+
});
|
|
674
|
+
return tickSpacing;
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Converts a value to string, handling both native bigint and serialized bigint objects
|
|
679
|
+
* from the centralized API
|
|
680
|
+
*/
|
|
681
|
+
convertToString(value) {
|
|
682
|
+
if (typeof value === 'bigint') {
|
|
683
|
+
return value.toString();
|
|
684
|
+
}
|
|
685
|
+
if (typeof value === 'number') {
|
|
686
|
+
return value.toString();
|
|
687
|
+
}
|
|
688
|
+
if (typeof value === 'string') {
|
|
689
|
+
return value;
|
|
690
|
+
}
|
|
691
|
+
// Handle serialized bigint from centralized API (e.g., { type: 'BigNumber', hex: '0x...' })
|
|
692
|
+
if (value && typeof value === 'object') {
|
|
693
|
+
// If it's a BigNumber-like object with hex property
|
|
694
|
+
if (value.hex !== undefined) {
|
|
695
|
+
return BigInt(value.hex).toString();
|
|
696
|
+
}
|
|
697
|
+
// If it has a _hex property (ethers v5 BigNumber)
|
|
698
|
+
if (value._hex !== undefined) {
|
|
699
|
+
return BigInt(value._hex).toString();
|
|
700
|
+
}
|
|
701
|
+
// If it has toString method, try using it
|
|
702
|
+
if (typeof value.toString === 'function' && value.toString() !== '[object Object]') {
|
|
703
|
+
return value.toString();
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
// Fallback: convert to string (may result in '[object Object]' if not handled above)
|
|
707
|
+
return String(value);
|
|
708
|
+
}
|
|
709
|
+
getTotalAmounts(vaultAddress, currentExecutionContext, provider, rpc) {
|
|
710
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
711
|
+
const getTotalAmountsABI = [
|
|
712
|
+
{
|
|
713
|
+
inputs: [],
|
|
714
|
+
name: 'getTotalAmounts',
|
|
715
|
+
outputs: [
|
|
716
|
+
{ internalType: 'uint256', name: 'total0', type: 'uint256' },
|
|
717
|
+
{ internalType: 'uint256', name: 'total1', type: 'uint256' },
|
|
718
|
+
],
|
|
719
|
+
stateMutability: 'view',
|
|
720
|
+
type: 'function',
|
|
721
|
+
},
|
|
722
|
+
];
|
|
723
|
+
const totalAmounts = yield (0, utils_js_1.readContract)({
|
|
724
|
+
address: vaultAddress,
|
|
725
|
+
abi: getTotalAmountsABI,
|
|
726
|
+
currentExecutionContext,
|
|
727
|
+
functionName: 'getTotalAmounts',
|
|
728
|
+
provider,
|
|
729
|
+
rpc,
|
|
730
|
+
chainId: this.chainId,
|
|
731
|
+
});
|
|
732
|
+
return {
|
|
733
|
+
total0: totalAmounts[0],
|
|
734
|
+
total1: totalAmounts[1],
|
|
735
|
+
};
|
|
736
|
+
});
|
|
737
|
+
}
|
|
302
738
|
getVaultPoolAddress() {
|
|
303
739
|
return __awaiter(this, void 0, void 0, function* () {
|
|
304
740
|
const requestSnapshot = {
|
|
@@ -314,8 +750,11 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
314
750
|
}
|
|
315
751
|
`,
|
|
316
752
|
},
|
|
753
|
+
headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
754
|
+
? 'application/json'
|
|
755
|
+
: 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
|
|
317
756
|
};
|
|
318
|
-
const response = yield (0,
|
|
757
|
+
const response = yield (0, utils_js_1.fetchData)(requestSnapshot, 4);
|
|
319
758
|
return response.data.vault.pool;
|
|
320
759
|
});
|
|
321
760
|
}
|