Query editor
-- Billion dollar mkt caps for stables as of 1/21/2023 = usdt, usdc, busd, dai, fraxwith trades as(Selectblock_time as time, COALESCE(token_sold_symbol,cast(token_sold_address as varchar)) as token_sold, COALESCE(token_bought_symbol, cast(token_bought_address as varchar)) as token_bought, token_pair, token_sold_amount, token_bought_amount, amount_usd-- Stable category, Case when lower(token_sold_symbol) like '%usdc%' then 'usdc'when lower(token_sold_symbol) like '%usdt%' then 'usdt'when lower(token_sold_symbol) like '%busd%' then 'busd'when lower(token_sold_symbol) like '%dai%' then 'dai'when lower(token_sold_symbol) like '%frax%' then 'frax'Else 'other'End As stable_category-- Stablecoin sales category, Case when lower(token_sold_symbol) like '%usdc%' then 'stablecoin_sold'when lower(token_sold_symbol) like '%usd%' then 'stablecoin_sold'when lower(token_sold_symbol) like '%usdt%' then 'stablecoin_sold'when lower(token_sold_symbol) like '%busd%' then 'stablecoin_sold'when lower(token_sold_symbol) like '%dai%' then 'stablecoin_sold'when lower(token_sold_symbol) like '%frax%' then 'stablecoin_sold'Else 'Coin'End As stable_sold-- Stablecoin buy category, Case when lower(token_bought_symbol) like '%usdc%' then 'stablecoin_bought'when lower(token_bought_symbol) like '%usd%' then 'stablecoin_bought'when lower(token_bought_symbol) like '%usdt%' then 'stablecoin_bought'when lower(token_bought_symbol) like '%busd%' then 'stablecoin_bought'when lower(token_bought_symbol) like '%dai%' then 'stablecoin_bought'when lower(token_bought_symbol) like '%frax%' then 'stablecoin_bought'Else 'Coin'End As stable_boughtfrom dex.trades as dex)Selectconcat(token_sold,'/',token_bought) as token_pair_symbol, token_sold, token_bought, sum(amount_usd) as sum_bought_usdfrom tradesWhere stable_sold = 'stablecoin_sold'and stable_category = 'busd'AND stable_bought != 'stablecoin_bought'AND token_bought not in ('TBTC','WIRTUAL','WHALE','aBNBc', 'UST', 'HAY', 'TIME')AND time > now() - interval '{{Date Frequency of}}' {{Date Period of}}group by 1,2,3having sum(amount_usd) != 0order by 4 DESCLimit 20