Query editor
WITH T1 AS( selecttx_hash,block_time,contract_address as pool,bytearray_substring(topic1, 13, 20) as user,bytearray_to_uint256(bytearray_substring(data, 1, 32)) as amount_raw,bytearray_to_uint256(bytearray_substring(data, 33, 32)) as shares,'deposit' as actionfrom base.logswhere topic0=0xd3d9500b000f4b80b8f9aea0e7ce7d135560d7775a63356999a9f3efd4f5edf8UNION ALLselecttx_hash,block_time,contract_address as pool,bytearray_substring(topic1, 13, 20) as user,bytearray_to_uint256(bytearray_substring(data, 33, 32)) as amount_raw,bytearray_to_uint256(bytearray_substring(data, 1, 32)) as shares,'withdraw' as actionfrom base.logswhere topic0 in (0x3d4e1044bfb4a3fcf650fac9580f0b6393a3d8ce7ee8fd669f94e42bd0067549, 0x354770e7f865c755f9fd808af7814ca3995ae730bcf14887fb0b6d301b18f3f7)),decoded AS(selectA.*,B.currency ,amount_raw / pow (10 , decimals) AS Amount,symbolFROMT1 ALEFT JOIN dune.azinat.result_pools/*QUERY_4647719*/ B ON A.pool = B.POOLLEFT JOIN tokens.erc20 c ON B.currency = C.contract_address AND C.blockchain = 'base')SELECTuser ,symbol ,SUM(CASE WHEN action='deposit' THEN Amount ELSE Amount* -1 END) AS Lend_VolumeFROMdecodedWHEREpool = {{POOL_ADDRESS}}GROUP BY user,2ORDER BY 3 DESC