diff --git a/dexs/lnexchange-perp/index.ts b/dexs/lnexchange-perp/index.ts new file mode 100644 index 0000000000..c6913f25ed --- /dev/null +++ b/dexs/lnexchange-perp/index.ts @@ -0,0 +1,36 @@ +import type { SimpleAdapter } from "../../adapters/types"; +import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; +import { httpPost } from "../../utils/fetchURL"; +import BigNumber from "bignumber.js"; +import { CHAIN } from "../../helpers/chains"; + +const URL = + "https://test-futures-api.ln.exchange/napi/common/getDayTradeAmount"; + +interface Response { + dayNtlVlm: number; +} +const fetch = async (timestamp: number) => { + const respose: Response[] = ( + await httpPost(URL, { dayTimestamp: timestamp * 1000 }) + ).data; + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); + const dailyVolume = respose.reduce((acc, item) => { + return acc.plus(item.dayNtlVlm); + }, new BigNumber(0)); + return { + dailyVolume: dailyVolume?.toString(), + timestamp: dayTimestamp, + }; +}; + +const adapter: SimpleAdapter = { + adapter: { + [CHAIN.BITCOIN]: { + fetch, + start: "2024-10-20", + }, + }, +}; + +export default adapter; diff --git a/dexs/lnexchange-spot/index.ts b/dexs/lnexchange-spot/index.ts new file mode 100644 index 0000000000..49d2ffe9ed --- /dev/null +++ b/dexs/lnexchange-spot/index.ts @@ -0,0 +1,36 @@ +import type { SimpleAdapter } from "../../adapters/types"; +import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; +import { httpPost } from "../../utils/fetchURL"; +import BigNumber from "bignumber.js"; +import { CHAIN } from "../../helpers/chains"; + +const URL = + "https://test-spots-api.ln.exchange/napi/common/getDayTradeAmount"; + +interface Response { + dayNtlVlm: number; +} +const fetch = async (timestamp: number) => { + const respose: Response[] = ( + await httpPost(URL, { dayTimestamp: timestamp * 1000 }) + ).data; + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); + const dailyVolume = respose.reduce((acc, item) => { + return acc.plus(item.dayNtlVlm); + }, new BigNumber(0)); + return { + dailyVolume: dailyVolume?.toString(), + timestamp: dayTimestamp, + }; +}; + +const adapter: SimpleAdapter = { + adapter: { + [CHAIN.BITCOIN]: { + fetch, + start: "2024-08-30", + }, + }, +}; + +export default adapter; diff --git a/fees/lnexchange.ts b/fees/lnexchange.ts new file mode 100644 index 0000000000..0337e141e3 --- /dev/null +++ b/fees/lnexchange.ts @@ -0,0 +1,34 @@ +import { CHAIN } from "../helpers/chains"; +import { Adapter, FetchOptions } from "../adapters/types"; +import { httpPost } from "../utils/fetchURL"; + +const fetchFees = async (options: FetchOptions) => { + const respose = await httpPost( + `https://test-futures-api.ln.exchange/napi/common/getTradeFee`, + { + startTimestamp: options.startTimestamp * 1000, + endTimestamp: options.endTimestamp * 1000, + } + ); + + const dailyFees = respose.data.dailyFees; + const totalFees = respose.data.totalFees; + + return { + dailyFees, + dailyRevenue: dailyFees, + totalFees, + totalRevenue: totalFees, + }; +}; + +const adapter: Adapter = { + version: 2, + adapter: { + [CHAIN.BITCOIN]: { + fetch: fetchFees, + start: "2024-10-20", + }, + }, +}; +export default adapter;