From 593d7a8ea15f8e77cabd2f64f1bf6ad517de8f6a Mon Sep 17 00:00:00 2001 From: Krunal Amin Date: Wed, 1 May 2024 11:43:56 -0500 Subject: [PATCH 1/3] update fee adapter with latest protocol endpoint/numbers --- fees/unidex.ts | 68 +++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/fees/unidex.ts b/fees/unidex.ts index 6a715fc209..5273e57f3d 100644 --- a/fees/unidex.ts +++ b/fees/unidex.ts @@ -4,11 +4,7 @@ import { getTimestampAtStartOfDayUTC } from "../utils/date"; import { Chain } from "@defillama/sdk/build/general"; import request, { gql } from "graphql-request"; - -type TChainIDs = { - [key in Chain]?: number; -}; - +type TChainIDs = { [key in Chain]?: number }; const chainIDs: TChainIDs = { [CHAIN.FANTOM]: 250, [CHAIN.ARBITRUM]: 42161, @@ -20,7 +16,7 @@ const chainIDs: TChainIDs = { interface IDayProduct { cumulativeFeesUsd: number; - _id: string; + chainId: number; } const fetch = (chain: Chain) => { @@ -31,35 +27,36 @@ const fetch = (chain: Chain) => { query MyQuery { DayProducts(filter: {date: ${todaysTimestamp}}) { cumulativeFeesUsd - _id + chainId } } `; - const endpoint = "https://arkiverbackup.moltennetwork.com/graphql"; + const endpoint = "https://arkiver.moltennetwork.com/graphql"; const response = await request(endpoint, graphQuery); const dayProducts: IDayProduct[] = response.DayProducts; - const chainID = chainIDs[chain]; - let dailyFeeUSD = 0; - + const feesByChain: { [chainId: number]: number } = {}; dayProducts.forEach((product) => { - const productChainID = parseInt(product._id.split(":")[2]); - if (productChainID === chainID) { - dailyFeeUSD += product.cumulativeFeesUsd; + const chainId = product.chainId; + if (chainId === 360) { + feesByChain[42161] = (feesByChain[42161] || 0) + product.cumulativeFeesUsd; + } else { + feesByChain[chainId] = (feesByChain[chainId] || 0) + product.cumulativeFeesUsd; } }); - const dailyHoldersRevenue = dailyFeeUSD * 0.35; - const dailyProtocolRevenue = dailyFeeUSD * 0.70; - const dailySupplySideRevenue = dailyFeeUSD * 0.3; + const chainID = chainIDs[chain]; + const dailyFeeUSD = chainID !== undefined ? feesByChain[chainID] || 0 : 0; + + const dailyHoldersRevenue = dailyFeeUSD * 0.15; + const dailyProtocolRevenue = dailyFeeUSD * 0.85; + return { dailyFees: dailyFeeUSD.toString(), dailyHoldersRevenue: dailyHoldersRevenue.toString(), dailyProtocolRevenue: dailyProtocolRevenue.toString(), - dailyRevenue: dailyProtocolRevenue.toString(), - dailySupplySideRevenue: dailySupplySideRevenue.toString(), - timestamp + timestamp, }; }; }; @@ -68,7 +65,6 @@ const methodology = { Fees: "Fees collected from user trading fees", Revenue: "Fees going to the treasury + holders", HoldersRevenue: "Fees going to token holders", - SupplySideRevenue: "Fees going to liquidity providers of counterparty pools" }; const adapter: Adapter = { @@ -76,53 +72,39 @@ const adapter: Adapter = { [CHAIN.OPTIMISM]: { fetch: fetch(CHAIN.OPTIMISM), start: 1687422746, - meta: { - methodology, - }, + meta: { methodology }, }, [CHAIN.ERA]: { fetch: fetch(CHAIN.ERA), start: 1687422746, - meta: { - methodology, - }, + meta: { methodology }, }, [CHAIN.ARBITRUM]: { fetch: fetch(CHAIN.ARBITRUM), start: 1687422746, - meta: { - methodology, - }, + meta: { methodology }, }, [CHAIN.BASE]: { fetch: fetch(CHAIN.BASE), start: 1687422746, - meta: { - methodology, - }, + meta: { methodology }, }, [CHAIN.FANTOM]: { fetch: fetch(CHAIN.FANTOM), start: 1687422746, - meta: { - methodology, - }, + meta: { methodology }, }, [CHAIN.METIS]: { fetch: fetch(CHAIN.METIS), start: 1687898060, - meta: { - methodology, - }, + meta: { methodology }, }, [CHAIN.EVMOS]: { fetch: fetch(CHAIN.EVMOS), start: 1700104066, - meta: { - methodology, - }, + meta: { methodology }, }, }, }; -export default adapter; +export default adapter; \ No newline at end of file From caed3bc0f20fbe89e762ca3a0d5030f2ac3ae027 Mon Sep 17 00:00:00 2001 From: Krunal Amin Date: Wed, 1 May 2024 11:45:49 -0500 Subject: [PATCH 2/3] update protocol rev with right number --- fees/unidex.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fees/unidex.ts b/fees/unidex.ts index 5273e57f3d..3be5feb64f 100644 --- a/fees/unidex.ts +++ b/fees/unidex.ts @@ -50,7 +50,7 @@ const fetch = (chain: Chain) => { const dailyFeeUSD = chainID !== undefined ? feesByChain[chainID] || 0 : 0; const dailyHoldersRevenue = dailyFeeUSD * 0.15; - const dailyProtocolRevenue = dailyFeeUSD * 0.85; + const dailyProtocolRevenue = dailyFeeUSD * 0.80; return { dailyFees: dailyFeeUSD.toString(), From c330a68db9095344f4429b4aa0175d5bcc575033 Mon Sep 17 00:00:00 2001 From: Krunal Amin Date: Wed, 1 May 2024 11:52:48 -0500 Subject: [PATCH 3/3] final fix for misunderstanding because im stupid --- fees/unidex.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fees/unidex.ts b/fees/unidex.ts index 3be5feb64f..b27ce781df 100644 --- a/fees/unidex.ts +++ b/fees/unidex.ts @@ -49,13 +49,15 @@ const fetch = (chain: Chain) => { const chainID = chainIDs[chain]; const dailyFeeUSD = chainID !== undefined ? feesByChain[chainID] || 0 : 0; - const dailyHoldersRevenue = dailyFeeUSD * 0.15; - const dailyProtocolRevenue = dailyFeeUSD * 0.80; + const dailyHoldersRevenue = dailyFeeUSD * 0.65; + const dailyProtocolRevenue = dailyFeeUSD; + const dailySupplySideRevenue = dailyFeeUSD * 0.20; return { dailyFees: dailyFeeUSD.toString(), dailyHoldersRevenue: dailyHoldersRevenue.toString(), dailyProtocolRevenue: dailyProtocolRevenue.toString(), + dailySupplySideRevenue: dailySupplySideRevenue.toString(), timestamp, }; }; @@ -64,7 +66,7 @@ const fetch = (chain: Chain) => { const methodology = { Fees: "Fees collected from user trading fees", Revenue: "Fees going to the treasury + holders", - HoldersRevenue: "Fees going to token holders", + SupplySideFees: "Fees going to liquidity providers of the protocol", }; const adapter: Adapter = {