@steerprotocol/data-connector-loader 3.1.1 → 3.2.2
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 +21 -1
- package/lib/bundle/bundleBase.d.ts +10 -5
- package/lib/bundle/bundleBase.js +89 -10
- package/lib/bundle/bundleDataConnector.d.ts +5 -4
- package/lib/bundle/bundleDataConnector.js +9 -11
- package/lib/esm/bundle/bundleBase.d.ts +10 -5
- package/lib/esm/bundle/bundleBase.js +84 -10
- package/lib/esm/bundle/bundleDataConnector.d.ts +5 -4
- package/lib/esm/bundle/bundleDataConnector.js +6 -8
- package/lib/esm/execution/executionApp.d.ts +52 -7
- package/lib/esm/execution/executionApp.js +561 -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/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 +559 -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/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 +11 -3
|
@@ -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,42 @@ 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
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
513
|
+
const dataConnector = new bundleDataConnector_js_1.DataConnector(_wasmFile, _vaultConfig, this.config, _identity, _etherRpcConfig);
|
|
514
|
+
yield dataConnector.loadSync();
|
|
515
|
+
const executionContext = yield this.getExecutionContext(dataConnector, JSON.parse(_vaultConfig));
|
|
516
|
+
const smartRewardsContractAddress = _job.targetAddresses[0];
|
|
517
|
+
if (!smartRewardsContractAddress) {
|
|
518
|
+
throw new Error('Dynamic job must include at least one target address');
|
|
519
|
+
}
|
|
520
|
+
const dynamicJobExecutionContext = {
|
|
521
|
+
smartRewardsContractAddress,
|
|
522
|
+
};
|
|
523
|
+
dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), dynamicJobExecutionContext), forceDeposit);
|
|
524
|
+
_data = _data.map((element) => JSON.stringify(element));
|
|
525
|
+
const result = yield dataConnector.executeDynamicJobBundle(_data);
|
|
526
|
+
return JSON.parse(result);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
210
529
|
getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig, rpc) {
|
|
211
530
|
var _a, _b, _c, _d, _e, _f;
|
|
212
531
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -214,6 +533,9 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
214
533
|
const request = {
|
|
215
534
|
method: 'POST',
|
|
216
535
|
url: this.steerSubgraph,
|
|
536
|
+
headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
537
|
+
? 'application/json'
|
|
538
|
+
: 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
|
|
217
539
|
data: {
|
|
218
540
|
query: `
|
|
219
541
|
{
|
|
@@ -231,11 +553,14 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
231
553
|
`,
|
|
232
554
|
},
|
|
233
555
|
};
|
|
234
|
-
const response = yield (0,
|
|
556
|
+
const response = yield (0, utils_js_1.fetchData)(request, 4);
|
|
235
557
|
this.log('Subgraph response vault positions :', response);
|
|
236
558
|
const requestSnapshot = {
|
|
237
559
|
method: 'POST',
|
|
238
560
|
url: this.steerSubgraph,
|
|
561
|
+
headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
562
|
+
? 'application/json'
|
|
563
|
+
: 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
|
|
239
564
|
data: {
|
|
240
565
|
query: `
|
|
241
566
|
{
|
|
@@ -250,7 +575,7 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
250
575
|
`,
|
|
251
576
|
},
|
|
252
577
|
};
|
|
253
|
-
const responseSnapshot = yield (0,
|
|
578
|
+
const responseSnapshot = yield (0, utils_js_1.fetchData)(requestSnapshot, 4);
|
|
254
579
|
this.log('Subgraph response current snapshot', responseSnapshot);
|
|
255
580
|
const positions = [];
|
|
256
581
|
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 +607,137 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
282
607
|
}
|
|
283
608
|
const poolAddress = yield this.getVaultPoolAddress();
|
|
284
609
|
const currentTick = yield this.getPoolCurrentTick(poolAddress, provider, currentExecutionContext, rpc);
|
|
610
|
+
const tickSpacing = yield this.getTickSpacing(poolAddress, provider, rpc, currentExecutionContext);
|
|
611
|
+
const totalAmounts = yield this.getTotalAmounts(this.vault, currentExecutionContext, provider, rpc);
|
|
612
|
+
// Handle both bigint and serialized bigint from centralized API
|
|
613
|
+
smartPoolExecutionContext.totalAmount0 = this.convertToString(totalAmounts.total0);
|
|
614
|
+
smartPoolExecutionContext.totalAmount1 = this.convertToString(totalAmounts.total1);
|
|
285
615
|
smartPoolExecutionContext.currentTick = currentTick;
|
|
616
|
+
smartPoolExecutionContext.tickSpacing = tickSpacing;
|
|
286
617
|
// "currentTick": 10,
|
|
287
618
|
return smartPoolExecutionContext;
|
|
288
619
|
});
|
|
289
620
|
}
|
|
290
621
|
getPoolCurrentTick(poolAddress, provider, currentExecutionContext, rpc) {
|
|
291
622
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
if (
|
|
293
|
-
const slot0 = yield this.
|
|
623
|
+
if (this.isAlgebraPool || this.isPoolSharkPool) {
|
|
624
|
+
const slot0 = yield this.getGlobalState(poolAddress, currentExecutionContext, provider, rpc);
|
|
625
|
+
return slot0.tick;
|
|
626
|
+
}
|
|
627
|
+
else if (this.isAerodromePool) {
|
|
628
|
+
const slot0 = yield this.getSlot0Aerodrome(poolAddress, currentExecutionContext, provider, rpc);
|
|
294
629
|
return slot0.tick;
|
|
295
630
|
}
|
|
296
631
|
else {
|
|
297
|
-
const slot0 = yield this.
|
|
632
|
+
const slot0 = yield this.getSlot0(poolAddress, currentExecutionContext, provider, rpc);
|
|
298
633
|
return slot0.tick;
|
|
299
634
|
}
|
|
300
635
|
});
|
|
301
636
|
}
|
|
637
|
+
getTickSpacing(poolAddress, provider, rpc, currentExecutionContext) {
|
|
638
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
639
|
+
const tickSpacingAbi = [
|
|
640
|
+
this.isPoolSharkPool
|
|
641
|
+
? {
|
|
642
|
+
inputs: [],
|
|
643
|
+
name: 'tickSpacing',
|
|
644
|
+
outputs: [
|
|
645
|
+
{
|
|
646
|
+
internalType: 'int24',
|
|
647
|
+
name: '',
|
|
648
|
+
type: 'int24',
|
|
649
|
+
},
|
|
650
|
+
],
|
|
651
|
+
stateMutability: 'view',
|
|
652
|
+
type: 'function',
|
|
653
|
+
}
|
|
654
|
+
: {
|
|
655
|
+
inputs: [],
|
|
656
|
+
name: 'tickSpacing',
|
|
657
|
+
outputs: [
|
|
658
|
+
{
|
|
659
|
+
internalType: 'int16',
|
|
660
|
+
name: '',
|
|
661
|
+
type: 'int16',
|
|
662
|
+
},
|
|
663
|
+
],
|
|
664
|
+
stateMutability: 'pure',
|
|
665
|
+
type: 'function',
|
|
666
|
+
},
|
|
667
|
+
];
|
|
668
|
+
const tickSpacing = yield (0, utils_js_1.readContract)({
|
|
669
|
+
address: poolAddress,
|
|
670
|
+
abi: tickSpacingAbi,
|
|
671
|
+
currentExecutionContext,
|
|
672
|
+
functionName: 'tickSpacing',
|
|
673
|
+
provider,
|
|
674
|
+
rpc,
|
|
675
|
+
chainId: this.chainId,
|
|
676
|
+
});
|
|
677
|
+
return tickSpacing;
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Converts a value to string, handling both native bigint and serialized bigint objects
|
|
682
|
+
* from the centralized API
|
|
683
|
+
*/
|
|
684
|
+
convertToString(value) {
|
|
685
|
+
if (typeof value === 'bigint') {
|
|
686
|
+
return value.toString();
|
|
687
|
+
}
|
|
688
|
+
if (typeof value === 'number') {
|
|
689
|
+
return value.toString();
|
|
690
|
+
}
|
|
691
|
+
if (typeof value === 'string') {
|
|
692
|
+
return value;
|
|
693
|
+
}
|
|
694
|
+
// Handle serialized bigint from centralized API (e.g., { type: 'BigNumber', hex: '0x...' })
|
|
695
|
+
if (value && typeof value === 'object') {
|
|
696
|
+
// If it's a BigNumber-like object with hex property
|
|
697
|
+
if (value.hex !== undefined) {
|
|
698
|
+
return BigInt(value.hex).toString();
|
|
699
|
+
}
|
|
700
|
+
// If it has a _hex property (ethers v5 BigNumber)
|
|
701
|
+
if (value._hex !== undefined) {
|
|
702
|
+
return BigInt(value._hex).toString();
|
|
703
|
+
}
|
|
704
|
+
// If it has toString method, try using it
|
|
705
|
+
if (typeof value.toString === 'function' && value.toString() !== '[object Object]') {
|
|
706
|
+
return value.toString();
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
// Fallback: convert to string (may result in '[object Object]' if not handled above)
|
|
710
|
+
return String(value);
|
|
711
|
+
}
|
|
712
|
+
getTotalAmounts(vaultAddress, currentExecutionContext, provider, rpc) {
|
|
713
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
714
|
+
const getTotalAmountsABI = [
|
|
715
|
+
{
|
|
716
|
+
inputs: [],
|
|
717
|
+
name: 'getTotalAmounts',
|
|
718
|
+
outputs: [
|
|
719
|
+
{ internalType: 'uint256', name: 'total0', type: 'uint256' },
|
|
720
|
+
{ internalType: 'uint256', name: 'total1', type: 'uint256' },
|
|
721
|
+
],
|
|
722
|
+
stateMutability: 'view',
|
|
723
|
+
type: 'function',
|
|
724
|
+
},
|
|
725
|
+
];
|
|
726
|
+
const totalAmounts = yield (0, utils_js_1.readContract)({
|
|
727
|
+
address: vaultAddress,
|
|
728
|
+
abi: getTotalAmountsABI,
|
|
729
|
+
currentExecutionContext,
|
|
730
|
+
functionName: 'getTotalAmounts',
|
|
731
|
+
provider,
|
|
732
|
+
rpc,
|
|
733
|
+
chainId: this.chainId,
|
|
734
|
+
});
|
|
735
|
+
return {
|
|
736
|
+
total0: totalAmounts[0],
|
|
737
|
+
total1: totalAmounts[1],
|
|
738
|
+
};
|
|
739
|
+
});
|
|
740
|
+
}
|
|
302
741
|
getVaultPoolAddress() {
|
|
303
742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
304
743
|
const requestSnapshot = {
|
|
@@ -314,8 +753,11 @@ class ExecutionApp extends executionBase_1.ExecutionBase {
|
|
|
314
753
|
}
|
|
315
754
|
`,
|
|
316
755
|
},
|
|
756
|
+
headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
757
|
+
? 'application/json'
|
|
758
|
+
: 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
|
|
317
759
|
};
|
|
318
|
-
const response = yield (0,
|
|
760
|
+
const response = yield (0, utils_js_1.fetchData)(requestSnapshot, 4);
|
|
319
761
|
return response.data.vault.pool;
|
|
320
762
|
});
|
|
321
763
|
}
|