maymoth55imperial-apricot
    Updated 2025-04-11
    with tb1 as (
    select
    hour,
    price
    from ethereum.price.ez_prices_hourly
    where symbol = 'WBTC'
    and hour::date >= '2025-03-01'
    ),

    repayments as (
    select
    block_timestamp,
    tx_hash,
    from_address as borrower_address,
    regexp_substr_all(substr(input, 11), '.{64}') as segmented_input,
    ethereum.public.udf_hex_to_int(segmented_input[0])::numeric / 1e18 as repaid_musd
    from mezo.testnet.fact_traces
    where
    to_address = '0x20faea18b6a1d0fcdbccfffe3d164314744baf30'
    and left(input, 10) ilike '0x8e54c119'
    and tx_succeeded = true
    ),

    openTrove as (
    select
    m.block_timestamp,
    m.tx_hash,
    m.from_address as borrower_add,
    m.value as collateral,
    m.value * p.price as collateral_usd,
    regexp_substr_all(substr(m.input, 11), '.{64}') as segmented_data,
    ethereum.public.udf_hex_to_int(segmented_data[1])::numeric / 1e18 as debt_value
    from mezo.testnet.fact_traces m
    join tb1 p on trunc(m.block_timestamp, 'hour') = p.hour
    where m.to_address = '0x20faea18b6a1d0fcdbccfffe3d164314744baf30'
    and left(m.input, 10) ilike '0x8f09162b'
    Last run: 15 days ago
    TOTAL_INTEREST_ACCRUED
    AVG_INTEREST_PER_USER
    1
    12502.49595918950.087604638329
    1
    35B
    5s