brian-terraUntitled Query
    Updated 2023-01-12
    WITH transfers1 as (
    select distinct tx_hash,
    event_inputs:from::string as sender,
    event_inputs:to::string as receiver,
    event_inputs:tokenId::float as tokenid
    from polygon.core.fact_event_logs
    where event_name = 'Transfer'
    and contract_address = '0x09421f533497331e1075fdca2a16e9ce3f52312b' --hellcats contract
    and tx_status = 'SUCCESS'
    )
    ,
    matic_sales as (
    select date_trunc('HOUR', block_timestamp) as date,
    a.tx_hash,
    b.receiver as receiver,
    amount as amount_matic,
    amount_usd,
    tokenid
    from polygon.core.ez_matic_transfers a,transfers1 b
    where a.tx_hash = b.tx_hash
    and matic_to_address = '0xcbbecf690e030d096794f7685a1bf4a58378a575' --oneplanet contract
    ),

    matic_price as (select hour, price from ethereum.core.fact_hourly_token_prices where symbol = 'MATIC')

    ,
    usdc_sales as
    (select b.date,
    b.tx_hash,
    b.receiver as receiver,
    b.amount as amount_usd,
    b.amount/a.price as amount_matic,
    tokenid
    from matic_price a,
    (select date_trunc('HOUR', block_timestamp) as date,
    Run a query to Download Data