Query editor
with pool as (selectfrom_hex('0x' || substring(to_hex(topic1),25)) as tokenA,from_hex('0x' || substring(to_hex(topic2),25)) as tokenB,from_hex('0x' || substring(to_hex(data),25,40)) as pool_addressfrom arbitrum.logs--where tx_hash = 0xb41266b3bc0a29e86b0a7ebf98935a2114a5f5bdb2a9e3ffe98e6a3546965481where contract_address = 0x6eccab422d763ac031210895c81787e87b43a652 -- camelot v2 factoryand topic0 = 0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9),swapData as (selectblock_time,tx_hash as hash,tx_to as swapper,contract_address as pool_address,regexp_extract_all(to_hex(data),'.{64}') as datafrom arbitrum.logswhere contract_address in (select pool_address from pool)--where tx_hash = 0x28d96e80d3f38775f53afb250d5bace378ea51be7862f872b6df4950cd01b60dand topic0 = 0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822)selectblock_time,hash,swapper,S.pool_address,tokenA,tokenB,varbinary_to_uint256(from_hex(data[1])) as amount0in,varbinary_to_uint256(from_hex(data[2])) as amount1in,varbinary_to_uint256(from_hex(data[3])) as amount0out,varbinary_to_uint256(from_hex(data[4])) as amount1Out,case when PR.contract_address = tokenA and date(block_time) = date(PR.day) then (varbinary_to_uint256(from_hex(data[1]))/ power(10,PR.decimals)) * PR.price end as amount0In_USD,case when R.contract_address = tokenB and date(block_time) = date(R.day) then (varbinary_to_uint256(from_hex(data[2])) / power(10,R.decimals)) * R.price end as amount1In_USD,case when PR.contract_address = tokenA and date(block_time) = date(PR.day) then (varbinary_to_uint256(from_hex(data[3]))/ power(10,PR.decimals)) * PR.price end as amount0Out_USD,case when R.contract_address = tokenB and date(block_time) = date(R.day) then (varbinary_to_uint256(from_hex(data[4])) / power(10,R.decimals)) * R.price end as amount1Out_USD,PR.symbol || '/' || R.symbol as pool_namefrom swapData Sjoin pool P ON P.pool_address = S.pool_addressjoin prices.usd_daily PR ON PR.contract_address = tokenA and date(block_time) = date(PR.day)join prices.usd_daily R ON R.contract_address = tokenB and date(block_time) = date(R.day)where PR.blockchain = 'arbitrum'and R.blockchain = 'arbitrum'