pietrektNon RUNE TVL in LP
    Updated 5 hours ago
    -- WITH tvls AS (select to_date(block_timestamp) as day,
    -- CASE
    -- WHEN pool_name like '%BNB%' then 'BNB'
    -- WHEN pool_name like '%ETH%' then 'ETH'
    -- WHEN pool_name like '%AVAX%' then 'AVAX'
    -- WHEN pool_name like '%BTC%' then 'BTC'
    -- WHEN pool_name like '%DOGE%' then 'DOGE'
    -- WHEN pool_name like '%BCH%' then 'BCH'
    -- WHEN pool_name like '%LTC%' then 'LTC'
    -- WHEN pool_name like '%GAIA%' then 'GAIA'
    -- WHEN pool_name like '%TERRA%' then 'TERRA'
    -- END AS label, asset_amount_usd
    -- from thorchain.defi.fact_pool_block_balances
    -- QUALIFY (block_timestamp = MIN(block_timestamp) OVER(PARTITION BY pool_name, time_slice(block_timestamp, 1, 'DAY', 'START'))))

    -- SELECT day, label, sum(asset_amount_usd) as non_rune_tvl_usd,
    -- SUM(non_rune_tvl_usd) OVER(PARTITION BY day) as total_non_rune_tvl_usd
    -- FROM tvls GROUP BY label, day ORDER BY day DESC

    with non_rune_tvl AS (SELECT day, total_value_pooled_usd / 2 as non_rune_tvl from thorchain.defi.fact_daily_tvl WHERE day is not null),

    to_rune_swaps AS (SELECT block_timestamp, tx_id, from_asset, to_asset, (liq_fee_in_rune_e8 /to_e8) * pow(10,4) as slip, from_e8 / pow(10, 8) as from_amount, to_e8 / pow(10,8) as to_amount from thorchain.defi.fact_swaps_events where block_timestamp is not null and to_asset = 'THOR.RUNE'),
    from_rune_swaps AS (SELECT block_timestamp, tx_id, from_asset, to_asset, (liq_fee_in_rune_e8 /from_e8) * pow(10,4) as slip, from_e8 / pow(10, 8) as from_amount, to_e8 / pow(10,8) as to_amount from thorchain.defi.fact_swaps_events where block_timestamp is not null and from_asset = 'THOR.RUNE'),
    -- UNIONED
    unioned AS (
    SELECT block_timestamp, tx_id, from_asset, to_asset, from_amount, to_amount, slip FROM to_rune_swaps
    UNION
    SELECT block_timestamp, tx_id, from_asset, to_asset, from_amount, to_amount, slip FROM from_rune_swaps

    ),
    union_grouped AS (SELECT to_date(block_timestamp) as day, avg(slip) as avg_slip_bp from unioned group by day),

    joined AS (SELECT a.day, a.non_rune_tvl, COALESCE(avg_slip_bp, 0) as avg_slip_bp from non_rune_tvl as a left join union_grouped as b on a.day = b.day)
    select * from joined where day > '2021-09-17' order by day DESC
    Last run: about 5 hours agoAuto-refreshes every 24 hours
    DAY
    NON_RUNE_TVL
    AVG_SLIP_BP
    1
    2025-05-20 00:00:00.00082986300.1828825.629430441
    2
    2025-05-19 00:00:00.00082842200.03601835.883638099
    3
    2025-05-18 00:00:00.00085621254.57997515.73883111
    4
    2025-05-17 00:00:00.00079566912.64457675.682828422
    5
    2025-05-16 00:00:00.00082129125.18609835.84517436
    6
    2025-05-15 00:00:00.00084876257.28095895.730797648
    7
    2025-05-14 00:00:00.00086722212.14144445.719212274
    8
    2025-05-13 00:00:00.00089914510.44850925.784827793
    9
    2025-05-12 00:00:00.00085755656.06186775.967272514
    10
    2025-05-11 00:00:00.00081818604.31356625.843795283
    11
    2025-05-10 00:00:00.00082108273.05486095.79547839
    12
    2025-05-09 00:00:00.00074431244.76770486.133476143
    13
    2025-05-08 00:00:00.00070825108.06063685.762991829
    14
    2025-05-07 00:00:00.00064704751.2464335.572304629
    15
    2025-05-06 00:00:00.00065574975.44270985.754291776
    16
    2025-05-05 00:00:00.00064260467.45085995.679655664
    17
    2025-05-04 00:00:00.00064371014.06613856.883820565
    18
    2025-05-03 00:00:00.00065036562.41510926.843731733
    19
    2025-05-02 00:00:00.00066405701.87956397.26062752
    20
    2025-05-01 00:00:00.00068421454.59992977.15368226
    ...
    1336
    74KB
    6s