Query editor
-- Ethereum Trade USDC v3. Fixed cutoff makes the benchmark reproducible.-- Exact transfer/principal reconstruction; LP valuation is an explicit estimate.with prev as (select * from table(previous.query.result(schema => descriptor(day date, cash_delta_raw int256, supply_delta_raw int256,principal_delta_raw int256, available_raw int256, supply_raw int256,borrowed_principal_raw int256, assets_per_share_raw double,ratio_observed_at timestamp(3) with time zone,last_event_at timestamp(3) with time zone, available_usdc double,borrowed_principal_usdc double, estimated_expected_usdc double)))), checkpoint as (select coalesce(max(day) - interval '30' day, date '2023-01-01') cutofffrom prev), events as (select cast(block_time as date) day, block_time, block_number, "index",contract_address, topic0, topic1, topic2,cast(varbinary_to_uint256(varbinary_substring(data, 1, 32)) as int256) amount,case when topic0 in (0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7,0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db) then cast(varbinary_to_uint256(varbinary_substring(data, 1, 32)) as double)/ nullif(cast(varbinary_to_uint256(varbinary_substring(data, 33, 32)) as double), 0)end assets_per_share_rawfrom ethereum.logswhere block_time >= cast((select cutoff from checkpoint) as timestamp)and block_time < timestamp '2026-09-06'and ((contract_address = 0xda00000035fef4082f78def6a8903bee419fbf8eand topic0 in (0x312a5e5e1079f5dda4e95dbbd0b908b291fd5b992ef22073643ab691572c5b52,0x2fe77b1c99aca6b022b8efc6e3e8dd1b48b30748709339b65c50ef3263443e09,0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7,0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db,0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef))or (contract_address = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48and topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efand (topic1 = 0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8eor topic2 = 0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e)))), recent_daily as (select day,sum(case when contract_address = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48then (case when topic2 = 0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e then amount else int256 '0' end)- (case when topic1 = 0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e then amount else int256 '0' end)else int256 '0' end) cash_delta_raw,sum(case when contract_address = 0xda00000035fef4082f78def6a8903bee419fbf8eand topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efthen (case when topic1 = 0x0000000000000000000000000000000000000000000000000000000000000000 then amount else int256 '0' end)- (case when topic2 = 0x0000000000000000000000000000000000000000000000000000000000000000 then amount else int256 '0' end)else int256 '0' end) supply_delta_raw,sum(case topic0when 0x312a5e5e1079f5dda4e95dbbd0b908b291fd5b992ef22073643ab691572c5b52 then amountwhen 0x2fe77b1c99aca6b022b8efc6e3e8dd1b48b30748709339b65c50ef3263443e09 then -amountelse int256 '0' end) principal_delta_raw,max_by(assets_per_share_raw, row(block_number, "index"))filter (where assets_per_share_raw > 0) assets_per_share_raw,max(block_time) filter (where assets_per_share_raw > 0) ratio_observed_at,max(block_time) last_event_at