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