Query editor
WITH Fees AS (-- Hyperliquid: Historical Fees from Perpetual Trades by Coinselectdate, coin, total_fees_usdc, SUM(total_fees_usdc) OVER (PARTITION BY coin ORDER BY date ASC) AS cumulative_fees_usdcfrom dune.ramiro_mata.dataset_hyperliquid_perp_fees_by_coin_allium),FundingPayments AS (select day_date as date, coin, daily_funding_payments, cumsum_funding_paymentsfrom dune.ramiro_mata.dataset_hyperliquid_funding_rate_payments_from_misc_events),FirstFundingDates AS (select coin, min(date) as first_datefrom FundingPaymentsgroup by coin),FeesAtDate AS (select coin, cumulative_fees_usdcfrom Feeswhere (coin, date) in (select * from FirstFundingDates)),Combined AS (select date, coin, 'Fees' as name, total_fees_usdc as daily, cumulative_fees_usdc as cumsumfrom FeesUNION ALLselect date, coin, 'Funding Rate Payments' as name, daily_funding_payments as daily, cumsum_funding_payments as cumsumfrom FundingPaymentsUNION ALLselect date, P.coin, 'shifted-up: Funding Rate Payments' as name, P.daily_funding_payments as daily, P.cumsum_funding_payments + F.cumulative_fees_usdc as cumsumfrom FundingPayments Pleft join FeesAtDate Fon P.coin = F.coin