Query editor
-- part of a query repo-- query name: LBTC DeFi Utilisation-- query link: https://dune.com/queries/4923884WITH lbtc_supply AS ( -- LBTCSELECTSUM(lbtc_amount) AS supplyFROM dune.lombard_protocol.result_lombard_deposits_and_withdrawals_v_2where token = 'LBTC'),lbtc_in_defi AS ( -- LBTC in DeFi (except Sui)SELECT SUM(amount) AS lbtc_in_defiFROM dune.lombard_protocol.result_lombard_lbtc_in_defi_transactions_v2 -- query_4923741),-- The DENOMINATOR no longer adds Sui separately: `lbtc_supply` above already includes it.---- Since Dune-Lombard #10 the mart carries chain='Sui' (121.57450144 LBTC on 2026-08-03, reconciled-- exactly against the on-chain treasury object - see 4844928), so `bs.supply + s.sui_total_supply`-- counted Sui twice and understated `percent_in_defi`.---- The NUMERATOR keeps its Sui term on purpose. It is not a double count: the DeFi mart-- result_lombard_lbtc_in_defi_transactions_v2 (query 4923741) contains no Sui at all, so the-- `0.98 *` term is the modelling assumption "98% of Sui LBTC sits in DeFi", owned by the dashboard,-- not an accounting duplicate. Left untouched deliberately - changing it changes what the metric-- means, which is a product decision rather than a bug fix.---- Its source stays the snapshot (query id 5162267 - digits spaced because build_lineage.py greps-- `query_<id>` out of published SQL, comments included) even though that snapshot is stale since-- 2026-07-28 and flat before 2025-12 (see the constancy measurement in 4365960). For a-- latest-value-only numerator term the staleness is a known, bounded inaccuracy; the alternative is-- to derive the Sui DeFi share from the mart, which needs the Sui pool coverage this repo does not-- yet have wired into the DeFi mart. Recorded as a follow-up, not silently changed here.sui_supply AS ( -- latest Sui LBTC (numerator term only)SELECT lbtc_total_supply AS sui_total_supplyFROM query_5162267ORDER BY date DESCLIMIT 1),totals AS ( -- correct supplySELECTl.lbtc_in_defi + 0.98 * s.sui_total_supply AS lbtc_defi_adjusted, -- + 98 % Suibs.supply AS supply_adjusted -- Sui already in martFROM lbtc_in_defi lCROSS JOIN sui_supply sCROSS JOIN lbtc_supply bs)SELECTlbtc_defi_adjusted AS lbtc_in_defi_total,supply_adjusted AS supply_total,lbtc_defi_adjusted / supply_adjusted * 100 AS percent_in_defiFROM totals