pietrektCollateral Amount
    Updated 2025-04-27
    with prices AS (select to_date(block_timestamp) as day,
    pool_name,
    avg(asset_usd) as asset_usd from thorchain.price.fact_prices
    group by day, pool_name),

    ------------------------------------
    collateral_deposits AS (select to_date(block_timestamp) as day,
    collateral_asset,
    collateral_deposited / POW(10, 8) as collateral_deposited,
    owner
    from thorchain.defi.fact_loan_open_events
    WHERE day IS NOT null),

    collateral_deposits_grouped AS (select day,
    collateral_asset,
    SUM(collateral_deposited) as collateral_deposited
    from collateral_deposits group by day, collateral_asset),

    --------------------------------------

    collateral_redeems AS (SELECT to_date(block_timestamp) as day,
    collateral_asset,
    collateral_withdrawn / POW(10, 8) as collateral_withdrawn,
    owner
    from thorchain.defi.fact_loan_repayment_events
    WHERE day IS NOT null),

    collateral_redeems_grouped AS (SELECT day,
    collateral_asset,
    SUM(collateral_withdrawn) as collateral_withdrawn
    from collateral_redeems group by day, collateral_asset),

    --------------------------------------

    unioned_collateral AS (
    SELECT day, collateral_asset, COALESCE(collateral_deposited, 0) as collateral_change_p FROM collateral_deposits_grouped
    Last run: about 1 month ago
    DAY
    COLLATERAL_ASSET
    COLLATERAL_AMOUNT_USD
    CUMULATIVE_BY_ASSET_COLLATERAL_AMOUNT_USD
    CUMULATIVE_COLLATERAL_AMOUNT_USD
    1
    2025-01-24 00:00:00.000BTC.BTC-905510.573802312128340292.693978174908380.899277
    2
    2025-01-24 00:00:00.000ETH.ETH-10080.38397079646568088.2052983174908380.899277
    3
    2025-01-23 00:00:00.000BTC.BTC-168435.524548943126676552.51479171398701.501821
    4
    2025-01-23 00:00:00.000ETH.ETH-12439453.260952844722148.9870309171398701.501821
    5
    2025-01-22 00:00:00.000BTC.BTC-10680.131104653128832473.471173186981707.52634
    6
    2025-01-22 00:00:00.000ETH.ETH-91038.80275215758149234.0551664186981707.52634
    7
    2025-01-21 00:00:00.000BTC.BTC-5293.836496381127591483.488521127591483.488521
    8
    2025-01-20 00:00:00.000BTC.BTC-120418.220586841128713578.058324128713578.058324
    9
    2025-01-19 00:00:00.000BTC.BTC-489609.12228267128495579.518573186797076.239504
    10
    2025-01-19 00:00:00.000ETH.ETH-236488.51300941758301496.7209315186797076.239504
    11
    2025-01-18 00:00:00.000BTC.BTC-2187391.50685261128002976.01802186850182.137468
    12
    2025-01-18 00:00:00.000ETH.ETH-118648.24103634658847206.1194478186850182.137468
    13
    2025-01-17 00:00:00.000ETH.ETH-403180.14680946160523471.497632189740968.694314
    14
    2025-01-17 00:00:00.000BTC.BTC-190752.276202518129217497.196682189740968.694314
    15
    2025-01-16 00:00:00.000ETH.ETH-57999.48661184559911066.3068394185103716.682069
    16
    2025-01-16 00:00:00.000BTC.BTC-113783.047812467125192650.375229185103716.682069
    17
    2025-01-15 00:00:00.000BTC.BTC-509073.221854476123428317.951037182303565.382759
    18
    2025-01-15 00:00:00.000ETH.ETH-204909.79248062958875247.431722182303565.382759
    19
    2025-01-14 00:00:00.000ETH.ETH-98558.17399913257472655.6421249178680390.227001
    20
    2025-01-14 00:00:00.000BTC.BTC-2918291.2390253121207734.584876178680390.227001
    ...
    821
    70KB
    4s