-- forked from ab93fb81-9964-439e-b2d7-1014766d5a51
with smart_trader as (select '{{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 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 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
(SELECT
p.recorded_hour::date as date,
a.symbol,
a.name,