diff --git a/dexs/grizzlyfi/index.ts b/dexs/grizzlyfi/index.ts index 2cabce4e0f..fefc664814 100644 --- a/dexs/grizzlyfi/index.ts +++ b/dexs/grizzlyfi/index.ts @@ -1,5 +1,5 @@ import request, { gql } from "graphql-request"; -import { BreakdownAdapter, Fetch, SimpleAdapter } from "../../adapters/types"; +import { BreakdownAdapter, Fetch } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; diff --git a/fees/grizzlyfi.ts b/fees/grizzlyfi.ts new file mode 100644 index 0000000000..fd1d8eae76 --- /dev/null +++ b/fees/grizzlyfi.ts @@ -0,0 +1,70 @@ +import { Adapter } from "../adapters/types"; +import { ARBITRUM, AVAX, BSC } from "../helpers/chains"; +import { request, gql } from "graphql-request"; +import type { ChainEndpoints } from "../adapters/types" +import { Chain } from '@defillama/sdk/build/general'; +import { getTimestampAtStartOfDayUTC } from "../utils/date"; + +const endpoints = { + [BSC]: "https://api.thegraph.com/subgraphs/name/metavault-trade/grizzly-bnb-subgraph" +} + +const methodology = { + Fees: "Fees from open/close position (0.1%), swap (0.2% to 0.8%), mint and burn (based on tokens balance in the pool) and borrow fee ((assets borrowed)/(total assets in pool)*0.01%)", + UserFees: "Fees from open/close position (0.1%), swap (0.2% to 0.8%) and borrow fee ((assets borrowed)/(total assets in pool)*0.01%)", + HoldersRevenue: "10% goes to MVX stakers and 25% are buyback and burn of GHNY", + SupplySideRevenue: "50% of all collected fees goes to GLL holders", + Revenue: "15% Protocol revenue, 10% goes to MVX stakers and 25% are buyback and burn of GHNY", + ProtocolRevenue: "10% of all collected fees goes to Grizzly.fi treasury and 5% goes to marketing" +} + +const graphs = (graphUrls: ChainEndpoints) => { + return (chain: Chain) => { + return async (timestamp: number) => { + const todaysTimestamp = getTimestampAtStartOfDayUTC(timestamp) + const searchTimestamp = todaysTimestamp + ":daily" + + const graphQuery = gql + `{ + feeStat(id: "${searchTimestamp}") { + mint + burn + marginAndLiquidation + swap + } + }`; + + const graphRes = await request(graphUrls[chain], graphQuery); + + const dailyFee = parseInt(graphRes.feeStat.mint) + parseInt(graphRes.feeStat.burn) + parseInt(graphRes.feeStat.marginAndLiquidation) + parseInt(graphRes.feeStat.swap) + const finalDailyFee = (dailyFee / 1e30); + const userFee = parseInt(graphRes.feeStat.marginAndLiquidation) + parseInt(graphRes.feeStat.swap) + const finalUserFee = (userFee / 1e30); + + return { + timestamp, + dailyFees: finalDailyFee.toString(), + dailyUserFees: finalUserFee.toString(), + dailyRevenue: (finalDailyFee * 0.1 + finalDailyFee * 0.25 + finalDailyFee * 0.15).toString(), + dailyProtocolRevenue: (finalDailyFee * 0.15).toString(), + dailyHoldersRevenue: (finalDailyFee * 0.1 + finalDailyFee * 0.25).toString(), + dailySupplySideRevenue: (finalDailyFee * 0.5).toString() + }; + }; + }; +}; + + +const adapter: Adapter = { + adapter: { + [BSC]: { + fetch: graphs(endpoints)(BSC), + start: async () => 1689897600, + meta: { + methodology + } + }, + } +} + +export default adapter;