Afonso_Diaz2023-04-30 08:58 PM
    Updated 2023-05-06
    with

    t1 as (
    select recorded_hour::date as date,
    symbol,
    avg(close) as price_usd
    from solana.core.fact_token_prices_hourly
    where symbol in ('RLB', 'SOL')
    group by 1, 2
    ),

    t2 as (
    select
    tx_id,
    block_timestamp,
    'Deposit' as type,
    iff(mint = 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a', 'RLB', 'SOL') as symbol,
    tx_from as user,
    amount * price_usd as amount_usd
    from solana.core.fact_transfers a
    join solana.core.dim_labels b
    on address = mint
    join t1 on t1.date = block_timestamp::date and t1.symbol = iff(mint = 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a', 'RLB', 'SOL')
    where tx_to = 'RBHdGVfDfMjfU6iUfCb1LczMJcQLx7hGnxbzRsoDNvx' --Rollbit
    and mint in ('So11111111111111111111111111111111111111112', 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a')

    union all

    select
    tx_id,
    block_timestamp,
    'Withdraw' as type,
    iff(mint = 'RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a', 'RLB', 'SOL') as symbol,
    tx_to as user,
    amount * price_usd as amount_usd
    from solana.core.fact_transfers a
    Run a query to Download Data