nitsDistribution based sushi
    Updated 2022-02-05
    with user_balances as (select user_address as ua, sum(amount_usd) as total_balance
    from ethereum.erc20_balances
    where user_address in
    (select distinct from_address from (select * from
    (select from_address, pool_address, sum(net_amt) as presence from (select *, case when direction = 'IN' then amount_in else amount_out*(-1) end as net_amt from ethereum.dex_swaps
    where platform = 'sushiswap')
    where net_amt is not NULL
    GROUP by 1,2)
    where presence > '0.0001' and presence < pow(10,5))) --average user- 0-100k$
    AND balance_date = CURRENT_DATE - 1
    and amount_usd is not NULL
    GROUP by 1 )
    select distribution, avg(percent_sushi) as avg_sushi, avg(total_balance) as avg_balance, avg(amt_usd) as avg_amt_added
    from (select *, case when percent_sushi = '0' then 'a- no sushi'
    when percent_sushi > '0' and percent_sushi < '0.01' then 'b- almost no sushi'
    when percent_sushi >='0.01' and percent_sushi < '1' then 'c-less than 1%'
    when percent_sushi >='1' and percent_sushi < '10' then 'd-1-10%'
    when percent_sushi >='10' and percent_sushi < '10' then 'e-10-20%'
    when percent_sushi >='20' and percent_sushi < '30' then 'f-20-30%'
    when percent_sushi >='30' and percent_sushi < '40' then 'g-30-40%'
    when percent_sushi >='40' and percent_sushi < '50' then 'h-40-50%'
    when percent_sushi >='50' and percent_sushi < '60' then 'i-50-60%'
    when percent_sushi >='60' and percent_sushi < '70' then 'j-60-70%'
    when percent_sushi >='70' and percent_sushi < '80' then 'k-70-80%'
    when percent_sushi >='80' and percent_sushi < '90' then 'l-80-90%'
    when percent_sushi >='90' and percent_sushi < '100' then 'm-90-100%'
    when percent_sushi ='100' then 'n-100%'
    end as distribution
    from
    (select *, case when amount_usd is NULL then '0' else amount_usd end as amt_usd , amt_usd/total_balance*100 as percent_sushi
    from
    (select user_address, amount_usd from ethereum.erc20_balances
    where contract_address = '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2' and balance_date = CURRENT_DATE -1 )
    right join user_balances
    on user_address = ua))
    Run a query to Download Data