@steerprotocol/sdk 1.29.3 → 1.30.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.
- package/dist/cjs/base/VaultClient.js +459 -78
- package/dist/cjs/base/VaultClient.js.map +1 -1
- package/dist/cjs/utils/SubgraphVaultClient.js +80 -6
- package/dist/cjs/utils/SubgraphVaultClient.js.map +1 -1
- package/dist/cjs/utils/subgraph-types.js.map +1 -1
- package/dist/esm/base/VaultClient.js +460 -79
- package/dist/esm/base/VaultClient.js.map +1 -1
- package/dist/esm/utils/SubgraphVaultClient.js +80 -6
- package/dist/esm/utils/SubgraphVaultClient.js.map +1 -1
- package/dist/esm/utils/subgraph-types.js.map +1 -1
- package/dist/types/base/VaultClient.d.ts +60 -1
- package/dist/types/base/VaultClient.d.ts.map +1 -1
- package/dist/types/utils/SubgraphVaultClient.d.ts +6 -0
- package/dist/types/utils/SubgraphVaultClient.d.ts.map +1 -1
- package/dist/types/utils/subgraph-types.d.ts +9 -0
- package/dist/types/utils/subgraph-types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/base/VaultClient.protocol-filter.test.ts +179 -0
- package/src/__tests__/base/VaultClient.test.ts +4 -3
- package/src/base/VaultClient.ts +568 -83
- package/src/utils/SubgraphVaultClient.ts +88 -6
- package/src/utils/subgraph-types.ts +10 -0
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SubgraphResponse,
|
|
8
8
|
SubgraphVaultDetails,
|
|
9
9
|
SubgraphVaultDetailsWithLpData,
|
|
10
|
+
SubgraphVaultPosition,
|
|
10
11
|
VaultFetchOptions,
|
|
11
12
|
} from './subgraph-types';
|
|
12
13
|
|
|
@@ -43,6 +44,14 @@ const FIND_ALL_VAULTS = (batchSize: number = 1000, timestamp?: string) => {
|
|
|
43
44
|
admin
|
|
44
45
|
executionBundle
|
|
45
46
|
}
|
|
47
|
+
positions(first: 1, orderBy: timestamp, orderDirection: desc) {
|
|
48
|
+
id
|
|
49
|
+
upperTick
|
|
50
|
+
lowerTick
|
|
51
|
+
relativeWeight
|
|
52
|
+
}
|
|
53
|
+
fees0
|
|
54
|
+
fees1
|
|
46
55
|
beaconName
|
|
47
56
|
payloadIpfs
|
|
48
57
|
deployer
|
|
@@ -78,6 +87,14 @@ const FIND_ALL_VAULTS = (batchSize: number = 1000, timestamp?: string) => {
|
|
|
78
87
|
admin
|
|
79
88
|
executionBundle
|
|
80
89
|
}
|
|
90
|
+
positions(first: 1, orderBy: timestamp, orderDirection: desc) {
|
|
91
|
+
id
|
|
92
|
+
upperTick
|
|
93
|
+
lowerTick
|
|
94
|
+
relativeWeight
|
|
95
|
+
}
|
|
96
|
+
fees0
|
|
97
|
+
fees1
|
|
81
98
|
beaconName
|
|
82
99
|
payloadIpfs
|
|
83
100
|
deployer
|
|
@@ -118,6 +135,14 @@ const FIND_ALL_VAULTS_BY_PROTOCOL = (
|
|
|
118
135
|
totalLPTokensIssued
|
|
119
136
|
createdAt
|
|
120
137
|
feeTier
|
|
138
|
+
positions(first: 1, orderBy: timestamp, orderDirection: desc) {
|
|
139
|
+
id
|
|
140
|
+
upperTick
|
|
141
|
+
lowerTick
|
|
142
|
+
relativeWeight
|
|
143
|
+
}
|
|
144
|
+
fees0
|
|
145
|
+
fees1
|
|
121
146
|
strategyToken {
|
|
122
147
|
id
|
|
123
148
|
name
|
|
@@ -162,6 +187,14 @@ const FIND_ALL_VAULTS_BY_PROTOCOL = (
|
|
|
162
187
|
admin
|
|
163
188
|
executionBundle
|
|
164
189
|
}
|
|
190
|
+
positions(first: 1, orderBy: timestamp, orderDirection: desc) {
|
|
191
|
+
id
|
|
192
|
+
upperTick
|
|
193
|
+
lowerTick
|
|
194
|
+
relativeWeight
|
|
195
|
+
}
|
|
196
|
+
fees0
|
|
197
|
+
fees1
|
|
165
198
|
beaconName
|
|
166
199
|
payloadIpfs
|
|
167
200
|
deployer
|
|
@@ -184,8 +217,10 @@ export class SubgraphVaultClient {
|
|
|
184
217
|
chainId: number,
|
|
185
218
|
aprMap: Map<string, number>
|
|
186
219
|
): VaultNode {
|
|
187
|
-
// Get the chain enum from chainId
|
|
188
220
|
const feeApr = aprMap.get(vault.id) ? aprMap.get(vault.id) : undefined;
|
|
221
|
+
|
|
222
|
+
const tickRange = this.computeTickRange(vault.positions ?? []);
|
|
223
|
+
|
|
189
224
|
return {
|
|
190
225
|
id: vault.id,
|
|
191
226
|
chainId,
|
|
@@ -195,8 +230,19 @@ export class SubgraphVaultClient {
|
|
|
195
230
|
protocolBaseType: this.getProtocolBaseType(vault.beaconName),
|
|
196
231
|
name: vault.name || '',
|
|
197
232
|
feeApr: feeApr ? parseFloat(feeApr.toString()) : undefined,
|
|
198
|
-
stakingApr: undefined,
|
|
199
|
-
merklApr: undefined,
|
|
233
|
+
stakingApr: undefined,
|
|
234
|
+
merklApr: undefined,
|
|
235
|
+
positions: (vault.positions ?? []).map((p) => ({
|
|
236
|
+
id: p.id,
|
|
237
|
+
upperTick: parseInt(p.upperTick, 10),
|
|
238
|
+
lowerTick: parseInt(p.lowerTick, 10),
|
|
239
|
+
relativeWeight: p.relativeWeight,
|
|
240
|
+
})),
|
|
241
|
+
tickRange,
|
|
242
|
+
fees:
|
|
243
|
+
vault.fees0 !== undefined && vault.fees1 !== undefined
|
|
244
|
+
? { fees0: vault.fees0, fees1: vault.fees1 }
|
|
245
|
+
: undefined,
|
|
200
246
|
pool: {
|
|
201
247
|
id: vault.pool,
|
|
202
248
|
poolAddress: vault.pool,
|
|
@@ -209,7 +255,7 @@ export class SubgraphVaultClient {
|
|
|
209
255
|
token0: {
|
|
210
256
|
id: vault.token0,
|
|
211
257
|
symbol: vault.token0Symbol,
|
|
212
|
-
name: vault.token0Symbol,
|
|
258
|
+
name: vault.token0Symbol,
|
|
213
259
|
decimals: parseInt(vault.token0Decimals),
|
|
214
260
|
address: vault.token0,
|
|
215
261
|
chainId,
|
|
@@ -217,7 +263,7 @@ export class SubgraphVaultClient {
|
|
|
217
263
|
token1: {
|
|
218
264
|
id: vault.token1,
|
|
219
265
|
symbol: vault.token1Symbol,
|
|
220
|
-
name: vault.token1Symbol,
|
|
266
|
+
name: vault.token1Symbol,
|
|
221
267
|
decimals: parseInt(vault.token1Decimals),
|
|
222
268
|
address: vault.token1,
|
|
223
269
|
chainId,
|
|
@@ -225,6 +271,31 @@ export class SubgraphVaultClient {
|
|
|
225
271
|
};
|
|
226
272
|
}
|
|
227
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Compute the tick range across all vault positions.
|
|
276
|
+
* Returns the minimum lowerTick and maximum upperTick, giving the full
|
|
277
|
+
* span of liquidity currently deployed by the vault strategy.
|
|
278
|
+
*/
|
|
279
|
+
private computeTickRange(
|
|
280
|
+
positions: SubgraphVaultPosition[]
|
|
281
|
+
): VaultNode['tickRange'] {
|
|
282
|
+
if (!positions.length) return undefined;
|
|
283
|
+
|
|
284
|
+
let minLowerTick = Infinity;
|
|
285
|
+
let maxUpperTick = -Infinity;
|
|
286
|
+
|
|
287
|
+
for (const pos of positions) {
|
|
288
|
+
const lower = parseInt(pos.lowerTick, 10);
|
|
289
|
+
const upper = parseInt(pos.upperTick, 10);
|
|
290
|
+
if (!isNaN(lower) && lower < minLowerTick) minLowerTick = lower;
|
|
291
|
+
if (!isNaN(upper) && upper > maxUpperTick) maxUpperTick = upper;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (minLowerTick === Infinity || maxUpperTick === -Infinity) return undefined;
|
|
295
|
+
|
|
296
|
+
return { minLowerTick, maxUpperTick };
|
|
297
|
+
}
|
|
298
|
+
|
|
228
299
|
/**
|
|
229
300
|
* Get protocol base type from beacon name
|
|
230
301
|
*/
|
|
@@ -311,6 +382,10 @@ export class SubgraphVaultClient {
|
|
|
311
382
|
await latestVaultResponse.json();
|
|
312
383
|
let lastTimestamp = latestVaultData?.data?.vaults?.[0]?.createdAt;
|
|
313
384
|
|
|
385
|
+
if (!lastTimestamp) {
|
|
386
|
+
return [];
|
|
387
|
+
}
|
|
388
|
+
|
|
314
389
|
let hasMoreData = true;
|
|
315
390
|
while (hasMoreData) {
|
|
316
391
|
const response = await fetch(subgraphUrl, {
|
|
@@ -334,6 +409,7 @@ export class SubgraphVaultClient {
|
|
|
334
409
|
|
|
335
410
|
if (!vaults.length) {
|
|
336
411
|
hasMoreData = false;
|
|
412
|
+
continue;
|
|
337
413
|
}
|
|
338
414
|
|
|
339
415
|
// Filter out duplicates based on vault ID
|
|
@@ -343,6 +419,7 @@ export class SubgraphVaultClient {
|
|
|
343
419
|
|
|
344
420
|
if (!newVaults.length) {
|
|
345
421
|
hasMoreData = false;
|
|
422
|
+
continue;
|
|
346
423
|
}
|
|
347
424
|
|
|
348
425
|
// For now, attach mock LP data to each vault
|
|
@@ -353,7 +430,12 @@ export class SubgraphVaultClient {
|
|
|
353
430
|
}));
|
|
354
431
|
|
|
355
432
|
allVaults.push(...vaultsWithLpData);
|
|
356
|
-
|
|
433
|
+
const lastVaultTimestamp = vaults[vaults.length - 1]?.createdAt;
|
|
434
|
+
if (!lastVaultTimestamp) {
|
|
435
|
+
hasMoreData = false;
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
lastTimestamp = lastVaultTimestamp;
|
|
357
439
|
}
|
|
358
440
|
|
|
359
441
|
// Filter deprecated vaults if needed
|
|
@@ -4,6 +4,13 @@ import { Address } from 'viem';
|
|
|
4
4
|
* Types for Steer subgraph responses
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
export interface SubgraphVaultPosition {
|
|
8
|
+
id: string;
|
|
9
|
+
upperTick: string;
|
|
10
|
+
lowerTick: string;
|
|
11
|
+
relativeWeight: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
export interface SubgraphVaultDetails {
|
|
8
15
|
id: string;
|
|
9
16
|
name: string;
|
|
@@ -31,6 +38,9 @@ export interface SubgraphVaultDetails {
|
|
|
31
38
|
admin: string;
|
|
32
39
|
executionBundle: string;
|
|
33
40
|
};
|
|
41
|
+
positions: SubgraphVaultPosition[];
|
|
42
|
+
fees0: string;
|
|
43
|
+
fees1: string;
|
|
34
44
|
beaconName: string;
|
|
35
45
|
payloadIpfs: string;
|
|
36
46
|
deployer: string;
|