Query editor
WITH native_top AS (SELECTDATE_TRUNC('day', tx.block_time) AS "Date",'INK' AS "Chain",'INK' AS "Currency",tx.value,(tx.gas_used * tx.gas_price / 1e18) AS gasFees,'INK' AS gasCurrency,tx.hash AS tx_hashFROM ink.transactions AS txWHERE --tx.block_time >= CAST('2024-12-01' AS TIMESTAMP)tx."from" = {{Address}}AND tx.value > 0),native_internal AS (SELECTDATE_TRUNC('day', tr.block_time) AS "Date",'INK' AS "Chain",'INK' AS "Currency",tr.value,(tx.gas_used * tx.gas_price / 1e18) AS gasFees,'INK' AS gasCurrency,tr.tx_hashFROM ink.traces AS trJOIN ink.transactions AS txON tr.tx_hash = tx.hashWHERE --tr.block_time >= CAST('2024-12-01' AS TIMESTAMP)tr."from" = {{Address}}AND tr.call_type = 'call'AND tr.input = 0x -- No quotes around 0xAND tr.value > 0),native_withdrawals AS (SELECT"Date","Chain","Currency",SUM(value / 1e18) AS "Amount",COUNT(*) AS "txCount(Withdrawals)",gasCurrency,SUM(gasFees) AS gasFeesFROM (SELECT * FROM native_topUNION ALLSELECT * FROM native_internal) AS combinedGROUP BY 1,2,3,6),erc20_withdrawals AS (SELECTDATE_TRUNC('day', t.evt_block_time) AS "Date",'INK' AS "Chain",COALESCE(e.symbol,CONCAT('Unknown-', LOWER(TO_HEX(t.contract_address)))) AS "Currency",SUM(t.value / POWER(10, e.decimals)) AS "Amount",COUNT(*) AS "txCount(Withdrawals)",'INK' AS gasCurrency,SUM(tx.gas_used * tx.gas_price / 1e18) AS gasFees