-- fees with just a single group for SS; change to block range to match dashboard
WITH get_memo AS (
SELECT DISTINCT TX_ID, MEMO
FROM thorchain.defi.fact_swaps_events
WHERE block_timestamp :: DATE BETWEEN '{{start_date}}' AND '{{end_date}}'
)
SELECT
SUM(s.LIQ_FEE_ASSET_USD) AS TOTAL_FEES_USD_SUM -- Summing the liquidity fee in USD across all transactions for the specific affiliate address
FROM thorchain.defi.fact_swaps AS s
JOIN get_memo AS m ON s.TX_ID = m.TX_ID
WHERE s.AFFILIATE_ADDRESS = 'ss' -- Replace 'ss' with the specific affiliate address