Query editor
-- Enosys Loans (Liquity v2 fork), FXRP collateral branch: interest rate paid by borrowers, daily.-- TroveManager 0xc46e7d05… (ActivePool 0x65c378bf…); debt token CDP (Enosys Loans' stablecoin).-- Borrowers set their own annual rate per loan (trove). For each day-end, every trove's latest-- TroveUpdated(troveId, debt, coll, stake, annualInterestRate, …) gives its debt and rate; open = debt > 0.-- debt_weighted_rate_pct = sum(debt x rate) / sum(debt) -> what the borrowed CDP pays on average-- (same as ActivePool aggWeightedDebtSum / aggRecordedDebt; 7.20% on 2026-11-30)-- simple_avg / median = per-loan, unweighted (many small loans carry high rates)-- TroveUpdated debt excludes interest accrued since the trove's last update; fine for a rate distribution.with u as (select bytearray_to_uint256(topic1) as trove_id, block_time,cast(bytearray_to_uint256(bytearray_substring(data, 1, 32)) as double) / 1e18 as debt,cast(bytearray_to_uint256(bytearray_substring(data, 97, 32)) as double) / 1e16 as rate_pctfrom flare.logswhere contract_address = 0xc46e7d0538494feb82b460b9723daba0508c8fb1and topic0 = 0x0fba2673863b12c7b8463f3fa2f9b0cb1d534c573cdec5b5d895ee00d6ce6f5e),cp as (select d from unnest(sequence((select cast(min(block_time) as date) from u), current_date, interval '1' day)) as t(d)),l as (select cp.d, u.trove_id, max_by(u.debt, u.block_time) as debt, max_by(u.rate_pct, u.block_time) as rate_pctfrom cp join u on u.block_time < cp.d + interval '1' daygroup by 1, 2)select d as day,sum(debt * rate_pct) / sum(debt) as debt_weighted_rate_pct,avg(rate_pct) as simple_avg_rate_pct,approx_percentile(rate_pct, 0.5) as median_rate_pct,sum(debt) as total_debt_cdp,count(*) as open_loansfrom l where debt > 0group by 1 order by 1