charliemarketplaceKPI-stablecoin_borrow_volume
    Updated 2 days ago

    WITH stablecoins AS (
    SELECT tokens
    FROM (VALUES
    ('a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near'),
    ('853d955acef822db058eb8505911ed77f175b99e.factory.bridge.near'), -- frax
    ('17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1'),
    ('dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near'),
    ('usdt.tether-token.near')
    ) AS s(tokens)
    )

    select
    date_trunc('week', block_timestamp) as week_,
    case
    when amount_usd >= 1000000 then '$1M+'
    when amount_usd >= 100000 then '$100k - $999k'
    when amount_usd >= 10000 then '$10k - $99k'
    when amount_usd >= 1000 then '$1k - $9.9k'
    else '$0 - $999' end as size_,
    case
    when amount_usd >= 1000000 then 'ee'
    when amount_usd >= 100000 then 'dd'
    when amount_usd >= 10000 then 'cc'
    when amount_usd >= 1000 then 'bb'
    else 'aa' end as size_order,
    sum(amount_usd) as borrow_usd_volume,
    avg(amount_usd) as avg_borrow_usd_amount,
    count(distinct sender_id) as n_borrowers
    from near.defi.ez_lending
    where block_timestamp >= '2024-01-01'
    and actions = 'borrow'
    and amount_usd IS NOT NULL
    and token_address IN (select tokens from stablecoins)
    group by week_, size_, size_order
    order by week_ asc, size_order asc

    Last run: 2 days ago
    WEEK_
    SIZE_
    SIZE_ORDER
    BORROW_USD_VOLUME
    AVG_BORROW_USD_AMOUNT
    N_BORROWERS
    1
    2024-01-01 00:00:00.000$0 - $999aa19478.392243398190.96462983730
    2
    2024-01-01 00:00:00.000$1k - $9.9kbb104720.3163438113173.34291950913
    3
    2024-01-01 00:00:00.000$10k - $99kcc146212.69455857729242.5389117154
    4
    2024-01-01 00:00:00.000$100k - $999kdd596718.477753616198906.1592512051
    5
    2024-01-08 00:00:00.000$0 - $999aa13413.943565411149.04381739334
    6
    2024-01-08 00:00:00.000$1k - $9.9kbb78758.4017601922812.80006286414
    7
    2024-01-08 00:00:00.000$10k - $99kcc238754.73027946347750.9460558934
    8
    2024-01-08 00:00:00.000$100k - $999kdd724011.43567621144802.2871352423
    9
    2024-01-15 00:00:00.000$0 - $999aa11174.649481975171.91768433827
    10
    2024-01-15 00:00:00.000$1k - $9.9kbb88466.260716484212.6790817379
    11
    2024-01-15 00:00:00.000$10k - $99kcc684209.3288639245613.9552575954
    12
    2024-01-15 00:00:00.000$100k - $999kdd672398.742439159168099.685609793
    13
    2024-01-22 00:00:00.000$0 - $999aa32304.718935837199.41184528336
    14
    2024-01-22 00:00:00.000$1k - $9.9kbb34697.7101127113154.3372829745
    15
    2024-01-22 00:00:00.000$10k - $99kcc177542.59960598729590.4332676645
    16
    2024-01-22 00:00:00.000$100k - $999kdd100152.064689453100152.0646894531
    17
    2024-01-29 00:00:00.000$0 - $999aa9643.834520734301.36982877317
    18
    2024-01-29 00:00:00.000$1k - $9.9kbb20410.4596233042267.8288470345
    19
    2024-01-29 00:00:00.000$10k - $99kcc33994.04011178533994.0401117851
    20
    2024-02-05 00:00:00.000$0 - $999aa13365.947688033247.51754977826
    ...
    250
    20KB
    22s