Query editor
WITH ui AS (SELECT "to" token_address,max_by(varbinary_to_uint256(output), block_time) ui_multiplier_raw,max(block_time) ui_multiplier_observed_atFROM robinhood.tracesWHERE block_date >= current_date - interval '30' dayAND successAND "to" IN (SELECT contract_address FROM query_8536264)AND bytearray_substring(input,1,4)=bytearray_substring(keccak(to_utf8('uiMultiplier()')),1,4)AND length(output)=32GROUP BY 1),dec AS (SELECT contract_address,max_by(output_0, call_block_time) feed_decimals,max(call_block_time) decimals_observed_atFROM chainlink_robinhood.dualaggregator_call_decimalsWHERE call_block_date >= current_date - interval '30' dayAND call_successGROUP BY 1),mapped AS (SELECT m.symbol, m.aggregator_address, m.feed_description, m.raw_answer,m.source_updated_at, m.observed_at,d.feed_decimals, d.decimals_observed_atFROM query_8545416 mLEFT JOIN dec d ON d.contract_address=from_hex(m.aggregator_address)WHERE m.mapping_status='EXACT_NORMALIZED_SYMBOL'),priced AS (SELECT r.*, m.aggregator_address, m.feed_description, m.raw_answer,m.feed_decimals, m.source_updated_at chainlink_updated_at,m.observed_at chainlink_observed_at,ui.ui_multiplier_raw, ui.ui_multiplier_observed_at,CASE WHEN m.aggregator_address IS NOT NULLAND m.feed_decimals IS NOT NULLAND m.source_updated_at >= current_timestamp - interval '72' hourTHEN CAST(m.raw_answer AS double)/power(10,m.feed_decimals)ELSE r.current_price END effective_price,CASE WHEN m.aggregator_address IS NOT NULLAND m.feed_decimals IS NOT NULLAND m.source_updated_at >= current_timestamp - interval '72' hourTHEN 'CHAINLINK_DIRECT_FRESH'ELSE 'PRICES_LATEST_FALLBACK' END effective_price_sourceFROM query_8536264 rLEFT JOIN mapped m ON upper(regexp_replace(r.symbol,'[^A-Za-z0-9]',''))=upper(regexp_replace(m.symbol,'[^A-Za-z0-9]',''))LEFT JOIN ui ON ui.token_address=r.contract_address)SELECT *,current_supply*effective_price effective_aum_usd,sum(current_supply*effective_price) OVER() effective_total_robinhood_aum_usd,sum(CASE WHEN effective_price_source='CHAINLINK_DIRECT_FRESH' THEN current_supply*effective_price ELSE 0 END) OVER() direct_chainlink_priced_aum_usd,sum(CASE WHEN effective_price_source='CHAINLINK_DIRECT_FRESH' THEN current_supply*effective_price ELSE 0 END) OVER()/ nullif(sum(current_supply*effective_price) OVER(),0) direct_chainlink_aum_share,CASE WHEN effective_price_source='CHAINLINK_DIRECT_FRESH' AND ui_multiplier_raw IS NOT NULLTHEN 'DIRECT_FEED_WITH_UI_MULTIPLIER_OBSERVED'WHEN effective_price_source='CHAINLINK_DIRECT_FRESH'THEN 'DIRECT_FEED__UI_MULTIPLIER_NOT_OBSERVED'ELSE 'FALLBACK_PRICE' END evidence_statusFROM priced