@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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DataConnector } from '../bundle/bundleDataConnector';
|
|
2
|
-
import { fetchData,
|
|
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(
|
|
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
|
|
33
|
+
const slot0 = await readContract({
|
|
34
34
|
address: pool,
|
|
35
35
|
abi: slot0Abi,
|
|
36
36
|
currentExecutionContext,
|
|
37
37
|
functionName: 'slot0',
|
|
38
|
-
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.
|
|
52
|
+
this.getSlot0Aerodrome = async (pool, currentExecutionContext, provider, rpc) => {
|
|
53
53
|
const slot0Abi = [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
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
|
|
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
|
|
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.
|
|
177
|
-
this.
|
|
178
|
-
this.
|
|
179
|
-
this.
|
|
180
|
-
this.
|
|
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,54 @@ 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 smartRewardsContractAddress = _job.targetAddresses[0];
|
|
505
|
+
if (!smartRewardsContractAddress) {
|
|
506
|
+
throw new Error('Dynamic job must include at least one target address');
|
|
507
|
+
}
|
|
508
|
+
const dynamicJobExecutionContext = {
|
|
509
|
+
smartRewardsContractAddress,
|
|
510
|
+
};
|
|
511
|
+
dataConnector.setExecutionContextStrategyExecution({
|
|
512
|
+
...executionContext,
|
|
513
|
+
...dynamicJobExecutionContext,
|
|
514
|
+
}, forceDeposit);
|
|
515
|
+
_data = _data.map((element) => JSON.stringify(element));
|
|
516
|
+
const result = await dataConnector.executeDynamicJobBundle(_data);
|
|
517
|
+
return JSON.parse(result);
|
|
518
|
+
}
|
|
199
519
|
async getSmartPoolExecutionContext(currentExecutionContext, dataConnector, vaultConfig, rpc) {
|
|
200
520
|
const smartPoolExecutionContext = {};
|
|
201
521
|
const request = {
|
|
202
522
|
method: 'POST',
|
|
203
523
|
url: this.steerSubgraph,
|
|
524
|
+
headers: {
|
|
525
|
+
'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
526
|
+
? 'application/json'
|
|
527
|
+
: 'text/plain;charset=UTF-8',
|
|
528
|
+
...(this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {}),
|
|
529
|
+
},
|
|
204
530
|
data: {
|
|
205
531
|
query: `
|
|
206
532
|
{
|
|
@@ -223,6 +549,12 @@ export class ExecutionApp extends ExecutionBase {
|
|
|
223
549
|
const requestSnapshot = {
|
|
224
550
|
method: 'POST',
|
|
225
551
|
url: this.steerSubgraph,
|
|
552
|
+
headers: {
|
|
553
|
+
'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
554
|
+
? 'application/json'
|
|
555
|
+
: 'text/plain;charset=UTF-8',
|
|
556
|
+
...(this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {}),
|
|
557
|
+
},
|
|
226
558
|
data: {
|
|
227
559
|
query: `
|
|
228
560
|
{
|
|
@@ -269,20 +601,130 @@ export class ExecutionApp extends ExecutionBase {
|
|
|
269
601
|
}
|
|
270
602
|
const poolAddress = await this.getVaultPoolAddress();
|
|
271
603
|
const currentTick = await this.getPoolCurrentTick(poolAddress, provider, currentExecutionContext, rpc);
|
|
604
|
+
const tickSpacing = await this.getTickSpacing(poolAddress, provider, rpc, currentExecutionContext);
|
|
605
|
+
const totalAmounts = await this.getTotalAmounts(this.vault, currentExecutionContext, provider, rpc);
|
|
606
|
+
// Handle both bigint and serialized bigint from centralized API
|
|
607
|
+
smartPoolExecutionContext.totalAmount0 = this.convertToString(totalAmounts.total0);
|
|
608
|
+
smartPoolExecutionContext.totalAmount1 = this.convertToString(totalAmounts.total1);
|
|
272
609
|
smartPoolExecutionContext.currentTick = currentTick;
|
|
610
|
+
smartPoolExecutionContext.tickSpacing = tickSpacing;
|
|
273
611
|
// "currentTick": 10,
|
|
274
612
|
return smartPoolExecutionContext;
|
|
275
613
|
}
|
|
276
614
|
async getPoolCurrentTick(poolAddress, provider, currentExecutionContext, rpc) {
|
|
277
|
-
if (
|
|
278
|
-
const slot0 = await this.
|
|
615
|
+
if (this.isAlgebraPool || this.isPoolSharkPool) {
|
|
616
|
+
const slot0 = await this.getGlobalState(poolAddress, currentExecutionContext, provider, rpc);
|
|
617
|
+
return slot0.tick;
|
|
618
|
+
}
|
|
619
|
+
else if (this.isAerodromePool) {
|
|
620
|
+
const slot0 = await this.getSlot0Aerodrome(poolAddress, currentExecutionContext, provider, rpc);
|
|
279
621
|
return slot0.tick;
|
|
280
622
|
}
|
|
281
623
|
else {
|
|
282
|
-
const slot0 = await this.
|
|
624
|
+
const slot0 = await this.getSlot0(poolAddress, currentExecutionContext, provider, rpc);
|
|
283
625
|
return slot0.tick;
|
|
284
626
|
}
|
|
285
627
|
}
|
|
628
|
+
async getTickSpacing(poolAddress, provider, rpc, currentExecutionContext) {
|
|
629
|
+
const tickSpacingAbi = [
|
|
630
|
+
this.isPoolSharkPool
|
|
631
|
+
? {
|
|
632
|
+
inputs: [],
|
|
633
|
+
name: 'tickSpacing',
|
|
634
|
+
outputs: [
|
|
635
|
+
{
|
|
636
|
+
internalType: 'int24',
|
|
637
|
+
name: '',
|
|
638
|
+
type: 'int24',
|
|
639
|
+
},
|
|
640
|
+
],
|
|
641
|
+
stateMutability: 'view',
|
|
642
|
+
type: 'function',
|
|
643
|
+
}
|
|
644
|
+
: {
|
|
645
|
+
inputs: [],
|
|
646
|
+
name: 'tickSpacing',
|
|
647
|
+
outputs: [
|
|
648
|
+
{
|
|
649
|
+
internalType: 'int16',
|
|
650
|
+
name: '',
|
|
651
|
+
type: 'int16',
|
|
652
|
+
},
|
|
653
|
+
],
|
|
654
|
+
stateMutability: 'pure',
|
|
655
|
+
type: 'function',
|
|
656
|
+
},
|
|
657
|
+
];
|
|
658
|
+
const tickSpacing = await readContract({
|
|
659
|
+
address: poolAddress,
|
|
660
|
+
abi: tickSpacingAbi,
|
|
661
|
+
currentExecutionContext,
|
|
662
|
+
functionName: 'tickSpacing',
|
|
663
|
+
provider,
|
|
664
|
+
rpc,
|
|
665
|
+
chainId: this.chainId,
|
|
666
|
+
});
|
|
667
|
+
return tickSpacing;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Converts a value to string, handling both native bigint and serialized bigint objects
|
|
671
|
+
* from the centralized API
|
|
672
|
+
*/
|
|
673
|
+
convertToString(value) {
|
|
674
|
+
if (typeof value === 'bigint') {
|
|
675
|
+
return value.toString();
|
|
676
|
+
}
|
|
677
|
+
if (typeof value === 'number') {
|
|
678
|
+
return value.toString();
|
|
679
|
+
}
|
|
680
|
+
if (typeof value === 'string') {
|
|
681
|
+
return value;
|
|
682
|
+
}
|
|
683
|
+
// Handle serialized bigint from centralized API (e.g., { type: 'BigNumber', hex: '0x...' })
|
|
684
|
+
if (value && typeof value === 'object') {
|
|
685
|
+
// If it's a BigNumber-like object with hex property
|
|
686
|
+
if (value.hex !== undefined) {
|
|
687
|
+
return BigInt(value.hex).toString();
|
|
688
|
+
}
|
|
689
|
+
// If it has a _hex property (ethers v5 BigNumber)
|
|
690
|
+
if (value._hex !== undefined) {
|
|
691
|
+
return BigInt(value._hex).toString();
|
|
692
|
+
}
|
|
693
|
+
// If it has toString method, try using it
|
|
694
|
+
if (typeof value.toString === 'function' && value.toString() !== '[object Object]') {
|
|
695
|
+
return value.toString();
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
// Fallback: convert to string (may result in '[object Object]' if not handled above)
|
|
699
|
+
return String(value);
|
|
700
|
+
}
|
|
701
|
+
async getTotalAmounts(vaultAddress, currentExecutionContext, provider, rpc) {
|
|
702
|
+
const getTotalAmountsABI = [
|
|
703
|
+
{
|
|
704
|
+
inputs: [],
|
|
705
|
+
name: 'getTotalAmounts',
|
|
706
|
+
outputs: [
|
|
707
|
+
{ internalType: 'uint256', name: 'total0', type: 'uint256' },
|
|
708
|
+
{ internalType: 'uint256', name: 'total1', type: 'uint256' },
|
|
709
|
+
],
|
|
710
|
+
stateMutability: 'view',
|
|
711
|
+
type: 'function',
|
|
712
|
+
},
|
|
713
|
+
];
|
|
714
|
+
const totalAmounts = await readContract({
|
|
715
|
+
address: vaultAddress,
|
|
716
|
+
abi: getTotalAmountsABI,
|
|
717
|
+
currentExecutionContext,
|
|
718
|
+
functionName: 'getTotalAmounts',
|
|
719
|
+
provider,
|
|
720
|
+
rpc,
|
|
721
|
+
chainId: this.chainId,
|
|
722
|
+
});
|
|
723
|
+
return {
|
|
724
|
+
total0: totalAmounts[0],
|
|
725
|
+
total1: totalAmounts[1],
|
|
726
|
+
};
|
|
727
|
+
}
|
|
286
728
|
async getVaultPoolAddress() {
|
|
287
729
|
const requestSnapshot = {
|
|
288
730
|
method: 'POST',
|
|
@@ -297,6 +739,12 @@ export class ExecutionApp extends ExecutionBase {
|
|
|
297
739
|
}
|
|
298
740
|
`,
|
|
299
741
|
},
|
|
742
|
+
headers: {
|
|
743
|
+
'Content-Type': !this.steerSubgraph.includes('subgraph-proxy-server')
|
|
744
|
+
? 'application/json'
|
|
745
|
+
: 'text/plain;charset=UTF-8',
|
|
746
|
+
...(this.steerSubgraph.includes('sentio') ? { 'api-key': this.sentioApiKey } : {}),
|
|
747
|
+
},
|
|
300
748
|
};
|
|
301
749
|
const response = await fetchData(requestSnapshot, 4);
|
|
302
750
|
return response.data.vault.pool;
|