PS0G1Sales tiers between buyers on platforms in USD
    Updated 2022-09-29
    --credit alik110
    with SOLPricet as (
    select block_timestamp::date as date,
    avg (swap_to_amount/swap_from_amount) as SOLprice
    from solana.fact_swaps
    where swap_from_mint = 'So11111111111111111111111111111111111111112' --SOL
    and swap_to_mint in ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v','Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') --USDC,USDT
    and swap_to_amount > 0
    and swap_from_amount > 0
    and succeeded = 'TRUE'
    group by 1),

    Pricet as (
    select hour::date as PriceDate,
    Symbol as USDToken,
    avg (price) as USDPrice
    from optimism.core.fact_hourly_token_prices
    where Symbol in ('OP', 'ETH', 'WETH')
    group by 1,2),

    Seaport as (
    select tx_hash from optimism.core.fact_event_logs where contract_address = '0x998ef16ea4111094eb5ee72fc2c6f4e6e8647666'), --SeaPort Contract

    WETH_Table as (
    select tx_hash from optimism.core.fact_event_logs where contract_address = '0x4200000000000000000000000000000000000006'), --WETH

    Table1 as (
    select block_timestamp::date as date,
    tx_hash,
    event_inputs:to as Buyer,
    event_inputs:from as Seller,
    contract_address as Collection,
    event_inputs[0]:tokenid as Token_ID
    from optimism.core.fact_event_logs
    where event_name = 'Transfer'
    and tx_hash in (select tx_hash from Seaport)),
    Run a query to Download Data