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;