misaghlbStablecoin Landscape on DEX - sushiswap TVL daily
    Updated 2022-06-05
    with assets as (
    SELECT top 10 symbol, address, sum(amount) as total_amount, sum(trx_count) as total_trx_count from
    (SELECT SYMBOL_OUT as symbol, TOKEN_OUT as address, sum(zeroifnull(AMOUNT_OUT_USD)) as amount, COUNT(DISTINCT tx_hash) as trx_count
    from ethereum.sushi.ez_swaps
    where (SYMBOL_OUT ilike '%usd%' OR SYMBOL_OUT in ('DAI', 'FRAX', 'FEI', 'EURS', 'TRIBE', 'XSGD') )
    and TOKEN_OUT != '0x5dbcf33d8c2e976c6b560249878e6f1491bca25c'
    GROUP by symbol, address

    UNION

    SELECT SYMBOL_IN as symbol, TOKEN_IN as address, sum(zeroifnull(AMOUNT_IN_USD)) as amount, COUNT(DISTINCT tx_hash) as trx_count
    from ethereum.sushi.ez_swaps
    where (SYMBOL_IN ilike '%usd%' OR SYMBOL_IN in ('DAI', 'FRAX', 'FEI', 'EURS', 'TRIBE', 'XSGD') )
    and TOKEN_IN != '0x5dbcf33d8c2e976c6b560249878e6f1491bca25c'
    GROUP by symbol, address
    )
    GROUP by symbol, address
    order by total_trx_count DESC
    ),
    all_sushipools as (
    select POOL_ADDRESS , token0 , token1,platform from ethereum.dex_liquidity_pools
    where platform = 'sushiswap'
    and (token0 in (SELECT address from assets) or token0 in (SELECT address from assets) )
    )

    select balance_date, SYMBOL, sum(BALANCE) as tvl
    from ethereum.erc20_balances
    where user_address in (SELECT POOL_ADDRESS FROM all_sushipools)
    and balance_date >= CURRENT_DATE - 60
    and (contract_address in (SELECT address from assets) )
    GROUP BY balance_date, SYMBOL
    ORDER BY tvl DESC
    Run a query to Download Data