Query editor
with base as (selectaccount_owner,sum(total_gains) sum_gains,avg(total_gains -(-coalesce(adds_x, 0) * (price_usd_x_at_close - price_usd_x_at_open) +-coalesce(adds_y, 0) * (price_usd_y_at_close - price_usd_y_at_open))) avg_gains_vs_hodl,sum(total_gains -(-coalesce(adds_x, 0) * (price_usd_x_at_close - price_usd_x_at_open) +-coalesce(adds_y, 0) * (price_usd_y_at_close - price_usd_y_at_open))) sum_gains_vs_hodl,coalesce(sum(claimed_fees_usd), 0) sum_claimed_fees_usd,coalesce(sum(adds_x_usd), 0) + coalesce(sum(adds_y_usd), 0) sum_adds_usd,coalesce(sum(removals_x_usd), 0) + coalesce(sum(removals_y_usd), 0) sum_removals_usd,count(distinct account_position) positionsfrom dune.kagren0.result_dlmm_pn_l_v_4_gains_by_positionwhere(('{{History}}' = '30 days' and date_closed >= current_date - interval '30' day )or ('{{History}}' = '90 days' and date_closed >= current_date - interval '90' day )or '{{History}}' = 'Beginning of time')and price_null_count = 0group by account_owner),base_72h_ago as (selectaccount_owner,sum(total_gains) sum_gains,coalesce(sum(claimed_fees_usd), 0) sum_claimed_fees_usd,coalesce(sum(adds_x_usd), 0) + coalesce(sum(adds_y_usd), 0) sum_adds_usd,count(distinct account_position) positionsfrom dune.kagren0.result_dlmm_pn_l_v_4_gains_by_positionwheredate_closed <= current_date - interval '72' hourand (('{{History}}' = '30 days' and date_closed >= current_date - interval '30' day - interval '72' hour)or ('{{History}}' = '90 days' and date_closed >= current_date - interval '90' day - interval '72' hour)or '{{History}}' = 'Beginning of time')and price_null_count = 0group by account_ownerhaving(coalesce(sum(adds_x_usd), 0) + coalesce(sum(adds_y_usd), 0)) != 0and (coalesce(sum(claimed_fees_usd), 0) >= 1or '{{Show wallets with zero fees claimed}}' = 'Yes')and count(distinct account_position) >= 50and sum(total_gains) * 100 / -(coalesce(sum(adds_x_usd), 0) + coalesce(sum(adds_y_usd), 0)) >= 2.5),