Afonso_DiazRemove Liquidity by pool Overtime
    Updated 2024-11-02
    with

    main as (
    select
    tx_id,
    block_timestamp,
    from_address as user,
    split(pool_name, '-')[0] as pool_name,
    lp_action,
    nvl(rune_amount_usd, asset_amount_usd) as amount_usd
    from
    thorchain.defi.fact_liquidity_actions
    where
    split(pool_name, '-')[0] like 'BNB%'
    and block_timestamp between '{{ start_date }}' and '{{ end_date }}'
    )

    select
    date_trunc('{{ period }}', block_timestamp) as date,
    pool_name,
    count(distinct tx_id) as transactions,
    count(distinct user) as users,
    sum(amount_usd) as volume_usd,
    avg(amount_usd) as average_amount_usd,
    sum(transactions) over (partition by pool_name order by date) as cumulative_transactions,
    sum(volume_usd) over (partition by pool_name order by date) as cumulative_volume_usd
    from
    main
    where
    lp_action = 'remove_liquidity'
    group by 1, 2
    order by 1, 2


    QueryRunArchived: QueryRun has been archived