Query editor
WITH metamask_vol AS(SELECTdate_trunc('month', block_date) as month, SUM(amount_usd) as swap_volume, SUM(SUM(amount_usd)) over (ORDER BY date_trunc('month', block_date)) AS cumulative_swap_volumeFROM dex.tradesWHERE tx_to = 0x881D40237659C251811CEC9c364ef91dC08D300CAND block_date >= NOW() - INTERVAL '3' yearGROUP BY 1), metamask_swaps AS (SELECTdate_trunc('month', block_date) as month, COUNT(tx_hash) as swap_countFROM dex.tradesWHERE tx_to = 0x881D40237659C251811CEC9c364ef91dC08D300CAND block_date >= NOW() - INTERVAL '3' yearGROUP BY 1), metamask_revenue_bull AS (SELECTdate_trunc('month', block_date) as month, SUM(amount_usd) * .00875 as swap_revenue_bull -- service fee of 0.875% (Variable fee ranging from .3% to .875%), SUM(SUM(amount_usd) * .00875) over (ORDER BY date_trunc('month', block_date)) AS cumulative_swap_revenue_bullFROM dex.tradesWHERE tx_to = 0x881D40237659C251811CEC9c364ef91dC08D300CAND block_date >= NOW() - INTERVAL '3' yearGROUP BY 1), metamask_revenue_base AS (SELECTdate_trunc('month', block_date) as month, SUM(amount_usd) * .003 as swap_revenue_base -- service fee of 0.875% (Variable fee ranging from .3% to .875%), SUM(SUM(amount_usd) * .003) over (ORDER BY date_trunc('month', block_date)) as cumulative_swap_revenue_baseFROM dex.tradesWHERE tx_to = 0x881D40237659C251811CEC9c364ef91dC08D300CAND block_date >= NOW() - INTERVAL '3' yearGROUP BY 1), metamask_seq AS (SELECTrow_number() over (order by base.month ASC) as num_seq, base.month AS month, {{discount rate}} / 12 AS rate, base.swap_revenue_base AS revenue_base, bull.swap_revenue_bull AS revenue_bullFROM metamask_revenue_base AS baseJOIN metamask_revenue_bull AS bull ON base.month = bull.month), metamask_dcf AS (SELECTms.num_seq, ms.month, ROUND(POWER(1 + ms.rate, ms.num_seq), 2) as disc_rate_denominator, ROUND(ROUND(ms.revenue_base, 2) / ROUND(POWER(1 + ms.rate, ms.num_seq), 2), 2) AS disc_rev_base