Query editor
/* The bulk of this query is forked from thesymmetrical @jacobrizzuto *//* The bulk of this query is forked from @sofiat *//* This will give you the latest prices for all token contracts */withprices as (SELECTdate_trunc('day', minute) as day,contract_address,symbol,decimals,priceFROMprices.usd_latestWHEREblockchain = 'ethereum'),/* This will give you the sum of transfers in to the wallet */balance as (SELECTe.contract_address,coalesce(cast(t.symbol as VARCHAR),cast(e.contract_address as VARCHAR)) as symbol,/* name is referenced in balances */ sum(cast(value as double) / power(10, t.decimals)) as value /* name is referenced in balances */FROMerc20_ethereum.evt_Transfer e /* named the table e */INNER JOIN tokens.erc20 t /* named the table t */ on e.contract_address = t.contract_addressand blockchain = 'ethereum'WHEREto = from_hex('')GROUP BY1,2union all/* this will stack the table generated from the query above to the table generated by the following query *//* This will give you the sum of transfers out of the wallet */SELECTe.contract_address,coalesce(cast(t.symbol as VARCHAR),cast(e.contract_address as VARCHAR)) as symbol,/* name is referenced in balances */ - sum(cast(value as double) / power(10, t.decimals)) as value /* name is referenced in balances */FROMerc20_ethereum.evt_Transfer e /* named the table e */INNER JOIN tokens.erc20 t /* named the table t */ on e.contract_address = t.contract_addressand blockchain = 'ethereum'WHERE"from" = from_hex('{{Wallet}}')GROUP BY1,2),/* This will give you the net balance of tokens in the wallet */balances as (SELECTcontract_address,symbol,sum(value) as token_balance