Query editor
WITH wallet_list AS (SELECT DISTINCT lower(to_hex(wallet)) AS wallet_addressFROM query_5668238),celo_price AS (SELECT priceFROM prices_external.minuteWHERE symbol = 'CELO'AND blockchain = 'celo'ORDER BY timestamp DESCLIMIT 1),kiln_deposits AS (SELECTlower(to_hex(d.sender)) AS wallet_address,SUM(CAST(d.assets AS DOUBLE)) / 1e6 AS deposited,SUM(CAST(d.shares AS DOUBLE)) / 1e6 AS shares_mintedFROM kiln_defi_production_celo.vault_v1_2_evt_deposit dJOIN wallet_list wlON lower(to_hex(d.sender)) = wl.wallet_addressGROUP BY 1),kiln_withdrawals AS (SELECTlower(to_hex(w.receiver)) AS wallet_address,SUM(CAST(w.assets AS DOUBLE)) / 1e6 AS withdrawn,SUM(CAST(w.shares AS DOUBLE)) / 1e6 AS shares_burnedFROM kiln_defi_production_celo.vault_v1_2_evt_withdraw wJOIN wallet_list wlON lower(to_hex(w.receiver)) = wl.wallet_addressGROUP BY 1)SELECT'0x' || d.wallet_address AS wallet_address,d.deposited AS total_deposited,COALESCE(w.withdrawn, 0) AS total_withdrawn,d.deposited - COALESCE(w.withdrawn, 0) AS net_balance,d.shares_minted - COALESCE(w.shares_burned, 0) AS net_sharesFROM kiln_deposits dLEFT JOIN kiln_withdrawals wON d.wallet_address = w.wallet_addressORDER BY 4 DESC