Query editor
/*Cross-protocol lending / vault take-rate benchmark.Output:- protocol- chain- market- gross_take_rate- protocol_only_take_rateInterpretation:- gross_take_rate = total share of borrower interest / vault yield taken before suppliers receive the remainder.- protocol_only_take_rate = share that appears to accrue to the protocol/DAO itself.Scaling:- Aave reserveFactor: bps, 1e4 = 100%- Morpho Vault V2 performanceFee: WAD, 1e18 = 100%- Euler EVault interestFee: bps, 1e4 = 100%- Euler protocolFeeShare: bps, 1e4 = 100%Caveats:- Aave query is event-based. Assets with no ReserveFactorChanged event are not included.- Morpho protocol_only_take_rate is NULL because performanceFee is vault/curator-level,not necessarily Morpho protocol revenue.- Euler requires EVault-level GovSetInterestFee. ProtocolConfig alone only gives the split,not the gross interest fee.*/WITH params AS (SELECTCOALESCE(NULLIF('{{blockchains}}', 'default value'),'ethereum') AS blockchain_csv,COALESCE(NULLIF('{{market_contains}}', 'default value'),'') AS market_contains),chain_filter AS (SELECT LOWER(TRIM(chain_name)) AS chainFROM paramsCROSS JOIN UNNEST(SPLIT(blockchain_csv, ',')) AS t(chain_name)),/* ========================================================== *//* AAVE V3: reserve factor *//* ========================================================== */aave_rf_events AS (SELECTLOWER(chain) AS chain,asset AS asset_address,newReserveFactor,evt_block_time,evt_block_number,evt_index,evt_tx_hash,