mucrypto2024-04-24 04:06 AM
    Updated 2024-04-26
    with resps as
    (select defillama.get('/protocols', {}) as resp),

    list as (
    select
    value:category as category,
    value:parentProtocol as protocol,
    value:name as name,
    value:tvl as tvl,
    -- value:description::string as description,
    value:url::string as url
    from resps,
    lateral flatten (input => resp:data)
    where category = 'Indexes'),

    m_protocols as (
    select
    substr(protocol, 8) as protocol,
    url,
    sum(tvl) as tvl
    from list
    group by 1, 2),

    protocols as (
    select
    name,
    url,
    sum(tvl) as tvl
    from list
    where protocol is null
    group by 1, 2),

    final_list as (
    select
    protocol,
    tvl,
    QueryRunArchived: QueryRun has been archived