maybeyonasmim_dex_vol
    Updated 2022-02-08
    with pools as (
    select distinct user_address from ethereum.erc20_balances
    where symbol = 'MIM'
    and year(balance_date) = 2022
    and (
    label_type = 'dex' or
    user_address in (
    lower('0x5a6A4D54456819380173272A5E8E9B9904BdF41B'), --mim-crv
    lower('0x55A8a39bc9694714E2874c1ce77aa1E599461E18') --mim-usd
    )
    )
    ),
    sell as (
    select
    date(block_timestamp) as date,
    count(distinct tx_id) as txs,
    sum(amount) as volume
    from ethereum.udm_events
    where symbol = 'MIM'
    -- and block_timestamp > current_date - interval '180 days'
    and year(block_timestamp) = 2022
    and to_address in (select user_address from pools)
    group by 1
    ),
    buy as (
    select
    date(block_timestamp) as date,
    count(distinct tx_id) as txs,
    sum(amount) as volume
    from ethereum.udm_events
    where symbol = 'MIM'
    -- and block_timestamp > current_date - interval '180 days'
    and year(block_timestamp) = 2022
    and from_address in (select user_address from pools)
    group by 1
    )
    Run a query to Download Data