From 1d182c0e3d7d9d7d3b1b621160ed6aa61a9da50b Mon Sep 17 00:00:00 2001 From: Zeke Date: Thu, 16 Jan 2025 14:43:59 +0800 Subject: [PATCH 1/5] feat : added the Starbase project --- aggregators/7k-aggregator/index.ts | 59 +++++++++++++++++++++++------- aggregators/starbase/index.ts | 39 ++++++++++++++++++++ helpers/env.ts | 1 + 3 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 aggregators/starbase/index.ts diff --git a/aggregators/7k-aggregator/index.ts b/aggregators/7k-aggregator/index.ts index 8a56bdd9d0..847f18b248 100644 --- a/aggregators/7k-aggregator/index.ts +++ b/aggregators/7k-aggregator/index.ts @@ -2,23 +2,54 @@ import fetchURL from '../../utils/fetchURL'; import { FetchV2, SimpleAdapter } from '../../adapters/types'; import { CHAIN } from '../../helpers/chains'; -const URL = 'https://statistic.7k.ag'; +import { FetchResult } from "../../adapters/types"; -const fetch: FetchV2 = async ({ fromTimestamp, toTimestamp }) => { - const dailyVolume = await fetchURL( - `${URL}/volume-with-ts?from_timestamp=${fromTimestamp}&to_timestamp=${toTimestamp}`, - ); - return { dailyVolume }; +const fetch = async (chain: string): Promise => { + try { + // 根据链选择相应的接口 + const url = `http://starbase/data/get?chain=${chain}`; + const response = await fetch(url); + const data = await response.json(); + + // 假设返回的数据结构如下: + // { + // '1d_change': 5.2, + // '7d_change': 12.3, + // 'volume_24h': 1000000, + // 'volume_7d': 7000000 + // } + + return { + dailyVolume: data.volume_24h, + timestamp: Math.floor(Date.now() / 1000), // 当前时间的 Unix 时间戳 + }; + } catch (error) { + console.error('获取数据失败:', error); + throw new Error('获取数据失败'); + } }; -const adapter: SimpleAdapter = { - version: 2, - adapter: { - [CHAIN.SUI]: { - fetch, - start: '2024-06-28', - }, - }, +const adapter = { + timetravel: false, + adapter: { + [CHAIN.ETHEREUM]: { + fetch: fetch, + runAtCurrTime: true, + start: '2023-12-05', + }, + [CHAIN.BASE]: { + fetch: fetch, + runAtCurrTime: true, + start: '2023-12-05', + }, + [CHAIN.BSC]: { + fetch: fetch, + runAtCurrTime: true, + start: '2023-12-05', + }, + }, + isExpensiveAdapter: true, }; export default adapter; + diff --git a/aggregators/starbase/index.ts b/aggregators/starbase/index.ts new file mode 100644 index 0000000000..28a4726c6b --- /dev/null +++ b/aggregators/starbase/index.ts @@ -0,0 +1,39 @@ +import { CHAIN } from "../../helpers/chains"; +import { FetchOptions } from "../../adapters/types"; +import { getEnv } from "../../helpers/env"; +import axios from "axios"; + +type TChain = { + [key: string]: number; +}; +const CHAINS: TChain = { + [CHAIN.BASE]: 8453, +}; + +const fetch = async (_a, _b, options: FetchOptions) => { + const response = await axios.get(`https://api-analysis-dev.starbase.ag/api/combine/defillama/volume`, { + headers: { + "X-BYPASS-KEY": getEnv("STARBASE_API_KEY"), + } + }) + const data = response.data; + const negativeVolume = data.volume24h? - data.volume24h : undefined; + return { + dailyVolume: negativeVolume, + }; +}; + +const adapter: any = { + version: 1, + adapter: Object.keys(CHAINS).reduce((acc, chain) => { + return { + ...acc, + [chain]: { + fetch: fetch, + start: '2025-01-10', + }, + }; + }, {}), +}; + +export default adapter; diff --git a/helpers/env.ts b/helpers/env.ts index 696683b8cd..98c3f9f36d 100644 --- a/helpers/env.ts +++ b/helpers/env.ts @@ -33,6 +33,7 @@ export const ENV_KEYS = new Set([ 'ALCHEMIX_KEY', 'ALCHEMIX_SECRET', 'FLIPSIDE_RESTRICTED_MODE', + 'STARBASE_API_KEY', ]) // This is done to support both ZEROx_API_KEY and ZEROX_API_KEY From 0d377cdad29a9451443b0199d58e5dc53d1b5fcd Mon Sep 17 00:00:00 2001 From: Zeke Date: Thu, 16 Jan 2025 14:44:48 +0800 Subject: [PATCH 2/5] Revert "feat : added the Starbase project" This reverts commit 1d182c0e3d7d9d7d3b1b621160ed6aa61a9da50b. --- aggregators/7k-aggregator/index.ts | 59 +++++++----------------------- aggregators/starbase/index.ts | 39 -------------------- helpers/env.ts | 1 - 3 files changed, 14 insertions(+), 85 deletions(-) delete mode 100644 aggregators/starbase/index.ts diff --git a/aggregators/7k-aggregator/index.ts b/aggregators/7k-aggregator/index.ts index 847f18b248..8a56bdd9d0 100644 --- a/aggregators/7k-aggregator/index.ts +++ b/aggregators/7k-aggregator/index.ts @@ -2,54 +2,23 @@ import fetchURL from '../../utils/fetchURL'; import { FetchV2, SimpleAdapter } from '../../adapters/types'; import { CHAIN } from '../../helpers/chains'; -import { FetchResult } from "../../adapters/types"; +const URL = 'https://statistic.7k.ag'; -const fetch = async (chain: string): Promise => { - try { - // 根据链选择相应的接口 - const url = `http://starbase/data/get?chain=${chain}`; - const response = await fetch(url); - const data = await response.json(); - - // 假设返回的数据结构如下: - // { - // '1d_change': 5.2, - // '7d_change': 12.3, - // 'volume_24h': 1000000, - // 'volume_7d': 7000000 - // } - - return { - dailyVolume: data.volume_24h, - timestamp: Math.floor(Date.now() / 1000), // 当前时间的 Unix 时间戳 - }; - } catch (error) { - console.error('获取数据失败:', error); - throw new Error('获取数据失败'); - } +const fetch: FetchV2 = async ({ fromTimestamp, toTimestamp }) => { + const dailyVolume = await fetchURL( + `${URL}/volume-with-ts?from_timestamp=${fromTimestamp}&to_timestamp=${toTimestamp}`, + ); + return { dailyVolume }; }; -const adapter = { - timetravel: false, - adapter: { - [CHAIN.ETHEREUM]: { - fetch: fetch, - runAtCurrTime: true, - start: '2023-12-05', - }, - [CHAIN.BASE]: { - fetch: fetch, - runAtCurrTime: true, - start: '2023-12-05', - }, - [CHAIN.BSC]: { - fetch: fetch, - runAtCurrTime: true, - start: '2023-12-05', - }, - }, - isExpensiveAdapter: true, +const adapter: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.SUI]: { + fetch, + start: '2024-06-28', + }, + }, }; export default adapter; - diff --git a/aggregators/starbase/index.ts b/aggregators/starbase/index.ts deleted file mode 100644 index 28a4726c6b..0000000000 --- a/aggregators/starbase/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { CHAIN } from "../../helpers/chains"; -import { FetchOptions } from "../../adapters/types"; -import { getEnv } from "../../helpers/env"; -import axios from "axios"; - -type TChain = { - [key: string]: number; -}; -const CHAINS: TChain = { - [CHAIN.BASE]: 8453, -}; - -const fetch = async (_a, _b, options: FetchOptions) => { - const response = await axios.get(`https://api-analysis-dev.starbase.ag/api/combine/defillama/volume`, { - headers: { - "X-BYPASS-KEY": getEnv("STARBASE_API_KEY"), - } - }) - const data = response.data; - const negativeVolume = data.volume24h? - data.volume24h : undefined; - return { - dailyVolume: negativeVolume, - }; -}; - -const adapter: any = { - version: 1, - adapter: Object.keys(CHAINS).reduce((acc, chain) => { - return { - ...acc, - [chain]: { - fetch: fetch, - start: '2025-01-10', - }, - }; - }, {}), -}; - -export default adapter; diff --git a/helpers/env.ts b/helpers/env.ts index 98c3f9f36d..696683b8cd 100644 --- a/helpers/env.ts +++ b/helpers/env.ts @@ -33,7 +33,6 @@ export const ENV_KEYS = new Set([ 'ALCHEMIX_KEY', 'ALCHEMIX_SECRET', 'FLIPSIDE_RESTRICTED_MODE', - 'STARBASE_API_KEY', ]) // This is done to support both ZEROx_API_KEY and ZEROX_API_KEY From ab176d58dd517491e3193ec3cf16899fed7c76fc Mon Sep 17 00:00:00 2001 From: Zeke Date: Thu, 16 Jan 2025 14:47:59 +0800 Subject: [PATCH 3/5] feat : added the Starbase project --- aggregators/starbase/index.ts | 39 +++++++++++++++++++++++++++++++++++ helpers/env.ts | 1 + 2 files changed, 40 insertions(+) create mode 100644 aggregators/starbase/index.ts diff --git a/aggregators/starbase/index.ts b/aggregators/starbase/index.ts new file mode 100644 index 0000000000..8d815d8550 --- /dev/null +++ b/aggregators/starbase/index.ts @@ -0,0 +1,39 @@ +import { getEnv } from "../../helpers/env"; +import axios from "axios"; +import { CHAIN } from "../../helpers/chains"; +import { FetchOptions } from "../../adapters/types"; + +type TChain = { + [key: string]: number; +}; +const CHAINS: TChain = { + [CHAIN.BASE]: 8453, +}; + +const fetch = async (_a, _b, options: FetchOptions) => { + const response = await axios.get(`https://api-analysis-dev.starbase.ag/api/combine/defillama/volume`, { + headers: { + "X-BYPASS-KEY": getEnv("STARBASE_API_KEY"), + } + }) + const data = response.data; + const negativeVolume = data.volume24h? - data.volume24h : undefined; + return { + dailyVolume: negativeVolume, + }; +}; + +const adapter: any = { + version: 1, + adapter: Object.keys(CHAINS).reduce((acc, chain) => { + return { + ...acc, + [chain]: { + fetch: fetch, + start: '2025-01-10', + }, + }; + }, {}), +}; + +export default adapter; \ No newline at end of file diff --git a/helpers/env.ts b/helpers/env.ts index 696683b8cd..98c3f9f36d 100644 --- a/helpers/env.ts +++ b/helpers/env.ts @@ -33,6 +33,7 @@ export const ENV_KEYS = new Set([ 'ALCHEMIX_KEY', 'ALCHEMIX_SECRET', 'FLIPSIDE_RESTRICTED_MODE', + 'STARBASE_API_KEY', ]) // This is done to support both ZEROx_API_KEY and ZEROX_API_KEY From 33b1a4f385afbda419c478c937cf0f153c0c6059 Mon Sep 17 00:00:00 2001 From: Zeke Date: Mon, 20 Jan 2025 10:30:28 +0800 Subject: [PATCH 4/5] fix : update the index.ts --- aggregators/starbase/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aggregators/starbase/index.ts b/aggregators/starbase/index.ts index 8d815d8550..7c6a6b4fac 100644 --- a/aggregators/starbase/index.ts +++ b/aggregators/starbase/index.ts @@ -13,7 +13,7 @@ const CHAINS: TChain = { const fetch = async (_a, _b, options: FetchOptions) => { const response = await axios.get(`https://api-analysis-dev.starbase.ag/api/combine/defillama/volume`, { headers: { - "X-BYPASS-KEY": getEnv("STARBASE_API_KEY"), + "X-External-API-Key": getEnv("STARBASE_API_KEY"), } }) const data = response.data; From 85f996602c93f10c413a2a1a7b2db8e5cda8d790 Mon Sep 17 00:00:00 2001 From: Zeke Date: Fri, 24 Jan 2025 11:51:38 +0800 Subject: [PATCH 5/5] fix : replace wit new url --- aggregators/starbase/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aggregators/starbase/index.ts b/aggregators/starbase/index.ts index 7c6a6b4fac..deb4fc1ed4 100644 --- a/aggregators/starbase/index.ts +++ b/aggregators/starbase/index.ts @@ -11,7 +11,7 @@ const CHAINS: TChain = { }; const fetch = async (_a, _b, options: FetchOptions) => { - const response = await axios.get(`https://api-analysis-dev.starbase.ag/api/combine/defillama/volume`, { + const response = await axios.get(`https://api-analysis.starbase.ag/api/combine/defillama/volume`, { headers: { "X-External-API-Key": getEnv("STARBASE_API_KEY"), }