cheeyoung-kekOvertime 3
    Updated 2022-08-25
    with buy_bets as (

    select
    date_trunc('day', BLOCK_TIMESTAMP) as day,
    from_address wallet,
    raw_amount,
    CONTRACT_ADDRESS,
    count(distinct(origin_from_address)) as bets
    from optimism.core.fact_token_transfers
    where to_address='0x170a5714112daeff20e798b6e92e25b86ea603c1'
    and CONTRACT_ADDRESS ='0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9'
    and block_timestamp >= current_date - 14
    group by 1,2,3,4
    ),

    sell_bets as (

    select
    date_trunc('day', BLOCK_TIMESTAMP) as day,
    to_address wallet,
    raw_amount,
    CONTRACT_ADDRESS,
    count(distinct(origin_from_address)) as bets
    from optimism.core.fact_token_transfers
    where from_address='0x170a5714112daeff20e798b6e92e25b86ea603c1'
    and CONTRACT_ADDRESS ='0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9'
    and block_timestamp >= current_date - 14
    group by 1,2,3,4
    ),

    price as (

    select date_trunc('day', hour) as day , decimals, token_address, avg(price) price_usd
    from optimism.core.fact_hourly_token_prices
    where token_address ='0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9'
    group by 1,2,3
    Run a query to Download Data