Datafi_2smart trader check (4.1) - Event Transfer copy
    Updated 2023-03-31
    -- forked from 54010635-fcf8-4fc3-b752-40c514462d18

    with smart_trader as (select lower('{{address}}') as address),
    raw_evt_transfer as
    (select
    'deposit' as type,
    t.*,
    c.name,
    c.symbol,
    t.raw_amount/cast(concat('1e',c.decimals) as numeric) as amount
    from ethereum.core.fact_token_transfers t
    inner join smart_trader s
    on s.address = t.to_address
    -- and symbol = '{{symbol}}'
    and contract_address = '{{token_address}}'
    and block_timestamp::date between '{{start_date}}' and '{{end_date}}'
    inner join ethereum.core.dim_contracts c
    on t.contract_address = c.address
    union all
    select
    'withdraw' as type,
    t.*,
    c.name,
    c.symbol,
    t.raw_amount/cast(concat('1e',c.decimals) as numeric) as amount
    from ethereum.core.fact_token_transfers t
    inner join smart_trader s
    on s.address = t.from_address
    -- and symbol = '{{symbol}}'
    and contract_address = '{{token_address}}'
    and block_timestamp::date between '{{start_date}}' and '{{end_date}}'
    inner join ethereum.core.dim_contracts c
    on t.contract_address = c.address),

    day_close_price as
    Run a query to Download Data