From b339543d7da244a9a00ecc9415e84abfc095a6ea Mon Sep 17 00:00:00 2001 From: KPHEMRAJ <65623621+KPHEMRAJ@users.noreply.github.com> Date: Tue, 16 Sep 2025 16:48:44 +0530 Subject: [PATCH] breakdown hyperliquid fees --- fees/hyperliquid-hlp.ts | 13 +++++ fees/hyperliquid-perp.ts | 25 ++++++++++ fees/hyperliquid-spot.ts | 25 ++++++++++ fees/hyperliquid.ts | 101 +++++++++++++++++++++------------------ 4 files changed, 117 insertions(+), 47 deletions(-) create mode 100644 fees/hyperliquid-hlp.ts create mode 100644 fees/hyperliquid-perp.ts create mode 100644 fees/hyperliquid-spot.ts diff --git a/fees/hyperliquid-hlp.ts b/fees/hyperliquid-hlp.ts new file mode 100644 index 0000000000..a81b125964 --- /dev/null +++ b/fees/hyperliquid-hlp.ts @@ -0,0 +1,13 @@ +import adapters from './hyperliquid' +const { breakdown, ...rest } = adapters + +const methodology = { + Fees: "1% of the hyperliquid spot and perp fees goes to HLP liquidity providers, before 30 Aug 2025 it was 3%", + SupplySideRevenue: "1% of fees go to HLP Vault suppliers, before 30 Aug 2025 it was 3%", +} + +export default { + ...rest, + methodology, + adapter: breakdown["hlp"], +} \ No newline at end of file diff --git a/fees/hyperliquid-perp.ts b/fees/hyperliquid-perp.ts new file mode 100644 index 0000000000..4dee994664 --- /dev/null +++ b/fees/hyperliquid-perp.ts @@ -0,0 +1,25 @@ +import adapters from './hyperliquid' +const { breakdown, ...rest } = adapters +import { METRIC } from "../helpers/metrics"; + +const breakdownMethodology = { + Fees: { + 'Trade Fees': 'Perp trade fees and Ticker auction proceeds', + }, + HoldersRevenue: { + [METRIC.TOKEN_BUY_BACK]: "All the revenue is used for buying back HYPE tokens" + }, +} + +const methodology = { + Fees: "Trade fees and Ticker auction proceeds. Note this excludes HyperEVM fees.", + Revenue: "99% of fees go to Assistance Fund for buying HYPE tokens, before 30 Aug 2025 it was 97% of fees", + ProtocolRevenue: "Protocol doesn't keep any fees.", + HoldersRevenue: "99% of fees go to Assistance Fund for bbuying HYPE tokens, before 30 Aug 2025 it was 97% of fees", +} +export default { + ...rest, + methodology, + breakdownMethodology, + adapter: breakdown["perp"], +} \ No newline at end of file diff --git a/fees/hyperliquid-spot.ts b/fees/hyperliquid-spot.ts new file mode 100644 index 0000000000..e3f846bf10 --- /dev/null +++ b/fees/hyperliquid-spot.ts @@ -0,0 +1,25 @@ +import adapters from './hyperliquid' +const { breakdown, ...rest } = adapters +import { METRIC } from "../helpers/metrics"; + +const breakdownMethodology = { + Fees: { + 'Trade Fees': 'Perp trade fees and Ticker auction proceeds', + }, + HoldersRevenue: { + [METRIC.TOKEN_BUY_BACK]: "All the revenue is used for buying back HYPE tokens" + }, +} + +const methodology = { + Fees: "Trade fees and Ticker auction proceeds. Note this excludes HyperEVM fees.", + Revenue: "99% of fees go to Assistance Fund for buying HYPE tokens, before 30 Aug 2025 it was 97% of fees", + ProtocolRevenue: "Protocol doesn't keep any fees.", + HoldersRevenue: "99% of fees go to Assistance Fund for bbuying HYPE tokens, before 30 Aug 2025 it was 97% of fees", +} +export default { + ...rest, + methodology, + breakdownMethodology, + adapter: breakdown['spot'], +} \ No newline at end of file diff --git a/fees/hyperliquid.ts b/fees/hyperliquid.ts index f735c90435..bb418d4555 100644 --- a/fees/hyperliquid.ts +++ b/fees/hyperliquid.ts @@ -1,7 +1,7 @@ import { CHAIN } from "../helpers/chains" -import { Adapter, FetchOptions, } from '../adapters/types'; import { findClosest } from "../helpers/utils/findClosest"; import { httpGet } from "../utils/fetchURL"; +import { BreakdownAdapter, FetchOptions } from "../adapters/types"; import { METRIC } from "../helpers/metrics"; let data: any @@ -10,59 +10,66 @@ async function getAllData() { } // fees source: https://hyperdash.info/statistics -const fetch = async (options: FetchOptions) => { - if (!data) data = getAllData() - data = await data +const fetch = (market_type: string) => { + return async (options: FetchOptions) => { + if (!data) data = getAllData() + data = await data - const dailyFees = options.createBalances() - const startCumFees: any = findClosest(options.startTimestamp, data, 3600) - const endCumFees: any = findClosest(options.endTimestamp, data, 3600) - dailyFees.addUSDValue((endCumFees.total_fees - startCumFees.total_fees) / 1e6, 'Trade fees') + const dailyFees = options.createBalances() + const startCumFees: any = findClosest(options.startTimestamp, data, 3600) + const endCumFees: any = findClosest(options.endTimestamp, data, 3600) + const totalFees = (endCumFees.total_fees - startCumFees.total_fees) / 1e6; + const totalSpotFees = (endCumFees.total_spot_fees - startCumFees.total_spot_fees) / 1e6; - // confirm from hyperliquid team - // before 30 Aug, 97% of fees go to Assistance Fund for burning tokens, remaining 3% go to HLP Vault - // after 30 Aug, 99% of fees go to Assistance Fund for burning tokens, remaining 1% go to HLP Vault - const dailyRevenue = dailyFees.clone(options.startTimestamp >= 1756512000 ? 0.99 : 0.97); - const dailySupplySideRevenue = dailyFees.clone(options.startTimestamp >= 1756512000 ? 0.01 : 0.03, 'HLP'); - - return { - dailyFees, - dailyUserFees: dailyFees, - dailySupplySideRevenue, - dailyRevenue, - dailyHoldersRevenue: dailyRevenue.clone(1, METRIC.TOKEN_BUY_BACK), - dailyProtocolRevenue: 0, - } -} + if (market_type === "spot" || market_type === "perp") { + market_type === "spot" ? dailyFees.addUSDValue(totalSpotFees, 'Trade fees') : dailyFees.addUSDValue(totalFees - totalSpotFees, 'Trade fees'); + // confirm from hyperliquid team + // before 30 Aug, 97% of fees go to Assistance Fund for burning tokens, remaining 3% go to HLP Vault + // after 30 Aug, 99% of fees go to Assistance Fund for burning tokens, remaining 1% go to HLP Vault + const dailyRevenue = dailyFees.clone(options.startTimestamp >= 1756512000 ? 0.99 : 0.97); -const breakdownMethodology = { - Fees: { - 'Trade Fees': 'Perp trade fees and Ticker auction proceeds', - }, - SupplySideRevenue: { - 'HLP': '1% of the fees go to HLP vault (used to be 3%)', - }, - HoldersRevenue: { - [METRIC.TOKEN_BUY_BACK]: "All the revenue is used for buying back HYPE tokens" - }, -} + return { + dailyFees, + dailyUserFees: dailyFees, + dailyRevenue, + dailyHoldersRevenue: dailyRevenue.clone(1, METRIC.TOKEN_BUY_BACK), + dailyProtocolRevenue: 0, + dailySupplySideRevenue: 0 + } + } + else { + dailyFees.addUSDValue(totalFees, 'Trade fees') + const dailySupplySideRevenue = dailyFees.clone(options.startTimestamp >= 1756512000 ? 0.01 : 0.03, 'HLP'); -const methodology = { - Fees: "Trade fees and Ticker auction proceeds. Note this excludes the HLP vault and HyperEVM fees.", - Revenue: "99% of fees go to Assistance Fund for buying HYPE tokens, before 30 Aug 2025 it was 97% of fees", - ProtocolRevenue: "Protocol doesn't keep any fees.", - HoldersRevenue: "99% of fees go to Assistance Fund for bbuying HYPE tokens, before 30 Aug 2025 it was 97% of fees", - SupplySideRevenue: "1% of fees go to HLP Vault suppliers, before 30 Aug 2025 it was 3%", + return { + dailyFees: dailySupplySideRevenue, + dailySupplySideRevenue, + } + } + } } -const adapter: Adapter = { +const adapters: BreakdownAdapter = { version: 2, - fetch, - breakdownMethodology, - chains: [CHAIN.HYPERLIQUID], - methodology, -} + breakdown: { + spot: { + [CHAIN.HYPERLIQUID]: { + fetch: fetch("spot"), + }, + }, + perp: { + [CHAIN.HYPERLIQUID]: { + fetch: fetch("perp"), + }, + }, + hlp: { + [CHAIN.HYPERLIQUID]: { + fetch: fetch("hlp") + } + } + }, +}; -export default adapter +export default adapters;