diff --git a/dexs/filament/index.ts b/dexs/filament/index.ts index 907f581968..a27a434cec 100644 --- a/dexs/filament/index.ts +++ b/dexs/filament/index.ts @@ -2,13 +2,23 @@ import type { SimpleAdapter } from "../../adapters/types"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; import { httpGet } from "../../utils/fetchURL"; -const api = "https://orderbook.filament.finance/sei/api/v1/orderbook/tradeVolumeStats/BTC"; +const assets = ["BTC", "ETH", "SOL", "TRUMP"]; -const fetch = async () => { +const fetchForAsset = async (asset: string) => { + const api = `https://orderbookv5.filament.finance/k8s/api/v1/orderbook/tradeVolumeStats/${asset}`; const timestamp = getUniqStartOfTodayTimestamp(); const res = await httpGet(api); + + if (!res || typeof res !== "object" || !("allTimeVolume" in res) || !("volumeIn24Hours" in res)) { + throw new Error(`Invalid response for asset ${asset}: ${JSON.stringify(res)}`); + } + const { allTimeVolume, volumeIn24Hours } = res; + if (typeof allTimeVolume !== "number" || typeof volumeIn24Hours !== "number") { + throw new Error(`Invalid volume data for ${asset}: ${JSON.stringify(res)}`); + } + return { timestamp, dailyVolume: volumeIn24Hours, @@ -16,6 +26,27 @@ const fetch = async () => { }; }; +const fetch = async () => { + const results = await Promise.all( + assets.map(async (asset) => { + try { + return { asset, ...(await fetchForAsset(asset)) }; + } catch (error) { + console.error(`Error fetching ${asset}:`, error); + return null; + } + }) + ); + + return results.reduce((acc, item) => { + if (item) { + const { asset, ...data } = item; + acc[asset] = data; + } + return acc; + }, {} as Record); +}; + const adapter: SimpleAdapter = { adapter: { sei: { diff --git a/fees/filament/index.tsx b/fees/filament/index.tsx index 915fc38713..2c9144085a 100644 --- a/fees/filament/index.tsx +++ b/fees/filament/index.tsx @@ -4,7 +4,7 @@ import { FetchOptions, SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; const endpoint = - "https://api.goldsky.com/api/public/project_cm0qvthsz96sp01utcnk55ib0/subgraphs/filament-sei/v1/gn"; + "https://api.goldsky.com/api/public/project_cm0qvthsz96sp01utcnk55ib0/subgraphs/filament-sei/v2/gn"; // Get timestamps for yesterday and today const now = Math.floor(Date.now() / 1000); // Current timestamp in seconds @@ -96,7 +96,7 @@ const adapter: SimpleAdapter = { adapter: { [CHAIN.SEI]: { fetch: fetchProtocolFees, - start: '2024-09-07', + start: '2025-01-21', meta: { methodology, },