Ali3N Dately Total Stablecoins Stats on BSC Sushi
    Updated 2023-03-17
    with maintable as (
    select 'Arbitrum' as chain,
    date_trunc ({{Date_Trunc}},block_timestamp) as date,
    case when symbol_in ilike any ('DAI','FRAX','LUSD','MAI','TUSD','USD+','USDC','USDT','USX','agEUR','alUSD','hUSDC','jEUR','sUSD','USDD','USDF','PAXG','RSV','XAUT','DGX','MIM') or symbol_in ilike '%usd%' then symbol_in
    else symbol_out end as Stablecoin,
    count (distinct tx_hash) as Swaps_Count,
    count (distinct origin_from_address) as Swappers_Count,
    sum (amount_in_usd) as Volume,
    avg (amount_in_usd) as Average_Volume
    from arbitrum.sushi.ez_swaps
    where (symbol_in ilike any ('DAI','FRAX','LUSD','MAI','TUSD','USD+','USDC','USDT','USX','agEUR','alUSD','hUSDC','jEUR','sUSD','USDD','USDF','PAXG','RSV','XAUT','DGX','MIM','PAXG','RSV','XAUT','DGX','MIM') or symbol_in ilike '%usd%'
    or symbol_out ilike any ('DAI','FRAX','LUSD','MAI','TUSD','USD+','USDC','USDT','USX','agEUR','alUSD','hUSDC','jEUR','sUSD','USDD','USDF','PAXG','RSV','XAUT','DGX','MIM','PAXG','RSV','XAUT','DGX','MIM') or symbol_out ilike '%usd%')
    and symbol_in not ilike '%-%' and symbol_in not ilike '%/%' and symbol_in not ilike '%+%'
    and symbol_out not ilike '%-%' and symbol_out not ilike '%/%' and symbol_out not ilike '%+%'
    group by 1,2,3

    union ALL

    select 'Avalanche' as chain,
    date_trunc ({{Date_Trunc}},block_timestamp) as date,
    case when symbol_in ilike any ('DAI','FRAX','LUSD','MAI','TUSD','USD+','USDC','USDT','USX','agEUR','alUSD','hUSDC','jEUR','sUSD','USDD','USDF','PAXG','RSV','XAUT','DGX','MIM') or symbol_in ilike '%usd%' then symbol_in
    else symbol_out end as Stablecoin,
    count (distinct tx_hash) as Swaps_Count,
    count (distinct origin_from_address) as Swappers_Count,
    sum (amount_in_usd) as Volume,
    avg (amount_in_usd) as Average_Volume
    from avalanche.sushi.ez_swaps
    where (symbol_in ilike any ('DAI','FRAX','LUSD','MAI','TUSD','USD+','USDC','USDT','USX','agEUR','alUSD','hUSDC','jEUR','sUSD','USDD','USDF','PAXG','RSV','XAUT','DGX','MIM') or symbol_in ilike '%usd%'
    or symbol_out ilike any ('DAI','FRAX','LUSD','MAI','TUSD','USD+','USDC','USDT','USX','agEUR','alUSD','hUSDC','jEUR','sUSD','USDD','USDF','PAXG','RSV','XAUT','DGX','MIM') or symbol_out ilike '%usd%')
    and symbol_in not ilike '%-%' and symbol_in not ilike '%/%' and symbol_in not ilike '%+%'
    and symbol_out not ilike '%-%' and symbol_out not ilike '%/%' and symbol_out not ilike '%+%'
    group by 1,2,3

    union ALL

    select 'Binance Smart Chain' as chain,
    Run a query to Download Data