Query editor
withf_eth as (select max_by(_F_ETH, (evt_block_number, evt_index)) as f_ethfrom liquity_ethereum.lqtystaking_evt_f_ethupdated),f_lusd as (select max_by(_F_LUSD, (evt_block_number, evt_index)) as f_lusdfrom liquity_ethereum.lqtystaking_evt_f_lusdupdated),stakes as (selectstaker as address,max_by(newStake, (evt_block_number, evt_index)) as lqty_stakedfrom liquity_ethereum.lqtystaking_evt_stakechangedgroup by 1),snapshots as (selectstakes.*,max_by(_F_ETH, (evt_block_number, evt_index)) as f_eth_snapshot,max_by(_F_LUSD, (evt_block_number, evt_index)) as f_lusd_snapshot,max(evt_block_time) as last_updatedfrom stakesjoin liquity_ethereum.lqtystaking_evt_stakersnapshotsupdated on address = _stakergroup by address, lqty_staked),v1_v2 as (selectsnapshots.*,coalesce(user, address) as staker,if(userProxy is not null, 'V2', 'V1') as verfrom snapshotsleft join liquity_v2_ethereum.governance_evt_deployuserproxy on address = userProxy)selectstaker,ver,cast(lqty_staked as double) / 1e18 as lqty_staked,cast(lqty_staked * (f_eth - f_eth_snapshot) as double) / 1e36 as unclaimed_eth,cast(lqty_staked * (f_lusd - f_lusd_snapshot) as double) / 1e36 as unclaimed_lusd,last_updatedfrom v1_v2, f_eth, f_lusdwhere lqty_staked > 0order by lqty_staked desc