Query editor
with params as (selectfrom_hex('0x4200000000000000000000000000000000000006') as weth20,from_hex('0xf739FC4094F3Df0a1Be08E2925b609F3C3Aa13c6') as feer20,from_hex('0xD09cf0982A32DD6856e12d6BF2F08A822eA5D91D') as fey20,from_hex('0x72f5565Ab147105614ca4Eb83ecF15f751Fd8C50') as vault20,from_hex('0x8EEF0dC80ADf57908bB1be0236c2a72a7e379C2d') as factory20,concat(from_hex('000000000000000000000000'), from_hex('0x4200000000000000000000000000000000000006')) as weth32,concat(from_hex('000000000000000000000000'), from_hex('0xf739FC4094F3Df0a1Be08E2925b609F3C3Aa13c6')) as feer32,concat(from_hex('000000000000000000000000'), from_hex('0xD09cf0982A32DD6856e12d6BF2F08A822eA5D91D')) as fey32,concat(from_hex('000000000000000000000000'), from_hex('0x72f5565Ab147105614ca4Eb83ecF15f751Fd8C50')) as vault32),-- Time bucketing helperbucketed as (selectl.*,date_trunc('week', l.block_time) as week,date_trunc('day', l.block_time) as dayfrom base.logs lwhere l.block_time >= current_date - interval '90' day),-- Vault fees: FeesClaimed(feeRecipient, token, amount)-- Event signature: FeesClaimed(address indexed feeRecipient, address indexed token, uint256 amount)vault_fees as (selectb.day,b.week,bytearray_ltrim(b.topic2) as token_address,bytearray_to_uint256(b.data) / 1e18 as amount,b.tx_hash,'Vault' as sourcefrom bucketed bcross join params pwhere b.contract_address = p.vault20and b.topic0 = from_hex('8a9c37f1c6ed380089808b6c2a4dfa1c09658478f02de4b3a67b8f2a8e4e85f7') -- FeesClaimedand b.topic1 = p.feer32and b.topic2 is not nulland length(b.topic2) = 32and length(b.data) = 32),-- Factory fees: ClaimTeamFees(token, recipient, amount)-- Event signature: ClaimTeamFees(address indexed token, address indexed recipient, uint256 amount)factory_fees as (selectb.day,b.week,bytearray_ltrim(b.topic1) as token_address,bytearray_to_uint256(b.data) / 1e18 as amount,b.tx_hash,'Factory' as sourcefrom bucketed bcross join params pwhere b.contract_address = p.factory20and b.topic0 = from_hex('d9d4761f75e0d0103b5cbeab941eeb443d7a56a35b5baf2a0787c03f03f4e474') -- ClaimTeamFeesand b.topic2 = p.vault32and b.topic1 is not nulland length(b.topic1) = 32