boomer77lp lunax
    Updated 2021-12-20
    with lp as (
    select
    date_trunc('day',BLOCK_TIMESTAMP) as dt,
    count (distinct MSG_VALUE:sender::string) as lp_address,
    sum(MSG_VALUE:execute_msg:provide_liquidity:assets[1]:amount::string/1e6) as lunax_lp
    from terra.msgs
    where MSG_VALUE:contract::string = 'terra1zrzy688j8g6446jzd88vzjzqtywh6xavww92hy' and tx_status = 'SUCCEEDED'
    group by 1),

    deposit as (
    select
    date_trunc('day' ,BLOCK_TIMESTAMP) as dt,
    sum(MSG_VALUE:coins[0]:amount::string /1e6) as lunax_total,
    count (distinct MSG_VALUE:sender::string) as address_lunax
    from terra.msgs
    where MSG_VALUE:contract::string = 'terra1xacqx447msqp46qmv8k2sq6v5jh9fdj37az898' and tx_status = 'SUCCEEDED'
    group by 1)

    select
    a.dt, a.lp_address, a.lunax_lp,
    sum(a.lunax_lp) over (order by a.dt) as LUNAX_provided_cumulative,
    b.lunax_total, sum(b.lunax_total) over (order by a.dt) as xx, b.address_lunax,
    (xx-LUNAX_provided_cumulative) as total_lunax_issued,
    (LUNAX_provided_cumulative/xx)*100 as percentage_LP
    from lp a
    left join deposit b on a.dt = b.dt