elenahooZapOut_ts
    Updated 2021-09-27
    with zap_out as (
    select *
    from ethereum.udm_events
    where contract_address in ('0x577c0e7a6fa416632b66b76449d55264d57143f5',
    '0x02e75fe4e8f8531421ee22f4560664685c3f07de',
    '0xcade5569bd2946db60f23624956d209ae903de4d',
    '0xf8c8d0c5547bd213b1dd281a4f61be9a9feed87b',
    '0x9c57618bfcdfae4ce8e49226ca22a7837de64a2d',
    '0x39fe62a9915faf4ca974a4d3d568b4e01ee9df40',
    '0xb0880df8420974ef1b040111e5e0e95f05f8fee1',
    '0xc5b49abf8b164472be9486767af6b1a5586b5609',
    '0xd6b88257e91e4e4d4e990b3a858c849ef2dfde8c')
    ),
    zap_out_nodup as (
    select distinct
    block_timestamp, block_id, tx_id, origin_address, from_address, to_address, symbol, amount, amount_usd
    from ethereum.udm_events
    where tx_id in (select tx_id from zap_out)
    and origin_address = to_address
    )

    select date_trunc('week', block_timestamp) as week
    --year(block_timestamp) || '-' || month(block_timestamp) as year_month
    , symbol
    , count(tx_id) as tx_count
    , sum(amount) as amount
    , sum(amount_USD) as amount_USD
    from zap_out_nodup
    group by 1,2
    order by 1, tx_count desc