binhachonDynamic Rate, Mvmt. I - Curve pool
    Updated 2022-03-23
    with curve_transaction as (
    select
    block_timestamp,
    amount
    from ethereum.udm_events
    where to_address = '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7'
    and symbol in ('USDT', 'USDC', 'DAI')
    union all
    select
    block_timestamp,
    -amount
    from ethereum.udm_events
    where from_address = '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7'
    and symbol in ('USDT', 'USDC', 'DAI')
    ),
    price as (
    select
    date_trunc('week', hour) as pricetime,
    avg(price) as price
    from ethereum.token_prices_hourly
    where symbol = 'CRV'
    group by pricetime
    ),
    pool_stats as (
    select
    date_trunc('week', block_timestamp) as time,
    sum(amount) as net_inflow,
    sum(net_inflow) over (order by time) as liquidity
    from curve_transaction
    group by time
    )
    select
    pool_stats.*,
    price
    from pool_stats
    left join price on (time = pricetime)

    Run a query to Download Data