Afonso_Diaz2023-05-20 03:26 AM
    Updated 2023-05-20
    with t as (
    select
    recorded_hour::date as date,
    token as symbol,
    case symbol
    when 'Flow' then 'A.1654653399040a61.FlowToken'
    when 'Blocto' then 'A.0f9df91c9121c460.BloctoToken'
    when 'USDC' then 'A.b19436aae4d94622.FiatToken'
    when 'FUSD' then 'A.3c5959b568896393.FUSD'
    end as token_contract,
    avg((open + close) / 2) as price_usd
    from flow.core.fact_hourly_prices
    group by 1, 2, 3

    union all

    select
    recorded_hour::date as date,
    'stFlow' as symbol,
    'A.d6f80565193ad727.stFlowToken' as token_contract,
    avg((open + close) / 2) as price_usd
    from flow.core.fact_hourly_prices
    group by 1, 2, 3
    )

    select
    tx_id,
    a.block_timestamp,
    a.event_data:to as user,
    'Withdraw' as type,
    pool_id,
    ta.symbol as symbol0,
    tb.symbol as symbol1,
    a.event_data:amount as amount0,
    b.event_data:amount as amount1,
    amount0 * ta.price_usd as amount0_usd,
    Run a query to Download Data