Query editor
-- stonkbox on Base, contract 0x515a693fc474b2344a9a07f4962ef33ffc253447, from block 51277954with b as (select bytearray_substring(topic1, 13, 20) as wallet,sum(bytearray_to_uint256(bytearray_substring(data, 1, 32))) as boxes_bought,sum(bytearray_to_uint256(bytearray_substring(data, 65, 32))) / 1e6 as spent_usdcfrom base.logs where contract_address = 0x515a693fc474b2344a9a07f4962ef33ffc253447 and topic0 = 0x793212bc54a93b64ad49d45a9d02304eb16c908134ea23af900d90d8bffb8783 and block_number >= 51277954group by 1), o as (select bytearray_substring(topic1, 13, 20) as wallet,count(*) as boxes_opened,sum(bytearray_to_uint256(bytearray_substring(data, 33, 32))) / 1e6 as won_usdcfrom base.logs where contract_address = 0x515a693fc474b2344a9a07f4962ef33ffc253447 and topic0 = 0xa0cb6ac2b5758d2e75f6f3fb20c12c440bc095a6ed084f08bc2633b3593b8501 and block_number >= 51277954group by 1)select coalesce(b.wallet, o.wallet) as wallet,coalesce(b.boxes_bought, 0) as boxes_bought, coalesce(b.spent_usdc, 0) as spent_usdc,coalesce(o.boxes_opened, 0) as boxes_opened, coalesce(o.won_usdc, 0) as won_usdcfrom b full outer join o on o.wallet = b.walletorder by boxes_bought desc, won_usdc desclimit 100