@steerprotocol/data-connector-loader 5.0.0-next.2 → 5.0.0-next.4

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.
Files changed (50) hide show
  1. package/README.md +74 -0
  2. package/lib/bundle/bundleBase.d.ts +11 -14
  3. package/lib/bundle/bundleBase.js +56 -88
  4. package/lib/bundle/bundleDataConnector.d.ts +2 -6
  5. package/lib/bundle/bundleDataConnector.js +22 -47
  6. package/lib/esm/bundle/bundleBase.d.ts +11 -14
  7. package/lib/esm/bundle/bundleBase.js +77 -91
  8. package/lib/esm/bundle/bundleDataConnector.d.ts +2 -6
  9. package/lib/esm/bundle/bundleDataConnector.js +26 -49
  10. package/lib/esm/execution/executionApp.d.ts +5 -6
  11. package/lib/esm/execution/executionApp.js +335 -309
  12. package/lib/esm/execution/executionBase.d.ts +7 -7
  13. package/lib/esm/execution/executionBase.js +27 -13
  14. package/lib/esm/execution/executionDataConnector.d.ts +6 -3
  15. package/lib/esm/execution/executionDataConnector.js +114 -68
  16. package/lib/esm/index.d.ts +7 -7
  17. package/lib/esm/index.js +4 -4
  18. package/lib/esm/types.d.ts +20 -24
  19. package/lib/esm/types.js +5 -5
  20. package/lib/esm/utils/blockFinder.d.ts +2 -2
  21. package/lib/esm/utils/blockFinder.js +3 -3
  22. package/lib/esm/utils/consts.js +39 -39
  23. package/lib/esm/utils/pluginManager.d.ts +1 -1
  24. package/lib/esm/utils/pluginManager.js +6 -5
  25. package/lib/esm/utils/replace-old-subgraphs.js +61 -61
  26. package/lib/esm/utils/rpc.d.ts +4 -0
  27. package/lib/esm/utils/rpc.js +32 -0
  28. package/lib/esm/utils/utils.d.ts +8 -11
  29. package/lib/esm/utils/utils.js +61 -55
  30. package/lib/execution/executionApp.d.ts +5 -6
  31. package/lib/execution/executionApp.js +323 -302
  32. package/lib/execution/executionBase.d.ts +7 -7
  33. package/lib/execution/executionBase.js +27 -13
  34. package/lib/execution/executionDataConnector.d.ts +6 -3
  35. package/lib/execution/executionDataConnector.js +116 -63
  36. package/lib/index.d.ts +7 -7
  37. package/lib/index.js +1 -1
  38. package/lib/types.d.ts +20 -24
  39. package/lib/types.js +5 -5
  40. package/lib/utils/blockFinder.d.ts +2 -2
  41. package/lib/utils/blockFinder.js +3 -3
  42. package/lib/utils/consts.js +39 -39
  43. package/lib/utils/pluginManager.d.ts +1 -1
  44. package/lib/utils/pluginManager.js +5 -4
  45. package/lib/utils/replace-old-subgraphs.js +61 -61
  46. package/lib/utils/rpc.d.ts +4 -0
  47. package/lib/utils/rpc.js +47 -0
  48. package/lib/utils/utils.d.ts +8 -11
  49. package/lib/utils/utils.js +55 -60
  50. package/package.json +14 -13
@@ -18,40 +18,38 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
18
18
  constructor(config) {
19
19
  var _a;
20
20
  super((_a = config.maxRetries) !== null && _a !== void 0 ? _a : 3);
21
- this.getSlot0 = (pool, currentExecutionContext, provider, rpc) => __awaiter(this, void 0, void 0, function* () {
21
+ this.getSlot0 = (pool, currentExecutionContext, provider) => __awaiter(this, void 0, void 0, function* () {
22
22
  const slot0Abi = [
23
23
  {
24
24
  inputs: [],
25
- name: 'slot0',
25
+ name: "slot0",
26
26
  outputs: [
27
- { internalType: 'uint160', name: 'sqrtPriceX96', type: 'uint160' },
28
- { internalType: 'int24', name: 'tick', type: 'int24' },
29
- { internalType: 'uint16', name: 'observationIndex', type: 'uint16' },
27
+ { internalType: "uint160", name: "sqrtPriceX96", type: "uint160" },
28
+ { internalType: "int24", name: "tick", type: "int24" },
29
+ { internalType: "uint16", name: "observationIndex", type: "uint16" },
30
30
  {
31
- internalType: 'uint16',
32
- name: 'observationCardinality',
33
- type: 'uint16',
31
+ internalType: "uint16",
32
+ name: "observationCardinality",
33
+ type: "uint16",
34
34
  },
35
35
  {
36
- internalType: 'uint16',
37
- name: 'observationCardinalityNext',
38
- type: 'uint16',
36
+ internalType: "uint16",
37
+ name: "observationCardinalityNext",
38
+ type: "uint16",
39
39
  },
40
- { internalType: 'uint8', name: 'feeProtocol', type: 'uint8' },
41
- { internalType: 'bool', name: 'unlocked', type: 'bool' },
40
+ { internalType: "uint8", name: "feeProtocol", type: "uint8" },
41
+ { internalType: "bool", name: "unlocked", type: "bool" },
42
42
  ],
43
- stateMutability: 'view',
44
- type: 'function',
43
+ stateMutability: "view",
44
+ type: "function",
45
45
  },
46
46
  ];
47
47
  const slot0 = yield (0, utils_js_1.readContract)({
48
48
  address: pool,
49
49
  abi: slot0Abi,
50
50
  currentExecutionContext,
51
- functionName: 'slot0',
51
+ functionName: "slot0",
52
52
  provider,
53
- rpc,
54
- chainId: this.chainId,
55
53
  });
56
54
  return {
57
55
  sqrtPriceX96: slot0[0],
@@ -63,55 +61,53 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
63
61
  unlocked: slot0[6],
64
62
  };
65
63
  });
66
- this.getSlot0Aerodrome = (pool, currentExecutionContext, provider, rpc) => __awaiter(this, void 0, void 0, function* () {
64
+ this.getSlot0Aerodrome = (pool, currentExecutionContext, provider) => __awaiter(this, void 0, void 0, function* () {
67
65
  const slot0Abi = [
68
66
  {
69
67
  inputs: [],
70
- name: 'slot0',
68
+ name: "slot0",
71
69
  outputs: [
72
70
  {
73
- internalType: 'uint160',
74
- name: 'sqrtPriceX96',
75
- type: 'uint160',
71
+ internalType: "uint160",
72
+ name: "sqrtPriceX96",
73
+ type: "uint160",
76
74
  },
77
75
  {
78
- internalType: 'int24',
79
- name: 'tick',
80
- type: 'int24',
76
+ internalType: "int24",
77
+ name: "tick",
78
+ type: "int24",
81
79
  },
82
80
  {
83
- internalType: 'uint16',
84
- name: 'observationIndex',
85
- type: 'uint16',
81
+ internalType: "uint16",
82
+ name: "observationIndex",
83
+ type: "uint16",
86
84
  },
87
85
  {
88
- internalType: 'uint16',
89
- name: 'observationCardinality',
90
- type: 'uint16',
86
+ internalType: "uint16",
87
+ name: "observationCardinality",
88
+ type: "uint16",
91
89
  },
92
90
  {
93
- internalType: 'uint16',
94
- name: 'observationCardinalityNext',
95
- type: 'uint16',
91
+ internalType: "uint16",
92
+ name: "observationCardinalityNext",
93
+ type: "uint16",
96
94
  },
97
95
  {
98
- internalType: 'bool',
99
- name: 'unlocked',
100
- type: 'bool',
96
+ internalType: "bool",
97
+ name: "unlocked",
98
+ type: "bool",
101
99
  },
102
100
  ],
103
- stateMutability: 'view',
104
- type: 'function',
101
+ stateMutability: "view",
102
+ type: "function",
105
103
  },
106
104
  ];
107
105
  const slot0 = yield (0, utils_js_1.readContract)({
108
106
  address: pool,
109
107
  abi: slot0Abi,
110
108
  currentExecutionContext,
111
- functionName: 'slot0',
109
+ functionName: "slot0",
112
110
  provider,
113
- rpc,
114
- chainId: this.chainId,
115
111
  });
116
112
  return {
117
113
  sqrtPriceX96: slot0[0],
@@ -126,317 +122,315 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
126
122
  if (this.isAlgebraIntegralPool) {
127
123
  return {
128
124
  inputs: [],
129
- name: 'globalState',
125
+ name: "globalState",
130
126
  outputs: [
131
127
  {
132
- internalType: 'uint160',
133
- name: 'price',
134
- type: 'uint160',
128
+ internalType: "uint160",
129
+ name: "price",
130
+ type: "uint160",
135
131
  },
136
132
  {
137
- internalType: 'int24',
138
- name: 'tick',
139
- type: 'int24',
133
+ internalType: "int24",
134
+ name: "tick",
135
+ type: "int24",
140
136
  },
141
137
  {
142
- internalType: 'uint16',
143
- name: 'lastFee',
144
- type: 'uint16',
138
+ internalType: "uint16",
139
+ name: "lastFee",
140
+ type: "uint16",
145
141
  },
146
142
  {
147
- internalType: 'uint8',
148
- name: 'pluginConfig',
149
- type: 'uint8',
143
+ internalType: "uint8",
144
+ name: "pluginConfig",
145
+ type: "uint8",
150
146
  },
151
147
  {
152
- internalType: 'uint16',
153
- name: 'communityFee',
154
- type: 'uint16',
148
+ internalType: "uint16",
149
+ name: "communityFee",
150
+ type: "uint16",
155
151
  },
156
152
  {
157
- internalType: 'bool',
158
- name: 'unlocked',
159
- type: 'bool',
153
+ internalType: "bool",
154
+ name: "unlocked",
155
+ type: "bool",
160
156
  },
161
157
  ],
162
- stateMutability: 'view',
163
- type: 'function',
158
+ stateMutability: "view",
159
+ type: "function",
164
160
  };
165
161
  }
166
162
  else if (this.isDirectionalPool) {
167
163
  return {
168
164
  inputs: [],
169
- name: 'globalState',
165
+ name: "globalState",
170
166
  outputs: [
171
167
  {
172
- internalType: 'uint160',
173
- name: 'price',
174
- type: 'uint160',
168
+ internalType: "uint160",
169
+ name: "price",
170
+ type: "uint160",
175
171
  },
176
172
  {
177
- internalType: 'int24',
178
- name: 'tick',
179
- type: 'int24',
173
+ internalType: "int24",
174
+ name: "tick",
175
+ type: "int24",
180
176
  },
181
177
  {
182
- internalType: 'uint16',
183
- name: 'feeZto',
184
- type: 'uint16',
178
+ internalType: "uint16",
179
+ name: "feeZto",
180
+ type: "uint16",
185
181
  },
186
182
  {
187
- internalType: 'uint16',
188
- name: 'feeOtz',
189
- type: 'uint16',
183
+ internalType: "uint16",
184
+ name: "feeOtz",
185
+ type: "uint16",
190
186
  },
191
187
  {
192
- internalType: 'uint16',
193
- name: 'timepointIndex',
194
- type: 'uint16',
188
+ internalType: "uint16",
189
+ name: "timepointIndex",
190
+ type: "uint16",
195
191
  },
196
192
  {
197
- internalType: 'uint8',
198
- name: 'communityFeeToken0',
199
- type: 'uint8',
193
+ internalType: "uint8",
194
+ name: "communityFeeToken0",
195
+ type: "uint8",
200
196
  },
201
197
  {
202
- internalType: 'uint8',
203
- name: 'communityFeeToken1',
204
- type: 'uint8',
198
+ internalType: "uint8",
199
+ name: "communityFeeToken1",
200
+ type: "uint8",
205
201
  },
206
202
  {
207
- internalType: 'bool',
208
- name: 'unlocked',
209
- type: 'bool',
203
+ internalType: "bool",
204
+ name: "unlocked",
205
+ type: "bool",
210
206
  },
211
207
  ],
212
- stateMutability: 'view',
213
- type: 'function',
208
+ stateMutability: "view",
209
+ type: "function",
214
210
  };
215
211
  }
216
212
  else if (this.isPoolSharkPool) {
217
213
  return {
218
214
  inputs: [],
219
- name: 'globalState',
215
+ name: "globalState",
220
216
  outputs: [
221
217
  {
222
218
  components: [
223
219
  {
224
220
  components: [
225
221
  {
226
- internalType: 'uint16',
227
- name: 'index',
228
- type: 'uint16',
222
+ internalType: "uint16",
223
+ name: "index",
224
+ type: "uint16",
229
225
  },
230
226
  {
231
- internalType: 'uint16',
232
- name: 'count',
233
- type: 'uint16',
227
+ internalType: "uint16",
228
+ name: "count",
229
+ type: "uint16",
234
230
  },
235
231
  {
236
- internalType: 'uint16',
237
- name: 'countMax',
238
- type: 'uint16',
232
+ internalType: "uint16",
233
+ name: "countMax",
234
+ type: "uint16",
239
235
  },
240
236
  ],
241
- internalType: 'struct PoolsharkStructs.SampleState',
242
- name: 'samples',
243
- type: 'tuple',
237
+ internalType: "struct PoolsharkStructs.SampleState",
238
+ name: "samples",
239
+ type: "tuple",
244
240
  },
245
241
  {
246
- internalType: 'uint200',
247
- name: 'feeGrowthGlobal0',
248
- type: 'uint200',
242
+ internalType: "uint200",
243
+ name: "feeGrowthGlobal0",
244
+ type: "uint200",
249
245
  },
250
246
  {
251
- internalType: 'uint200',
252
- name: 'feeGrowthGlobal1',
253
- type: 'uint200',
247
+ internalType: "uint200",
248
+ name: "feeGrowthGlobal1",
249
+ type: "uint200",
254
250
  },
255
251
  {
256
- internalType: 'uint160',
257
- name: 'secondsPerLiquidityAccum',
258
- type: 'uint160',
252
+ internalType: "uint160",
253
+ name: "secondsPerLiquidityAccum",
254
+ type: "uint160",
259
255
  },
260
256
  {
261
- internalType: 'uint160',
262
- name: 'price',
263
- type: 'uint160',
257
+ internalType: "uint160",
258
+ name: "price",
259
+ type: "uint160",
264
260
  },
265
261
  {
266
- internalType: 'uint128',
267
- name: 'liquidity',
268
- type: 'uint128',
262
+ internalType: "uint128",
263
+ name: "liquidity",
264
+ type: "uint128",
269
265
  },
270
266
  {
271
- internalType: 'int56',
272
- name: 'tickSecondsAccum',
273
- type: 'int56',
267
+ internalType: "int56",
268
+ name: "tickSecondsAccum",
269
+ type: "int56",
274
270
  },
275
271
  {
276
- internalType: 'int24',
277
- name: 'tickAtPrice',
278
- type: 'int24',
272
+ internalType: "int24",
273
+ name: "tickAtPrice",
274
+ type: "int24",
279
275
  },
280
276
  {
281
- internalType: 'uint16',
282
- name: 'protocolSwapFee0',
283
- type: 'uint16',
277
+ internalType: "uint16",
278
+ name: "protocolSwapFee0",
279
+ type: "uint16",
284
280
  },
285
281
  {
286
- internalType: 'uint16',
287
- name: 'protocolSwapFee1',
288
- type: 'uint16',
282
+ internalType: "uint16",
283
+ name: "protocolSwapFee1",
284
+ type: "uint16",
289
285
  },
290
286
  ],
291
- internalType: 'struct PoolsharkStructs.RangePoolState',
292
- name: 'pool',
293
- type: 'tuple',
287
+ internalType: "struct PoolsharkStructs.RangePoolState",
288
+ name: "pool",
289
+ type: "tuple",
294
290
  },
295
291
  {
296
292
  components: [
297
293
  {
298
- internalType: 'uint160',
299
- name: 'price',
300
- type: 'uint160',
294
+ internalType: "uint160",
295
+ name: "price",
296
+ type: "uint160",
301
297
  },
302
298
  {
303
- internalType: 'uint128',
304
- name: 'liquidity',
305
- type: 'uint128',
299
+ internalType: "uint128",
300
+ name: "liquidity",
301
+ type: "uint128",
306
302
  },
307
303
  {
308
- internalType: 'uint128',
309
- name: 'protocolFees',
310
- type: 'uint128',
304
+ internalType: "uint128",
305
+ name: "protocolFees",
306
+ type: "uint128",
311
307
  },
312
308
  {
313
- internalType: 'uint16',
314
- name: 'protocolFillFee',
315
- type: 'uint16',
309
+ internalType: "uint16",
310
+ name: "protocolFillFee",
311
+ type: "uint16",
316
312
  },
317
313
  {
318
- internalType: 'int24',
319
- name: 'tickAtPrice',
320
- type: 'int24',
314
+ internalType: "int24",
315
+ name: "tickAtPrice",
316
+ type: "int24",
321
317
  },
322
318
  ],
323
- internalType: 'struct PoolsharkStructs.LimitPoolState',
324
- name: 'pool0',
325
- type: 'tuple',
319
+ internalType: "struct PoolsharkStructs.LimitPoolState",
320
+ name: "pool0",
321
+ type: "tuple",
326
322
  },
327
323
  {
328
324
  components: [
329
325
  {
330
- internalType: 'uint160',
331
- name: 'price',
332
- type: 'uint160',
326
+ internalType: "uint160",
327
+ name: "price",
328
+ type: "uint160",
333
329
  },
334
330
  {
335
- internalType: 'uint128',
336
- name: 'liquidity',
337
- type: 'uint128',
331
+ internalType: "uint128",
332
+ name: "liquidity",
333
+ type: "uint128",
338
334
  },
339
335
  {
340
- internalType: 'uint128',
341
- name: 'protocolFees',
342
- type: 'uint128',
336
+ internalType: "uint128",
337
+ name: "protocolFees",
338
+ type: "uint128",
343
339
  },
344
340
  {
345
- internalType: 'uint16',
346
- name: 'protocolFillFee',
347
- type: 'uint16',
341
+ internalType: "uint16",
342
+ name: "protocolFillFee",
343
+ type: "uint16",
348
344
  },
349
345
  {
350
- internalType: 'int24',
351
- name: 'tickAtPrice',
352
- type: 'int24',
346
+ internalType: "int24",
347
+ name: "tickAtPrice",
348
+ type: "int24",
353
349
  },
354
350
  ],
355
- internalType: 'struct PoolsharkStructs.LimitPoolState',
356
- name: 'pool1',
357
- type: 'tuple',
351
+ internalType: "struct PoolsharkStructs.LimitPoolState",
352
+ name: "pool1",
353
+ type: "tuple",
358
354
  },
359
355
  {
360
- internalType: 'uint128',
361
- name: 'liquidityGlobal',
362
- type: 'uint128',
356
+ internalType: "uint128",
357
+ name: "liquidityGlobal",
358
+ type: "uint128",
363
359
  },
364
360
  {
365
- internalType: 'uint32',
366
- name: 'positionIdNext',
367
- type: 'uint32',
361
+ internalType: "uint32",
362
+ name: "positionIdNext",
363
+ type: "uint32",
368
364
  },
369
365
  {
370
- internalType: 'uint32',
371
- name: 'epoch',
372
- type: 'uint32',
366
+ internalType: "uint32",
367
+ name: "epoch",
368
+ type: "uint32",
373
369
  },
374
370
  {
375
- internalType: 'uint8',
376
- name: 'unlocked',
377
- type: 'uint8',
371
+ internalType: "uint8",
372
+ name: "unlocked",
373
+ type: "uint8",
378
374
  },
379
375
  ],
380
- stateMutability: 'view',
381
- type: 'function',
376
+ stateMutability: "view",
377
+ type: "function",
382
378
  };
383
379
  }
384
380
  else {
385
381
  return {
386
382
  inputs: [],
387
- name: 'globalState',
383
+ name: "globalState",
388
384
  outputs: [
389
385
  {
390
- internalType: 'uint160',
391
- name: 'price',
392
- type: 'uint160',
386
+ internalType: "uint160",
387
+ name: "price",
388
+ type: "uint160",
393
389
  },
394
390
  {
395
- internalType: 'int24',
396
- name: 'tick',
397
- type: 'int24',
391
+ internalType: "int24",
392
+ name: "tick",
393
+ type: "int24",
398
394
  },
399
395
  {
400
- internalType: 'int24',
401
- name: 'prevInitializedTick',
402
- type: 'int24',
396
+ internalType: "int24",
397
+ name: "prevInitializedTick",
398
+ type: "int24",
403
399
  },
404
400
  {
405
- internalType: 'uint16',
406
- name: 'fee',
407
- type: 'uint16',
401
+ internalType: "uint16",
402
+ name: "fee",
403
+ type: "uint16",
408
404
  },
409
405
  {
410
- internalType: 'uint16',
411
- name: 'timepointIndex',
412
- type: 'uint16',
406
+ internalType: "uint16",
407
+ name: "timepointIndex",
408
+ type: "uint16",
413
409
  },
414
410
  {
415
- internalType: 'uint8',
416
- name: 'communityFee',
417
- type: 'uint8',
411
+ internalType: "uint8",
412
+ name: "communityFee",
413
+ type: "uint8",
418
414
  },
419
415
  {
420
- internalType: 'bool',
421
- name: 'unlocked',
422
- type: 'bool',
416
+ internalType: "bool",
417
+ name: "unlocked",
418
+ type: "bool",
423
419
  },
424
420
  ],
425
- stateMutability: 'view',
426
- type: 'function',
421
+ stateMutability: "view",
422
+ type: "function",
427
423
  };
428
424
  }
429
425
  };
430
- this.getGlobalState = (pool, currentExecutionContext, provider, rpc) => __awaiter(this, void 0, void 0, function* () {
426
+ this.getGlobalState = (pool, currentExecutionContext, provider) => __awaiter(this, void 0, void 0, function* () {
431
427
  const slot0Abi = [this.getGlobalStateAbi()];
432
428
  const slot0 = yield (0, utils_js_1.readContract)({
433
429
  address: pool,
434
430
  abi: slot0Abi,
435
431
  currentExecutionContext,
436
- functionName: 'globalState',
432
+ functionName: "globalState",
437
433
  provider,
438
- rpc,
439
- chainId: this.chainId,
440
434
  });
441
435
  if (this.isPoolSharkPool) {
442
436
  return {
@@ -481,16 +475,17 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
481
475
  this.sentioApiKey = config.apiKeys.sentioApiKey;
482
476
  this.config = config;
483
477
  }
484
- execute(_wasmFile, _vaultConfig, _data, _identity, _etherRpcConfig, forceDeposit) {
478
+ execute(_wasmFile, _vaultConfig, _data, rpc, forceDeposit) {
485
479
  return __awaiter(this, void 0, void 0, function* () {
486
- const dataConnector = new bundleDataConnector_js_1.DataConnector(_wasmFile, _vaultConfig, this.config, _identity, _etherRpcConfig);
480
+ const dataConnector = new bundleDataConnector_js_1.DataConnector({
481
+ wasmFile: _wasmFile,
482
+ config: _vaultConfig,
483
+ executionConfig: this.config,
484
+ rpc,
485
+ });
487
486
  yield dataConnector.loadSync();
488
487
  const executionContext = yield this.getExecutionContext(dataConnector, JSON.parse(_vaultConfig));
489
- let rpc = '';
490
- if (_etherRpcConfig) {
491
- rpc = _etherRpcConfig[this.chainId.toString()].url;
492
- }
493
- const smartPoolExecutionContext = yield this.getSmartPoolExecutionContext(executionContext, dataConnector, JSON.parse(_vaultConfig), rpc);
488
+ const smartPoolExecutionContext = yield this.getSmartPoolExecutionContext(executionContext, dataConnector, JSON.parse(_vaultConfig));
494
489
  dataConnector.setExecutionContextStrategyExecution(Object.assign(Object.assign({}, executionContext), smartPoolExecutionContext), forceDeposit);
495
490
  _data = _data.map((element) => JSON.stringify(element));
496
491
  const result = yield dataConnector.executeBundle(_data);
@@ -505,9 +500,13 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
505
500
  executeWithContext(options) {
506
501
  return __awaiter(this, void 0, void 0, function* () {
507
502
  const vaultConfig = this.parseVaultConfig(options.vaultConfig);
508
- const executionContext = options.executionContext;
509
- this.validateExecutionContext(executionContext, vaultConfig);
510
- const dataConnector = new bundleDataConnector_js_1.DataConnector(options.wasmFile, options.vaultConfig, this.config, options.identity, options.etherRpcConfig);
503
+ this.validateExecutionContext(options.executionContext, vaultConfig);
504
+ const executionContext = Object.assign(Object.assign({}, options.executionContext), { positions: options.executionContext.positions.map((position) => (Object.assign({}, position))) });
505
+ const dataConnector = new bundleDataConnector_js_1.DataConnector({
506
+ wasmFile: options.wasmFile,
507
+ config: options.vaultConfig,
508
+ executionConfig: this.config,
509
+ });
511
510
  try {
512
511
  yield dataConnector.loadSync();
513
512
  dataConnector.initializeStrategyWithContext(executionContext, options.forceDeposit);
@@ -526,13 +525,13 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
526
525
  return JSON.parse(vaultConfig);
527
526
  }
528
527
  catch (_a) {
529
- throw new types_js_1.ExecutionContextError('INVALID_EXECUTION_CONTEXT', 'vaultConfig must be valid JSON.');
528
+ throw new types_js_1.ExecutionContextError("INVALID_EXECUTION_CONTEXT", "vaultConfig must be valid JSON.");
530
529
  }
531
530
  }
532
531
  validateExecutionContext(context, vaultConfig) {
533
532
  var _a;
534
- if (!context || typeof context !== 'object') {
535
- throw new types_js_1.ExecutionContextError('INVALID_EXECUTION_CONTEXT', 'An execution context is required.');
533
+ if (!context || typeof context !== "object") {
534
+ throw new types_js_1.ExecutionContextError("INVALID_EXECUTION_CONTEXT", "An execution context is required.");
536
535
  }
537
536
  if (!Number.isSafeInteger(context.chainId) ||
538
537
  !Number.isSafeInteger(context.blockNumber) ||
@@ -546,51 +545,58 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
546
545
  !Number.isFinite(context.blockTime) ||
547
546
  !Number.isInteger(context.currentTick) ||
548
547
  !Number.isInteger(context.tickSpacing) ||
549
- typeof context.vaultAddress !== 'string' ||
548
+ typeof context.vaultAddress !== "string" ||
550
549
  context.vaultAddress.length === 0 ||
551
- typeof context.totalAmount0 !== 'string' ||
550
+ typeof context.totalAmount0 !== "string" ||
552
551
  !/^\d+$/.test(context.totalAmount0) ||
553
- typeof context.totalAmount1 !== 'string' ||
552
+ typeof context.totalAmount1 !== "string" ||
554
553
  !/^\d+$/.test(context.totalAmount1) ||
555
554
  !Array.isArray(context.positions) ||
556
555
  !Number.isFinite(context.lastExecutionTime) ||
557
556
  context.lastExecutionTime < 0) {
558
- throw new types_js_1.ExecutionContextError('INVALID_EXECUTION_CONTEXT', 'Execution context is malformed.');
557
+ throw new types_js_1.ExecutionContextError("INVALID_EXECUTION_CONTEXT", "Execution context is malformed.");
559
558
  }
560
559
  const sameAddress = (left, right) => (left === null || left === void 0 ? void 0 : left.toLowerCase()) === (right === null || right === void 0 ? void 0 : right.toLowerCase());
561
560
  if (!sameAddress(this.vault, context.vaultAddress) ||
562
561
  !sameAddress(vaultConfig.vaultAddress, context.vaultAddress)) {
563
- throw new types_js_1.ExecutionContextError('EXECUTION_CONTEXT_MISMATCH', 'Supplied context vault does not match the execution request.');
562
+ throw new types_js_1.ExecutionContextError("EXECUTION_CONTEXT_MISMATCH", "Supplied context vault does not match the execution request.");
564
563
  }
565
564
  if (this.chainId !== context.chainId ||
566
- (vaultConfig.chainId !== undefined && Number(vaultConfig.chainId) !== context.chainId)) {
567
- throw new types_js_1.ExecutionContextError('EXECUTION_CONTEXT_MISMATCH', 'Supplied context chain does not match the execution request.');
565
+ (vaultConfig.chainId !== undefined &&
566
+ Number(vaultConfig.chainId) !== context.chainId)) {
567
+ throw new types_js_1.ExecutionContextError("EXECUTION_CONTEXT_MISMATCH", "Supplied context chain does not match the execution request.");
568
568
  }
569
569
  if (vaultConfig.anchorBlockNumber !== undefined &&
570
570
  String(vaultConfig.anchorBlockNumber) !== String(context.blockNumber)) {
571
- throw new types_js_1.ExecutionContextError('EXECUTION_CONTEXT_MISMATCH', 'Supplied context block does not match anchorBlockNumber.');
571
+ throw new types_js_1.ExecutionContextError("EXECUTION_CONTEXT_MISMATCH", "Supplied context block does not match anchorBlockNumber.");
572
572
  }
573
- if (Number((_a = vaultConfig.strategyConfigData) === null || _a === void 0 ? void 0 : _a.epochLength) !== context.epochLength) {
574
- throw new types_js_1.ExecutionContextError('EXECUTION_CONTEXT_MISMATCH', 'Supplied context epoch length does not match vaultConfig.');
573
+ if (Number((_a = vaultConfig.strategyConfigData) === null || _a === void 0 ? void 0 : _a.epochLength) !==
574
+ context.epochLength) {
575
+ throw new types_js_1.ExecutionContextError("EXECUTION_CONTEXT_MISMATCH", "Supplied context epoch length does not match vaultConfig.");
575
576
  }
576
577
  for (const position of context.positions) {
577
578
  if (!position ||
578
579
  !Number.isInteger(position.startTick) ||
579
580
  !Number.isInteger(position.endTick) ||
580
581
  !Number.isFinite(position.weight)) {
581
- throw new types_js_1.ExecutionContextError('INVALID_EXECUTION_CONTEXT', 'Execution context contains an invalid position.');
582
+ throw new types_js_1.ExecutionContextError("INVALID_EXECUTION_CONTEXT", "Execution context contains an invalid position.");
582
583
  }
583
584
  }
584
585
  }
585
586
  redactError(error) {
586
587
  const message = error instanceof Error ? error.message : String(error);
587
588
  return message
588
- .replace(/https?:\/\/[^\s@/]+(?::[^\s@/]+)?@/gi, 'https://[REDACTED]@')
589
- .replace(/([?&](?:key|token|api[_-]?key|password)=)[^&\s]+/gi, '$1[REDACTED]');
589
+ .replace(/https?:\/\/[^\s@/]+(?::[^\s@/]+)?@/gi, "https://[REDACTED]@")
590
+ .replace(/([?&](?:key|token|api[_-]?key|password)=)[^&\s]+/gi, "$1[REDACTED]");
590
591
  }
591
- executeStabilityVault(_wasmFile, _vaultConfig, _data, _identity, _etherRpcConfig, forceDeposit) {
592
+ executeStabilityVault(_wasmFile, _vaultConfig, _data, rpc, forceDeposit) {
592
593
  return __awaiter(this, void 0, void 0, function* () {
593
- const dataConnector = new bundleDataConnector_js_1.DataConnector(_wasmFile, _vaultConfig, this.config, _identity, _etherRpcConfig);
594
+ const dataConnector = new bundleDataConnector_js_1.DataConnector({
595
+ wasmFile: _wasmFile,
596
+ config: _vaultConfig,
597
+ executionConfig: this.config,
598
+ rpc,
599
+ });
594
600
  yield dataConnector.loadSync();
595
601
  const executionContext = yield this.getExecutionContext(dataConnector, JSON.parse(_vaultConfig));
596
602
  const dynamicJobExecutionContext = {};
@@ -600,14 +606,19 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
600
606
  return JSON.parse(result);
601
607
  });
602
608
  }
603
- executeDynamicJobs(_wasmFile, _vaultConfig, _data, _job, _identity, _etherRpcConfig, forceDeposit) {
609
+ executeDynamicJobs(_wasmFile, _vaultConfig, _data, _job, rpc, forceDeposit) {
604
610
  return __awaiter(this, void 0, void 0, function* () {
605
- const dataConnector = new bundleDataConnector_js_1.DataConnector(_wasmFile, _vaultConfig, this.config, _identity, _etherRpcConfig);
611
+ const dataConnector = new bundleDataConnector_js_1.DataConnector({
612
+ wasmFile: _wasmFile,
613
+ config: _vaultConfig,
614
+ executionConfig: this.config,
615
+ rpc,
616
+ });
606
617
  yield dataConnector.loadSync();
607
618
  const executionContext = yield this.getExecutionContext(dataConnector, JSON.parse(_vaultConfig));
608
619
  const smartRewardsContractAddress = _job.targetAddresses[0];
609
620
  if (!smartRewardsContractAddress) {
610
- throw new Error('Dynamic job must include at least one target address');
621
+ throw new Error("Dynamic job must include at least one target address");
611
622
  }
612
623
  const dynamicJobExecutionContext = {
613
624
  smartRewardsContractAddress,
@@ -618,16 +629,18 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
618
629
  return JSON.parse(result);
619
630
  });
620
631
  }
621
- getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig, rpc) {
632
+ getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig) {
622
633
  var _a, _b, _c, _d, _e, _f;
623
634
  return __awaiter(this, void 0, void 0, function* () {
624
635
  const smartPoolExecutionContext = {};
625
636
  const request = {
626
- method: 'POST',
637
+ method: "POST",
627
638
  url: this.steerSubgraph,
628
- headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
629
- ? 'application/json'
630
- : 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
639
+ headers: Object.assign({ "Content-Type": !this.steerSubgraph.includes("subgraph-proxy-server")
640
+ ? "application/json"
641
+ : "text/plain;charset=UTF-8" }, (this.steerSubgraph.includes("sentio")
642
+ ? { "api-key": this.sentioApiKey }
643
+ : {})),
631
644
  data: {
632
645
  query: `
633
646
  {
@@ -646,13 +659,15 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
646
659
  },
647
660
  };
648
661
  const response = yield (0, utils_js_1.fetchData)(request, 4);
649
- this.log('Subgraph response vault positions :', response);
662
+ this.log("Subgraph response vault positions :", response);
650
663
  const requestSnapshot = {
651
- method: 'POST',
664
+ method: "POST",
652
665
  url: this.steerSubgraph,
653
- headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
654
- ? 'application/json'
655
- : 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
666
+ headers: Object.assign({ "Content-Type": !this.steerSubgraph.includes("subgraph-proxy-server")
667
+ ? "application/json"
668
+ : "text/plain;charset=UTF-8" }, (this.steerSubgraph.includes("sentio")
669
+ ? { "api-key": this.sentioApiKey }
670
+ : {})),
656
671
  data: {
657
672
  query: `
658
673
  {
@@ -668,9 +683,10 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
668
683
  },
669
684
  };
670
685
  const responseSnapshot = yield (0, utils_js_1.fetchData)(requestSnapshot, 4);
671
- this.log('Subgraph response current snapshot', responseSnapshot);
686
+ this.log("Subgraph response current snapshot", responseSnapshot);
672
687
  const positions = [];
673
- 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) {
688
+ if (((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.vaultPositions) &&
689
+ ((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.vaultPositions.length) > 0) {
674
690
  const positionResponse = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.vaultPositions[0];
675
691
  for (let i = 0; i < positionResponse.upperTick.length; i++) {
676
692
  const position = positionResponse;
@@ -682,25 +698,31 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
682
698
  }
683
699
  }
684
700
  let lastSnapshot;
685
- if (((_d = responseSnapshot === null || responseSnapshot === void 0 ? void 0 : responseSnapshot.data) === null || _d === void 0 ? void 0 : _d.vaultSnapshots) && ((_e = responseSnapshot === null || responseSnapshot === void 0 ? void 0 : responseSnapshot.data) === null || _e === void 0 ? void 0 : _e.vaultSnapshots.length) > 0) {
701
+ if (((_d = responseSnapshot === null || responseSnapshot === void 0 ? void 0 : responseSnapshot.data) === null || _d === void 0 ? void 0 : _d.vaultSnapshots) &&
702
+ ((_e = responseSnapshot === null || responseSnapshot === void 0 ? void 0 : responseSnapshot.data) === null || _e === void 0 ? void 0 : _e.vaultSnapshots.length) > 0) {
686
703
  lastSnapshot = (_f = responseSnapshot === null || responseSnapshot === void 0 ? void 0 : responseSnapshot.data) === null || _f === void 0 ? void 0 : _f.vaultSnapshots[0];
687
704
  }
688
- this.log('Subgraph response vault positions', positions);
705
+ this.log("Subgraph response vault positions", positions);
689
706
  smartPoolExecutionContext.positions = positions;
690
707
  if (lastSnapshot) {
691
- smartPoolExecutionContext.lastExecutionTime = (Date.now() - Number(lastSnapshot.timestamp) * 1000) / 1000;
708
+ smartPoolExecutionContext.lastExecutionTime =
709
+ (Date.now() - Number(lastSnapshot.timestamp) * 1000) / 1000;
692
710
  }
693
711
  else {
694
- smartPoolExecutionContext.lastExecutionTime = currentExecutionContext.epochTimestamp;
712
+ smartPoolExecutionContext.lastExecutionTime =
713
+ currentExecutionContext.epochTimestamp;
695
714
  }
696
- const provider = dataConnector.getProvider(vaultConfig);
715
+ const provider = dataConnector.getClient();
697
716
  if (!provider) {
698
- throw new Error('Provider configuration issue, unable to process Smart Pool execution context.');
717
+ throw new Error("Provider configuration issue, unable to process Smart Pool execution context.");
718
+ }
719
+ if ((yield provider.getChainId()) !== currentExecutionContext.chainId) {
720
+ throw new Error("EXECUTION_CONTEXT_MISMATCH: provider chain does not match supplied context.");
699
721
  }
700
722
  const poolAddress = yield this.getVaultPoolAddress();
701
- const currentTick = yield this.getPoolCurrentTick(poolAddress, provider, currentExecutionContext, rpc);
702
- const tickSpacing = yield this.getTickSpacing(poolAddress, provider, rpc, currentExecutionContext);
703
- const totalAmounts = yield this.getTotalAmounts(this.vault, currentExecutionContext, provider, rpc);
723
+ const currentTick = yield this.getPoolCurrentTick(poolAddress, provider, currentExecutionContext);
724
+ const tickSpacing = yield this.getTickSpacing(poolAddress, provider, currentExecutionContext);
725
+ const totalAmounts = yield this.getTotalAmounts(this.vault, currentExecutionContext, provider);
704
726
  // Handle both bigint and serialized bigint from centralized API
705
727
  smartPoolExecutionContext.totalAmount0 = this.convertToString(totalAmounts.total0);
706
728
  smartPoolExecutionContext.totalAmount1 = this.convertToString(totalAmounts.total1);
@@ -710,61 +732,59 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
710
732
  return smartPoolExecutionContext;
711
733
  });
712
734
  }
713
- getPoolCurrentTick(poolAddress, provider, currentExecutionContext, rpc) {
735
+ getPoolCurrentTick(poolAddress, provider, currentExecutionContext) {
714
736
  return __awaiter(this, void 0, void 0, function* () {
715
737
  if (this.isAlgebraPool || this.isPoolSharkPool) {
716
- const slot0 = yield this.getGlobalState(poolAddress, currentExecutionContext, provider, rpc);
738
+ const slot0 = yield this.getGlobalState(poolAddress, currentExecutionContext, provider);
717
739
  return slot0.tick;
718
740
  }
719
741
  else if (this.isAerodromePool) {
720
- const slot0 = yield this.getSlot0Aerodrome(poolAddress, currentExecutionContext, provider, rpc);
742
+ const slot0 = yield this.getSlot0Aerodrome(poolAddress, currentExecutionContext, provider);
721
743
  return slot0.tick;
722
744
  }
723
745
  else {
724
- const slot0 = yield this.getSlot0(poolAddress, currentExecutionContext, provider, rpc);
746
+ const slot0 = yield this.getSlot0(poolAddress, currentExecutionContext, provider);
725
747
  return slot0.tick;
726
748
  }
727
749
  });
728
750
  }
729
- getTickSpacing(poolAddress, provider, rpc, currentExecutionContext) {
751
+ getTickSpacing(poolAddress, provider, currentExecutionContext) {
730
752
  return __awaiter(this, void 0, void 0, function* () {
731
753
  const tickSpacingAbi = [
732
754
  this.isPoolSharkPool
733
755
  ? {
734
756
  inputs: [],
735
- name: 'tickSpacing',
757
+ name: "tickSpacing",
736
758
  outputs: [
737
759
  {
738
- internalType: 'int24',
739
- name: '',
740
- type: 'int24',
760
+ internalType: "int24",
761
+ name: "",
762
+ type: "int24",
741
763
  },
742
764
  ],
743
- stateMutability: 'view',
744
- type: 'function',
765
+ stateMutability: "view",
766
+ type: "function",
745
767
  }
746
768
  : {
747
769
  inputs: [],
748
- name: 'tickSpacing',
770
+ name: "tickSpacing",
749
771
  outputs: [
750
772
  {
751
- internalType: 'int16',
752
- name: '',
753
- type: 'int16',
773
+ internalType: "int16",
774
+ name: "",
775
+ type: "int16",
754
776
  },
755
777
  ],
756
- stateMutability: 'pure',
757
- type: 'function',
778
+ stateMutability: "pure",
779
+ type: "function",
758
780
  },
759
781
  ];
760
782
  const tickSpacing = yield (0, utils_js_1.readContract)({
761
783
  address: poolAddress,
762
784
  abi: tickSpacingAbi,
763
785
  currentExecutionContext,
764
- functionName: 'tickSpacing',
786
+ functionName: "tickSpacing",
765
787
  provider,
766
- rpc,
767
- chainId: this.chainId,
768
788
  });
769
789
  return tickSpacing;
770
790
  });
@@ -774,17 +794,17 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
774
794
  * from the centralized API
775
795
  */
776
796
  convertToString(value) {
777
- if (typeof value === 'bigint') {
797
+ if (typeof value === "bigint") {
778
798
  return value.toString();
779
799
  }
780
- if (typeof value === 'number') {
800
+ if (typeof value === "number") {
781
801
  return value.toString();
782
802
  }
783
- if (typeof value === 'string') {
803
+ if (typeof value === "string") {
784
804
  return value;
785
805
  }
786
806
  // Handle serialized bigint from centralized API (e.g., { type: 'BigNumber', hex: '0x...' })
787
- if (value && typeof value === 'object') {
807
+ if (value && typeof value === "object") {
788
808
  // If it's a BigNumber-like object with hex property
789
809
  if (value.hex !== undefined) {
790
810
  return BigInt(value.hex).toString();
@@ -794,35 +814,34 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
794
814
  return BigInt(value._hex).toString();
795
815
  }
796
816
  // If it has toString method, try using it
797
- if (typeof value.toString === 'function' && value.toString() !== '[object Object]') {
817
+ if (typeof value.toString === "function" &&
818
+ value.toString() !== "[object Object]") {
798
819
  return value.toString();
799
820
  }
800
821
  }
801
822
  // Fallback: convert to string (may result in '[object Object]' if not handled above)
802
823
  return String(value);
803
824
  }
804
- getTotalAmounts(vaultAddress, currentExecutionContext, provider, rpc) {
825
+ getTotalAmounts(vaultAddress, currentExecutionContext, provider) {
805
826
  return __awaiter(this, void 0, void 0, function* () {
806
827
  const getTotalAmountsABI = [
807
828
  {
808
829
  inputs: [],
809
- name: 'getTotalAmounts',
830
+ name: "getTotalAmounts",
810
831
  outputs: [
811
- { internalType: 'uint256', name: 'total0', type: 'uint256' },
812
- { internalType: 'uint256', name: 'total1', type: 'uint256' },
832
+ { internalType: "uint256", name: "total0", type: "uint256" },
833
+ { internalType: "uint256", name: "total1", type: "uint256" },
813
834
  ],
814
- stateMutability: 'view',
815
- type: 'function',
835
+ stateMutability: "view",
836
+ type: "function",
816
837
  },
817
838
  ];
818
839
  const totalAmounts = yield (0, utils_js_1.readContract)({
819
840
  address: vaultAddress,
820
841
  abi: getTotalAmountsABI,
821
842
  currentExecutionContext,
822
- functionName: 'getTotalAmounts',
843
+ functionName: "getTotalAmounts",
823
844
  provider,
824
- rpc,
825
- chainId: this.chainId,
826
845
  });
827
846
  return {
828
847
  total0: totalAmounts[0],
@@ -833,7 +852,7 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
833
852
  getVaultPoolAddress() {
834
853
  return __awaiter(this, void 0, void 0, function* () {
835
854
  const requestSnapshot = {
836
- method: 'POST',
855
+ method: "POST",
837
856
  url: this.steerSubgraph,
838
857
  data: {
839
858
  query: `
@@ -845,9 +864,11 @@ class ExecutionApp extends executionBase_js_1.ExecutionBase {
845
864
  }
846
865
  `,
847
866
  },
848
- headers: Object.assign({ 'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
849
- ? 'application/json'
850
- : 'text/plain;charset=UTF-8' }, (this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {})),
867
+ headers: Object.assign({ "Content-Type": !this.steerSubgraph.includes("subgraph-proxy-server")
868
+ ? "application/json"
869
+ : "text/plain;charset=UTF-8" }, (this.steerSubgraph.includes("sentio")
870
+ ? { "api-key": this.sentioApiKey }
871
+ : {})),
851
872
  };
852
873
  const response = yield (0, utils_js_1.fetchData)(requestSnapshot, 4);
853
874
  return response.data.vault.pool;