h4wkpolygon
    Updated 2023-11-20
    with price as (
    select hour::date as price_date,
    token_address,
    symbol,
    decimals,
    avg(price) as price
    from polygon.price.ez_hourly_token_prices
    group by 1,2,3,4
    )
    , matic_price as (
    select hour::date as price_date,
    token_address,
    symbol,
    decimals,
    avg(price) as matic_price
    from polygon.price.ez_hourly_token_prices
    where symbol = 'MATIC'
    group by 1,2,3,4
    )
    , base_from_polygon as (
    select distinct tx_hash
    from polygon.core.fact_token_transfers t
    where 1 = 1
    and block_timestamp >= '2022-12-01'
    and to_address = '0xef4fb24ad0916217251f553c0596f8edc630eb66'
    )
    , from_polygon as (
    select block_timestamp::date as date,
    'From Polygon' as type,
    p.symbol,
    raw_amount/pow(10,p.decimals) as amount,
    amount*price as volume_usd,
    origin_from_address as user_address,
    tx_hash
    from polygon.core.fact_token_transfers t
    join price p ON (contract_address = token_address and block_timestamp::date = p.price_date)
    Run a query to Download Data