mucryptoTVL Market Share 2024-08-06 02:47 AM
    Updated 2024-08-05
    with resps as
    (select defillama.get('/v2/historicalChainTvl', {}) as resp),

    figure as (
    select
    value:date::timestamp as date,
    value:tvl as tvl
    from resps,
    lateral flatten (input => resp:data)
    order by date desc
    limit 1),

    protocols as
    (select defillama.get('/protocols', {}) as resp),

    tvl as (
    select
    value:category as category,
    sum(value:tvl) as combined_tvl
    from protocols,
    lateral flatten (input => resp:data)
    where category = 'Uncollateralized Lending'
    group by 1)

    select
    'Rest of DeFi' as category,
    tvl,
    100 - cast(combined_tvl / tvl * 100 as decimal(38,2)) as "TVL MARKET SHARE"
    from figure
    inner join tvl

    union all

    select
    'Uncollateralized Lending' as category,
    combined_tvl as tvl,
    QueryRunArchived: QueryRun has been archived