cyphersteth Curve Pool volume
    Updated 2022-06-13
    with steth_transactions as (select
    block_timestamp,
    tx_hash,
    ((event_inputs:tokens_sold + event_inputs:tokens_bought)/2)/1e18 as eth_amount
    from ethereum.core.fact_event_logs
    where block_timestamp >= current_date() - 90
    and contract_address = '0xdc24316b9ae028f1497c275eb9192a3ea0f67022'
    and event_name = 'TokenExchange'),

    eth_price_hourly as (select
    hour,
    price
    from ethereum.core.fact_hourly_token_prices
    where hour >= current_date() - 90
    and token_address is null),

    hourly_volume as (
    select date_trunc('hour', block_timestamp) as hour,
    sum(eth_amount) as total_hourly_eth
    from steth_transactions
    group by hour
    ),

    joined_1 as (select * from hourly_volume
    left join eth_price_hourly using (hour)),

    hourly_volume_usd as (
    select *, total_hourly_eth * price as volume
    from joined_1),

    daily_volume as (
    select date_trunc('day', hour) as date,
    sum(volume) as daily_steth_eth_volume
    from hourly_volume_usd
    group by date),
    Run a query to Download Data