Query editor
WITH mine_events AS (SELECTa."from" AS address,COUNT(a."value") AS mine_count,MIN(a.block_number) AS first_mineFROM ethereum.transactions AS aINNER JOIN ethereum.traces_decoded AS bON a.hash = b.tx_hashWHEREa.to = 0xE0E907e3743715294c2A5f52618d278CBc006CEdAND a.success = TRUEAND b.function_name = 'mineLiquidity'GROUP BYa."from"), claim_events AS (SELECTc."to" AS address,SUM(c."value" / 1e18) AS total_pndc_claimedFROM ethereum.transactions AS aINNER JOIN ethereum.traces_decoded AS bON a.hash = b.tx_hashINNER JOIN erc20_ethereum.evt_Transfer AS cON a.hash = c.evt_tx_hashWHEREa.to = 0xe7f01261EF9792095E22aBBF7F6f7B881D423C28 /* Pond Claims contract */AND a.success = TRUEAND b.function_name = 'claim'AND c.contract_address = 0x423f4e6138E475D85CF7Ea071AC92097Ed631eea /* $PNDC */GROUP BYc."to")SELECTme.address,DENSE_RANK() OVER (ORDER BY SUM(DISTINCT total_pndc_claimed) DESC) AS mined_rank,COALESCE(ce.total_pndc_claimed, 0) AS total_pndc_claimed,RANK() OVER (ORDER BY me.first_mine) AS mine_block_time,COALESCE(me.mine_count, 0) AS mine_countFROM mine_events AS meLEFT JOIN claim_events AS ceON me.address = ce.addressGROUP BYme.address,me.first_mine,me.mine_count,ce.total_pndc_claimedHAVINGCOALESCE(ce.total_pndc_claimed, 0) > 1ORDER BYtotal_pndc_claimed desc