Query editor
/* Robinhood Chain (4663): Fusion resolver balance-delta P&L.Base: https://dune.com/queries/6457704; corrected 2026-09-06.Fusion Settlement IS deployed at 0xb55ba9617dafae1236313c3cb7806439ceefbd13.Reclassify the exact LOP call using its trace/calldata before applying modes.This repairs historical rows still labelled limits by oneinch.swaps.Standalone Fusion requires evidence for B55, even if upstream says fusion.Fusion+ also uses EscrowFactory 50d26... (current official SDK) or a02b9...(older deployment). Recover their LOP fills when decoded cross-chain rowsare missing; deduplicate only against the same transaction, LOP trace AND order hash.Default modes: fusion,cross-chain. Ordinary LOP limits are always excluded.Valuation: signed raw token deltas, normalized once using prices.hour decimals,valued at that token's independent USD price for the execution hour. There isNO order-implied price, transfer-price fallback, or assumed token decimals.Scope: transaction recipient contract plus the configured profit_accs set;both incoming and outgoing collector transfers are netted. This is an addressscope assumption, not an ownership registry or the resolver's whole business.Profit covers only same-chain transactions with all nonzero deltas priced,no blacklisted residual tokens, and ABS(net USD) within the configured cap.Cross-chain/mixed transactions count as activity only: this query does notmatch both networks/escrows and therefore cannot calculate Fusion+ profit.Missing prices/amounts/gas stay unknown. Coverage/exclusion columns explainthe subset used for profit; bps uses that SAME subset's volume. Gas excludesreverted attempts (the activity set contains successful fills only).prices.hour is a historical hourly market mark, not a hedge execution price.*/WITHbounds AS (SELECT DATE_TRUNC('{{period}}', CURRENT_TIMESTAMP)- INTERVAL '{{periods}}' {{period}} AS start_time), sel_modes AS (SELECT TRIM(x) AS mode FROM UNNEST(SPLIT('{{modes}}', ',')) AS t(x)), routers AS (SELECT * FROM (VALUES(0x111111125421ca6dc452d289314280a0f8842a65),(0x5a705de8982235a7fa45bb83dcacf03a211389c7)) AS t(address)), resolver_profit_accs AS (SELECT DISTINCT from_hex(addr) AS addressFROM UNNEST(regexp_extract_all('{{profit_accs}}', '0x[0-9A-Fa-f]{40}')) AS t(addr))/* Match the exact successful LOP call. Factory implementations inheritSettlement logic, but are classified as Fusion+ and never same-chain P&L. */, settlement_calls AS (SELECT tx_hash, trace_address,BOOL_OR("from" = 0xb55ba9617dafae1236313c3cb7806439ceefbd13OR varbinary_position(input, 0xb55ba9617dafae1236313c3cb7806439ceefbd13) > 0)AS has_fusion_settlement,BOOL_OR("from" IN (0x50d26ea1e2460b3a42ff47466b955fc6bd906013,0xa02b9cc95094bb27d1d041b9fbf09f65a366f7b3)OR varbinary_position(input, 0x50d26ea1e2460b3a42ff47466b955fc6bd906013) > 0OR varbinary_position(input, 0xa02b9cc95094bb27d1d041b9fbf09f65a366f7b3) > 0)AS has_cross_chain_settlementFROM {{blockchain}}.tracesWHERE '{{blockchain}}' = 'robinhood'