Query editor
-- List of FLP Stakers with their staking activity-- Shows all users who have staked FLP and their current balancewith deposits as (SELECT"user",sum(cast(amount as double)) / power(10, 18) as total_shares_deposited,count(*) as number_of_deposits,min(evt_block_time) as first_stake_time,max(evt_block_time) as last_stake_timeFROM flexperp_base.FLPStaking_evt_LogDepositGROUP BY "user"),-- Get unique withdrawals-- The withdrawal events are duplicated in the tablewithdrawals as (SELECTcaller as user_address,sum(cast(amount as double)) / power(10, 18) / 2.0 as total_shares_withdrawnFROM flexperp_base.FLPStaking_evt_LogWithdrawGROUP BY caller),current_balances as (SELECTd."user" as staker_address,d.number_of_deposits,d.first_stake_time,d.last_stake_time,d.total_shares_deposited,coalesce(w.total_shares_withdrawn, 0) as total_shares_withdrawn,d.total_shares_deposited - coalesce(w.total_shares_withdrawn, 0) as current_shares_balanceFROM deposits dLEFT JOIN withdrawals w ON d."user" = w.user_address)SELECTstaker_address,number_of_deposits,first_stake_time,last_stake_time,round(total_shares_deposited, 6) as total_shares_deposited,round(total_shares_withdrawn, 6) as total_shares_withdrawn,round(current_shares_balance, 6) as current_shares_balance,CASEWHEN current_shares_balance > 0.001 THEN 'Active'WHEN current_shares_balance < -0.001 THEN 'Error' -- Real negative (shouldn't happen)ELSE 'Withdrawn'END as statusFROM current_balancesORDER BY current_shares_balance DESC