@steerprotocol/sdk 3.5.0 → 3.6.0

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.
@@ -16376,6 +16376,47 @@ const FIND_ALL_VAULTS_BY_PROTOCOL = (batchSize = 1e3, timestamp, beaconNames) =>
16376
16376
  }
16377
16377
  }`;
16378
16378
  };
16379
+ const FIND_VAULT_BY_ADDRESS = (vaultAddress) => `query {
16380
+ vaults(first: 1, where: { id: "${vaultAddress}" }) {
16381
+ id
16382
+ name
16383
+ token0
16384
+ token1
16385
+ pool
16386
+ weeklyFeeAPR
16387
+ token0Symbol
16388
+ token0Decimals
16389
+ token1Symbol
16390
+ token1Decimals
16391
+ totalValueLockedToken0
16392
+ totalValueLockedToken1
16393
+ token0Balance
16394
+ token1Balance
16395
+ totalLPTokensIssued
16396
+ createdAt
16397
+ feeTier
16398
+ strategyToken {
16399
+ id
16400
+ name
16401
+ creator {
16402
+ id
16403
+ }
16404
+ admin
16405
+ executionBundle
16406
+ }
16407
+ positions(first: 1, orderBy: timestamp, orderDirection: desc) {
16408
+ id
16409
+ upperTick
16410
+ lowerTick
16411
+ relativeWeight
16412
+ }
16413
+ fees0
16414
+ fees1
16415
+ beaconName
16416
+ payloadIpfs
16417
+ deployer
16418
+ }
16419
+ }`;
16379
16420
  /**
16380
16421
  * Utility class for fetching vault data from Steer subgraphs
16381
16422
  */
@@ -16506,6 +16547,29 @@ var SubgraphVaultClient = class {
16506
16547
  };
16507
16548
  }
16508
16549
  /**
16550
+ * Fetches one vault by its address without enumerating the chain's vault set.
16551
+ */
16552
+ async getVaultByAddress(options) {
16553
+ const { subgraphUrl, chainId, vaultAddress } = options;
16554
+ if (!vaultAddress) throw new Error("vaultAddress is required for an address lookup");
16555
+ const vault = (await (await fetch(subgraphUrl, {
16556
+ method: "POST",
16557
+ headers: {
16558
+ "Content-Type": "application/json",
16559
+ ...subgraphUrl.includes("sentio") && this.SENTIO_API_KEY ? { "api-key": this.SENTIO_API_KEY } : {}
16560
+ },
16561
+ body: JSON.stringify({
16562
+ query: FIND_VAULT_BY_ADDRESS(vaultAddress.toLowerCase()),
16563
+ variables: {}
16564
+ })
16565
+ })).json())?.data?.vaults?.[0];
16566
+ if (!vault) return null;
16567
+ return this.transformSubgraphVaultToVaultNode({
16568
+ ...vault,
16569
+ lpPriceData: this.createMockLpPriceData(vault)
16570
+ }, chainId, /* @__PURE__ */ new Map());
16571
+ }
16572
+ /**
16509
16573
  * Fetch vault data from subgraph
16510
16574
  */
16511
16575
  async getAllVaultsFromSubgraph(options) {
@@ -20489,6 +20553,45 @@ var VaultClient = class extends SubgraphClient {
20489
20553
  }
20490
20554
  return apiFilter;
20491
20555
  }
20556
+ transformApiVaultNode(vault) {
20557
+ return {
20558
+ id: vault.id,
20559
+ chainId: vault.chainId,
20560
+ vaultAddress: vault.vaultAddress,
20561
+ protocol: vault.protocol,
20562
+ beaconName: vault.beaconName,
20563
+ protocolBaseType: vault.protocolBaseType,
20564
+ name: vault.name || "",
20565
+ feeApr: vault.feeApr || void 0,
20566
+ stakingApr: vault.stakingApr || void 0,
20567
+ merklApr: vault.merklApr || void 0,
20568
+ pool: {
20569
+ id: vault.pool?.id || "",
20570
+ poolAddress: vault.pool?.poolAddress || "",
20571
+ feeTier: vault.pool?.feeTier || "",
20572
+ tick: void 0,
20573
+ liquidity: void 0,
20574
+ volumeUSD: void 0,
20575
+ totalValueLockedUSD: void 0
20576
+ },
20577
+ token0: {
20578
+ id: vault.token0?.id || "",
20579
+ symbol: vault.token0?.symbol || "",
20580
+ name: vault.token0?.name || "",
20581
+ decimals: vault.token0?.decimals || 0,
20582
+ address: vault.token0?.address || "",
20583
+ chainId: vault.token0?.chainId || 0
20584
+ },
20585
+ token1: {
20586
+ id: vault.token1?.id || "",
20587
+ symbol: vault.token1?.symbol || "",
20588
+ name: vault.token1?.name || "",
20589
+ decimals: vault.token1?.decimals || 0,
20590
+ address: vault.token1?.address || "",
20591
+ chainId: vault.token1?.chainId || 0
20592
+ }
20593
+ };
20594
+ }
20492
20595
  vaultMatchesProtocolFilter(vault, protocolFilter, resolvedProtocol) {
20493
20596
  const normalizedFilter = this.normalizeProtocolValue(protocolFilter);
20494
20597
  const normalizedBeaconName = this.normalizeProtocolValue(vault.beaconName);
@@ -20672,43 +20775,7 @@ var VaultClient = class extends SubgraphClient {
20672
20775
  data: {
20673
20776
  edges: response.data.vaults.edges.map((edge) => ({
20674
20777
  cursor: edge.cursor,
20675
- node: {
20676
- id: edge.node.id,
20677
- chainId: edge.node.chainId,
20678
- vaultAddress: edge.node.vaultAddress,
20679
- protocol: edge.node.protocol,
20680
- beaconName: edge.node.beaconName,
20681
- protocolBaseType: edge.node.protocolBaseType,
20682
- name: edge.node.name || "",
20683
- feeApr: edge.node.feeApr || void 0,
20684
- stakingApr: edge.node.stakingApr || void 0,
20685
- merklApr: edge.node.merklApr || void 0,
20686
- pool: {
20687
- id: edge.node.pool?.id || "",
20688
- poolAddress: edge.node.pool?.poolAddress || "",
20689
- feeTier: edge.node.pool?.feeTier || "",
20690
- tick: void 0,
20691
- liquidity: void 0,
20692
- volumeUSD: void 0,
20693
- totalValueLockedUSD: void 0
20694
- },
20695
- token0: {
20696
- id: edge.node.token0?.id || "",
20697
- symbol: edge.node.token0?.symbol || "",
20698
- name: edge.node.token0?.name || "",
20699
- decimals: edge.node.token0?.decimals || 0,
20700
- address: edge.node.token0?.address || "",
20701
- chainId: edge.node.token0?.chainId || 0
20702
- },
20703
- token1: {
20704
- id: edge.node.token1?.id || "",
20705
- symbol: edge.node.token1?.symbol || "",
20706
- name: edge.node.token1?.name || "",
20707
- decimals: edge.node.token1?.decimals || 0,
20708
- address: edge.node.token1?.address || "",
20709
- chainId: edge.node.token1?.chainId || 0
20710
- }
20711
- }
20778
+ node: this.transformApiVaultNode(edge.node)
20712
20779
  })),
20713
20780
  pageInfo: {
20714
20781
  hasNextPage: response.data.vaults.pageInfo.hasNextPage,
@@ -21245,21 +21312,62 @@ var VaultClient = class extends SubgraphClient {
21245
21312
  };
21246
21313
  }
21247
21314
  async getVaultByAddress(vaultAddress, filter) {
21248
- const response = await this.searchVaults({
21249
- ...filter,
21250
- vaultAddress
21251
- });
21252
- if (!response.success || !response.data) return {
21315
+ const chainId = filter?.chainId;
21316
+ const normalizedVaultAddress = this.normalizeAddress(vaultAddress);
21317
+ if (!chainId) return {
21253
21318
  data: null,
21254
- status: response.status,
21255
- success: response.success,
21256
- error: response.error
21319
+ status: 400,
21320
+ success: false,
21321
+ error: "chainId is required for a direct vault address lookup"
21257
21322
  };
21258
- return {
21259
- data: response.data[0] || null,
21260
- status: 200,
21261
- success: true
21323
+ if (!normalizedVaultAddress || !isAddress(vaultAddress)) return {
21324
+ data: null,
21325
+ status: 400,
21326
+ success: false,
21327
+ error: "vaultAddress must be a valid EVM address"
21262
21328
  };
21329
+ try {
21330
+ const chain = chainIdToName(chainId);
21331
+ const subgraphUrl = chain ? steerSubgraphConfig[chain] : void 0;
21332
+ if (!subgraphUrl) throw new Error(`No subgraph configured for chainId: ${chainId}`);
21333
+ const node = await this.subgraphVaultClient.getVaultByAddress({
21334
+ subgraphUrl,
21335
+ chainId,
21336
+ vaultAddress: normalizedVaultAddress
21337
+ });
21338
+ return {
21339
+ data: node ? this.filterVaultNodes([node], {
21340
+ ...filter,
21341
+ vaultAddress: normalizedVaultAddress
21342
+ })[0] || null : null,
21343
+ status: 200,
21344
+ success: true
21345
+ };
21346
+ } catch (error) {
21347
+ console.warn("Direct subgraph vault lookup failed, falling back to the API:", error);
21348
+ }
21349
+ try {
21350
+ const response = await this.apiClient.vault({
21351
+ id: normalizedVaultAddress,
21352
+ chainId
21353
+ });
21354
+ const vault = response.data?.vault;
21355
+ return {
21356
+ data: vault ? this.filterVaultNodes([this.transformApiVaultNode(vault)], {
21357
+ ...filter,
21358
+ vaultAddress: normalizedVaultAddress
21359
+ })[0] || null : null,
21360
+ status: response.status,
21361
+ success: true
21362
+ };
21363
+ } catch (error) {
21364
+ return {
21365
+ data: null,
21366
+ status: 500,
21367
+ success: false,
21368
+ error: error instanceof Error ? error.message : "Direct vault lookup failed"
21369
+ };
21370
+ }
21263
21371
  }
21264
21372
  async getVaultsForPool(poolAddress, filter) {
21265
21373
  return this.searchVaults({