Query editor
WITHclaims AS (SELECTevt_block_time,'Deposit' AS type,amount / 1e18 AS amount,recipient as user,evt_tx_hashFROMfriendtech_v2_base.Points_evt_ClaimedAUNION ALLSELECTevt_block_time,'Deposit' AS type,amount / 1e18 AS amount,recipient as user,evt_tx_hashFROMfriendtech_v2_base.Points_evt_ClaimedB),accounting AS (SELECT_to AS user,_value / 1e18 AS amountFROM friendtech_v2_base.Points_evt_TransferUNION ALLSELECT_from AS user,-_value / 1e18 AS amountFROM friendtech_v2_base.Points_evt_TransferUNION ALLselect user, amount from claims),total_claims as(select user, sum(amount) as claim from claims group by user),balances AS (SELECTuser,SUM(amount) AS balanceFROM accountingGROUP BYuser),deposits AS (SELECTevt_block_time,'Deposit' AS type,amount / 1e18 AS amount,user,evt_tx_hash