From 33b384ea860f7c7be1eaaa25bbd5825d36d25049 Mon Sep 17 00:00:00 2001 From: 0xgnek <0xgnek@gmail.com> Date: Tue, 11 Feb 2025 15:12:06 +0000 Subject: [PATCH] enable mondrain --- protocols/mondrain/index.ts | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 protocols/mondrain/index.ts diff --git a/protocols/mondrain/index.ts b/protocols/mondrain/index.ts new file mode 100644 index 0000000000..71ece7f02b --- /dev/null +++ b/protocols/mondrain/index.ts @@ -0,0 +1,44 @@ +import request from "graphql-request" +import { FetchOptions, SimpleAdapter } from "../../adapters/types" +import { CHAIN } from "../../helpers/chains" + +const url = 'https://api.mondrianswap.xyz/graphql' + + +interface IProtocolData { + swapVolume24h: number + swapFee24h: number +} +const fetchVolume = async (options: FetchOptions) => { + const querry = ` + { + embrGetProtocolData{ + swapVolume24h + swapFee24h + + } + }` + + const respose = (await request(url, querry)).embrGetProtocolData as IProtocolData + + const dailyVolume = options.createBalances(); + dailyVolume.addUSDValue(Number(respose.swapVolume24h)) + const dailyFees = dailyVolume.clone(); + dailyFees.addUSDValue(Number(respose.swapFee24h)) + return { + dailyVolume: dailyVolume, + dailyFees: dailyFees, + } +} + +const adapters: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.ABSTRACT]: { + fetch: fetchVolume, + runAtCurrTime: true + } + } +} + +export default adapters