From b0d3e1578c5845b51f64f212d10674decade286a Mon Sep 17 00:00:00 2001 From: ulydev Date: Wed, 1 Oct 2025 15:39:37 +0200 Subject: [PATCH 1/5] feat: add spectra on katana --- dexs/spectra-v2.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/dexs/spectra-v2.ts b/dexs/spectra-v2.ts index a9bb619140..3d0014845c 100644 --- a/dexs/spectra-v2.ts +++ b/dexs/spectra-v2.ts @@ -83,9 +83,7 @@ const chains: { start: "2024-07-01", protocolSubgraphUrl: "https://subgraph.satsuma-prod.com/957f3120c2b2/perspective/spectra-base/api", - blacklistPools: [ - '0x447d24edf78b20a4cf748a7cee273510edf87df1', - ], + blacklistPools: ["0x447d24edf78b20a4cf748a7cee273510edf87df1"], }, [CHAIN.SONIC]: { id: 146, @@ -118,6 +116,13 @@ const chains: { "https://api.goldsky.com/api/public/project_cm55feuq3euos01xjb3w504ls/subgraphs/spectra-hyperevm/1.2.1/gn", limit: 1000, }, + [CHAIN.KATANA]: { + id: 747474, + start: "2025-07-02", + protocolSubgraphUrl: + "https://api.studio.thegraph.com/query/17172/spectra-katana/version/latest", + limit: 1000, + }, }; type Address = `0x${string}`; @@ -168,8 +173,13 @@ const fetchDailyFeesAndVolume = async ({ ).transactions as Transaction[]; dailyData.forEach((transaction) => { - if (chains[chain].blacklistPools && (new Set(chains[chain].blacklistPools)).has(transaction.poolInTransaction.id)) { - return + if ( + chains[chain].blacklistPools && + new Set(chains[chain].blacklistPools).has( + transaction.poolInTransaction.id + ) + ) { + return; } dailyFees.add( From ccc249f468f51c544e33c4f1fa0548c1710c1801 Mon Sep 17 00:00:00 2001 From: Eden Date: Wed, 1 Oct 2025 23:38:23 +0700 Subject: [PATCH 2/5] refactor --- dexs/spectra-v2.ts | 69 ++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 52 deletions(-) diff --git a/dexs/spectra-v2.ts b/dexs/spectra-v2.ts index 3d0014845c..5cc29c49ac 100644 --- a/dexs/spectra-v2.ts +++ b/dexs/spectra-v2.ts @@ -1,4 +1,4 @@ -import { FetchOptions, FetchV2, SimpleAdapter } from "../adapters/types"; +import { BaseAdapterChainConfig, FetchOptions, FetchV2, SimpleAdapter } from "../adapters/types"; import { CHAIN } from "../helpers/chains"; import BigNumber from "bignumber.js"; import { gql, GraphQLClient } from "graphql-request"; @@ -116,13 +116,13 @@ const chains: { "https://api.goldsky.com/api/public/project_cm55feuq3euos01xjb3w504ls/subgraphs/spectra-hyperevm/1.2.1/gn", limit: 1000, }, - [CHAIN.KATANA]: { - id: 747474, - start: "2025-07-02", - protocolSubgraphUrl: - "https://api.studio.thegraph.com/query/17172/spectra-katana/version/latest", - limit: 1000, - }, + // [CHAIN.KATANA]: { + // id: 747474, + // start: "2025-07-02", + // protocolSubgraphUrl: + // "https://api.studio.thegraph.com/query/17172/spectra-katana/version/latest", + // limit: 1000, + // }, }; type Address = `0x${string}`; @@ -173,12 +173,7 @@ const fetchDailyFeesAndVolume = async ({ ).transactions as Transaction[]; dailyData.forEach((transaction) => { - if ( - chains[chain].blacklistPools && - new Set(chains[chain].blacklistPools).has( - transaction.poolInTransaction.id - ) - ) { + if (chains[chain].blacklistPools && new Set(chains[chain].blacklistPools).has(transaction.poolInTransaction.id)) { return; } @@ -263,44 +258,14 @@ const methodology = { const adapter: SimpleAdapter = { version: 2, methodology, - adapter: { - [CHAIN.ETHEREUM]: { - fetch, - start: "2024-07-01", - }, - [CHAIN.ARBITRUM]: { - fetch, - start: "2024-07-01", - }, - [CHAIN.OPTIMISM]: { - fetch, - start: "2024-07-01", - }, - [CHAIN.BASE]: { - fetch, - start: "2024-07-01", - }, - [CHAIN.SONIC]: { - fetch, - start: "2024-12-27", - }, - [CHAIN.HEMI]: { - fetch, - start: "2025-03-06", - }, - [CHAIN.AVAX]: { - fetch, - start: "2025-05-26", - }, - [CHAIN.BSC]: { - fetch, - start: "2025-05-26", - }, - [CHAIN.HYPERLIQUID]: { - fetch, - start: "2025-06-01", - }, - }, + adapter: {}, }; +for (const [chain, config] of Object.entries(chains)) { + (adapter.adapter as any)[chain] = { + fetch, + start: config.start, + } +} + export default adapter; From 11d0f71bf5aafe6432eba40ed89a9dc001f744cc Mon Sep 17 00:00:00 2001 From: ulydev Date: Wed, 1 Oct 2025 18:51:05 +0200 Subject: [PATCH 3/5] chore: replace katana public subgraph --- dexs/spectra-v2.ts | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/dexs/spectra-v2.ts b/dexs/spectra-v2.ts index 5cc29c49ac..b5fd86791b 100644 --- a/dexs/spectra-v2.ts +++ b/dexs/spectra-v2.ts @@ -1,4 +1,5 @@ -import { BaseAdapterChainConfig, FetchOptions, FetchV2, SimpleAdapter } from "../adapters/types"; +import * as sdk from "@defillama/sdk"; +import { FetchOptions, FetchV2, SimpleAdapter } from "../adapters/types"; import { CHAIN } from "../helpers/chains"; import BigNumber from "bignumber.js"; import { gql, GraphQLClient } from "graphql-request"; @@ -116,13 +117,14 @@ const chains: { "https://api.goldsky.com/api/public/project_cm55feuq3euos01xjb3w504ls/subgraphs/spectra-hyperevm/1.2.1/gn", limit: 1000, }, - // [CHAIN.KATANA]: { - // id: 747474, - // start: "2025-07-02", - // protocolSubgraphUrl: - // "https://api.studio.thegraph.com/query/17172/spectra-katana/version/latest", - // limit: 1000, - // }, + [CHAIN.KATANA]: { + id: 747474, + start: "2025-07-02", + protocolSubgraphUrl: sdk.graph.modifyEndpoint( + "FFz8eoWmY2G8ntMnhHZqeAu71CEpstm7wVZbhyMh7GNa" + ), + limit: 1000, + }, }; type Address = `0x${string}`; @@ -173,7 +175,12 @@ const fetchDailyFeesAndVolume = async ({ ).transactions as Transaction[]; dailyData.forEach((transaction) => { - if (chains[chain].blacklistPools && new Set(chains[chain].blacklistPools).has(transaction.poolInTransaction.id)) { + if ( + chains[chain].blacklistPools && + new Set(chains[chain].blacklistPools).has( + transaction.poolInTransaction.id + ) + ) { return; } @@ -265,7 +272,7 @@ for (const [chain, config] of Object.entries(chains)) { (adapter.adapter as any)[chain] = { fetch, start: config.start, - } + }; } export default adapter; From 3da44cd698c1a7b0ef2371f17b672bcecf0c01ac Mon Sep 17 00:00:00 2001 From: Eden Date: Thu, 2 Oct 2025 00:24:39 +0700 Subject: [PATCH 4/5] refactor --- dexs/spectra-v2.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/dexs/spectra-v2.ts b/dexs/spectra-v2.ts index b5fd86791b..0dfed46438 100644 --- a/dexs/spectra-v2.ts +++ b/dexs/spectra-v2.ts @@ -120,9 +120,7 @@ const chains: { [CHAIN.KATANA]: { id: 747474, start: "2025-07-02", - protocolSubgraphUrl: sdk.graph.modifyEndpoint( - "FFz8eoWmY2G8ntMnhHZqeAu71CEpstm7wVZbhyMh7GNa" - ), + protocolSubgraphUrl: sdk.graph.modifyEndpoint("FFz8eoWmY2G8ntMnhHZqeAu71CEpstm7wVZbhyMh7GNa"), limit: 1000, }, }; @@ -175,12 +173,7 @@ const fetchDailyFeesAndVolume = async ({ ).transactions as Transaction[]; dailyData.forEach((transaction) => { - if ( - chains[chain].blacklistPools && - new Set(chains[chain].blacklistPools).has( - transaction.poolInTransaction.id - ) - ) { + if (chains[chain].blacklistPools && new Set(chains[chain].blacklistPools).has(transaction.poolInTransaction.id)) { return; } @@ -216,9 +209,8 @@ const fetchDailyHoldersRevenue = async ({ // Count both reward types (voting incentives + fees) separately dailyData.forEach((reward) => { - if ( - reward.distributor.governancePool.chainId === chains[chain].id.toString() // Only count rewards for pools on the current chain - ) { + // Only count rewards for pools on the current chain + if (reward.distributor.governancePool.chainId === chains[chain].id.toString()) { if (reward.distributor.type === "FEE") { dailyVotingFeesRevenue.add(reward.address, reward.amount.toString()); } else { @@ -239,8 +231,7 @@ const fetch: FetchV2 = async (options) => { const dailyRevenue = dailyFees.clone(0.8); const dailySupplySideRevenue = dailyFees.clone(0.2); - const [dailyVotingFeesRevenue, dailyVotingIncentivesRevenue] = - await fetchDailyHoldersRevenue(options); + const [dailyVotingFeesRevenue, dailyVotingIncentivesRevenue] = await fetchDailyHoldersRevenue(options); return { dailyVolume, From 68773bf3dbd7ad0c0ebe350a692075fcde2d8fad Mon Sep 17 00:00:00 2001 From: ulydev Date: Wed, 22 Oct 2025 13:58:10 +0200 Subject: [PATCH 5/5] fix: wrong subgraph --- dexs/spectra-v2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dexs/spectra-v2.ts b/dexs/spectra-v2.ts index b5fd86791b..5d29c27898 100644 --- a/dexs/spectra-v2.ts +++ b/dexs/spectra-v2.ts @@ -121,7 +121,7 @@ const chains: { id: 747474, start: "2025-07-02", protocolSubgraphUrl: sdk.graph.modifyEndpoint( - "FFz8eoWmY2G8ntMnhHZqeAu71CEpstm7wVZbhyMh7GNa" + "EM1PDEWqo1BWaLEW5FotmHtVK1HX8z7eFnLVfDRLjfQh" ), limit: 1000, },