Query editor
with raw_eth_deposits as (SELECT time,token_address,token_amount,call_tx_hash,unique_depositFROM (SELECT date_trunc('day', call_block_time) as time,unique_deposit,from_hex(json_value(json_query(unique_deposit, 'lax $.token' OMIT quotes), 'lax $.tokenAddress')) as token_address,CAST(json_extract(unique_deposit,'$.value') AS DECIMAL) as token_amount,call_tx_hashFROM railgun_ethereum.RailgunLogic_call_generateDeposit, unnest(_notes) as all_deposits(unique_deposit)WHERE call_success)),raw_eth_withdraws as (SELECT time, token_address, token_amount, call_tx_hashFROM (SELECT date_trunc('day', call_block_time) as time,from_hex(JSON_QUERY(JSON_QUERY(json_query(ELEMENT_AT("_transactions", -1), 'lax $.withdrawPreimage' OMIT QUOTES), 'lax $.token' OMIT QUOTES), 'lax $.tokenAddress' OMIT QUOTES)) AS token_address,CAST(JSON_QUERY(json_query(ELEMENT_AT("_transactions", -1), 'lax $.withdrawPreimage' OMIT QUOTES), 'lax $.value') as DECIMAL) as token_amount,call_tx_hashFROM railgun_ethereum.RailgunLogic_call_transactWHERE call_success)), new_raw_eth_deposits as (-- jh : there is a newer implementation , we can send this for decoding to further optimize the query-- ShieldsSELECT date_trunc('day', block_time) as time,bytearray_substring(data, 1 + 12 + 32 * 7, 20) AS token_address,(bytearray_to_decimal(bytearray_substring(data, 1 + 12 + 32 * 9 + 4, 16))/0.9975) AS token_amount,tx_hashFROM ethereum.logs as logsWHERElogs.contract_address = 0xfa7093cdd9ee6932b4eb2c9e1cde7ce00b1fa4b9 ANDlogs.topic0 = 0xc3821e11e71307afd1d94a490660178ff37aefdd3c0514e5dd08937bd7024f34UNION ALL-- New Shield TopicSELECTdate_trunc('day', block_time) as time,bytearray_substring(data, 1 + 12 + 32 * 8, 20) AS token_address,bytearray_to_decimal(bytearray_substring(data, 1 + 12 + 32 * 10 + 4, 16))/0.9975 AS token_amount,tx_hashFROM ethereum.logs as logsWHERE logs.contract_address = 0xfa7093cdd9ee6932b4eb2c9e1cde7ce00b1fa4b9 ANDlogs.topic0 = 0x3a5b9dc26075a3801a6ddccf95fec485bb7500a91b44cec1add984c21ee6db3b), new_raw_eth_withdraws as (-- TransactSELECT time, token_address, token_amount, tx_hashFROM (-- TransactSELECTdate_trunc('day', block_time) as time, bytearray_substring(data, 1 + 12 + 32 * 2, 20) AS token_address, bytearray_to_decimal(bytearray_substring(data, 1 + 12 + 32 * 4 + 4, 16))/0.9975 AS token_amount, tx_hash