RamaharArbitrageurs Trend
    Updated 2022-12-12
    /* Query taken from Author :Ali3N#8546
    Modify accordingly */
    with token_price as (
    select DATE(block_timestamp) as dayz,
    from_currency as token,
    AVG ((to_amount / pow(10 , to_decimal))/(from_amount / pow(10 , from_decimal))) as average_price
    from osmosis.core.fact_swaps
    where to_currency in ('ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858') --USDC
    and to_amount > 0 and from_amount > 0 and tx_status = 'SUCCEEDED'
    and from_currency in ('ibc/3FF92D26B407FD61AE95D975712A7C319CDE28DE4D80BDC9978D935932B991D7','uosmo')
    group by 1,2),

    jointable as (
    select liquidity_provider_address,
    count (distinct tx_id) as lp_transactions,
    sum (amount * average_price / pow(10 , decimal)) as volume
    from osmosis.core.fact_liquidity_provider_actions a join token_price b on a.block_timestamp::date = b.dayz and a.currency = b.token
    where pool_id [0] = '773' and action in ('pool_joined') and tx_status = 'SUCCEEDED'
    group by 1 having lp_transactions > 5),

    exittable as (
    select liquidity_provider_address,
    count (distinct tx_id) as lp_transactions,
    sum (amount * average_price / pow(10,decimal)) as volume
    from osmosis.core.fact_liquidity_provider_actions a join token_price b on a.block_timestamp::date = b.dayz and a.currency = b.token
    where pool_id [0] = '773' and action in ('pool_exited') and tx_status = 'SUCCEEDED'
    group by 1 having lp_transactions > 5),

    Arbitrageurs as (
    select distinct a.liquidity_provider_address,
    a.lp_transactions as join_count,
    b.lp_transactions as exit_count
    from jointable a join exittable b on a.liquidity_provider_address = b.liquidity_provider_address
    order by 2 DESC
    )

    Run a query to Download Data