From 228676504d5686bb46f225f7dacc2caeb966e8ac Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Tue, 5 Sep 2023 15:43:11 +0000 Subject: [PATCH] add pact fes --- fees/pact.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 fees/pact.ts diff --git a/fees/pact.ts b/fees/pact.ts new file mode 100644 index 0000000000..e989b6f73e --- /dev/null +++ b/fees/pact.ts @@ -0,0 +1,28 @@ +import { Adapter, FetchResultFees, SimpleAdapter } from "../adapters/types" +import { CHAIN } from "../helpers/chains" +import fetchURL from "../utils/fetchURL" + +interface IAPIResponse { + fee_usd_24h: string +} +const url = 'https://api.pact.fi/api/internal/pools_details/all' +const fetchFees = async (timestamp: number): Promise => { + const response = (await fetchURL(url)).data.map((e: any) => { return {fee_usd_24h: e.fee_usd_24h}}) as IAPIResponse[] + const dailyFees = response.reduce((a: number, b: IAPIResponse) => a + Number(b.fee_usd_24h), 0) + return { + dailyFees: `${dailyFees}`, + timestamp + } +} + +const adapters: SimpleAdapter = { + adapter:{ + [CHAIN.ALGORAND]: { + fetch: fetchFees, + start: async () => 1693699200, + runAtCurrTime: true + } + } +} + +export default adapters