binhachon22. Gainers and Losers - Liquidity losers top 10
    Updated 2022-01-11
    with sushi_pools as (
    select
    pool_address,
    pool_name
    from ethereum.dex_liquidity_pools
    where platform ilike '%sushi%'
    ),
    remove_liquidity as (
    select
    tx_id,
    from_address,
    amount_usd,
    row_number() over (partition by tx_id order by amount_usd) as rownumber
    from ethereum.udm_events
    where block_timestamp > getdate() - interval'1 day'
    and origin_function_name like '%removeLiquidity%'
    and from_address in (select pool_address from sushi_pools)
    and amount_usd > 0
    ),
    remove_liquidity_1 as (
    select
    tx_id,
    from_address,
    sum(amount_usd) as amount_usd,
    sum(rownumber) as rownumber
    from remove_liquidity
    group by tx_id, from_address
    ),
    remove_liquidity_2 as (
    select
    from_address,
    sum(case when rownumber = 1 then amount_usd * 2 else amount_usd end) as liquidity_removed
    from remove_liquidity_1
    group by from_address
    ),
    add_liquidity as (
    Run a query to Download Data