From 6a48e045fa795bc7b03e3daee3ce5c173c89adce Mon Sep 17 00:00:00 2001 From: hetao8 Date: Mon, 7 Oct 2024 21:24:30 +0800 Subject: [PATCH] add jeton update --- aggregators/jeton/index.ts | 74 ++++++++++++++++++++++++++++++++++++ fees/jeton/index.ts | 77 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 aggregators/jeton/index.ts create mode 100644 fees/jeton/index.ts diff --git a/aggregators/jeton/index.ts b/aggregators/jeton/index.ts new file mode 100644 index 0000000000..c97e52e519 --- /dev/null +++ b/aggregators/jeton/index.ts @@ -0,0 +1,74 @@ +import { Adapter, FetchResultVolume } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import { httpGet } from "../../utils/fetchURL"; + +const url = "https://api.echooo.xyz/tenant/defillama/data/v2"; + +const chains = [ + CHAIN.ETHEREUM, + CHAIN.POLYGON, + CHAIN.OPTIMISM, + CHAIN.BSC, + CHAIN.ARBITRUM, + CHAIN.AVAX, + CHAIN.SCROLL, + CHAIN.ERA, + CHAIN.BASE, +]; +type Responce = { + timestamp: number; + protocol: { + daily: { + revenue: string; + volume: string; + }; + total: { + revenue: string; + volume: string; + }; + }; + chains: { + [chain: string]: { + daily: { + revenue: string; + volume: string; + }; + total: { + revenue: string; + volume: string; + }; + }; + }; +}; + +const fetch = + (chain: string) => + async (timestamp: number): Promise => { + const resp: Responce = await httpGet(`${url}?timestamp=${timestamp}`); + const data = resp.chains[chain]; + if (!data || !data.daily || !data.total) { + return {} as FetchResultVolume; + } + return { + dailyVolume: data.daily.volume, + totalVolume: data.total.volume, + timestamp + }; + }; + +const adapter: Adapter = { + adapter: { + ...Object.entries(chains).reduce((acc, chain) => { + const key = chain[1]; + return { + ...acc, + [key]: { + fetch: fetch(key), + start: 1693785600, + }, + }; + }, {}), + }, +}; + +export default adapter; diff --git a/fees/jeton/index.ts b/fees/jeton/index.ts new file mode 100644 index 0000000000..9cbcd73f8d --- /dev/null +++ b/fees/jeton/index.ts @@ -0,0 +1,77 @@ +import { Adapter, FetchResultFees } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import { httpGet } from "../../utils/fetchURL"; + +const url = "https://api.echooo.xyz/tenant/defillama/data/v2"; + +const chains = [ + CHAIN.ETHEREUM, + CHAIN.POLYGON, + CHAIN.OPTIMISM, + CHAIN.BSC, + CHAIN.ARBITRUM, + CHAIN.AVAX, + CHAIN.SCROLL, + CHAIN.ERA, + CHAIN.BASE, +]; + +type Responce = { + timestamp: number; + protocol: { + daily: { + revenue: string; + volume: string; + }; + total: { + revenue: string; + volume: string; + }; + }; + chains: { + [chain: string]: { + daily: { + revenue: string; + volume: string; + }; + total: { + revenue: string; + volume: string; + }; + }; + }; +}; + +const fetch = + (chain: string) => + async (timestamp: number): Promise => { + const resp: Responce = await httpGet(`${url}?timestamp=${timestamp}`); + const data = resp.chains[chain]; + if (!data || !data.daily || !data.total) { + return {} as FetchResultFees; + } + return { + dailyFees: data.daily.revenue, + dailyRevenue: data.daily.revenue, + totalFees: data.total.revenue, + totalRevenue: data.total.revenue, + timestamp + }; + }; + +const adapter: Adapter = { + adapter: { + ...Object.entries(chains).reduce((acc, chain) => { + const key = chain[1]; + return { + ...acc, + [key]: { + fetch: fetch(key), + start: 1693785600, + }, + }; + }, {}), + }, +}; + +export default adapter;