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