mucryptoTVL market share of lending protocols
    Updated 2023-11-08
    with resps as
    (select defillama.get('/protocols', {}) as resp),

    partial_list as (select
    value:description::string as description,
    value:category::string as category,
    value:name::string as project_name,
    case when project_name = 'Mango Markets V4' then 'Mango Markets'
    end as name,
    value:tvl as tvl
    from resps,
    lateral flatten (input => resp:data)
    where category = 'Lending'
    and name not in ('AAVE V1', 'AAVE V2','AAVE V3','Aave Arc', 'Compound', 'Compound V3'
    ,'Morpho Aave','Morpho AaveV3','Morpho Compound', 'Venus', 'Venus Isolated Pools',
    'Radiant V1', 'Radiant V2', 'Lodestar V1','Lodestar V0', 'Mare Finance V1',
    'Mare Finance V2', 'Tropykus RSK', 'Tropykus zkEVM')),

    venus as (
    select
    value:description::string as description,
    value:category::string as category,
    value:name::string as project_name,
    case when project_name = 'Venus' then 'Venus Finance'
    end as name,
    value:tvl as tvl
    from resps,
    lateral flatten (input => resp:data)
    where category = 'Lending'
    and project_name in ('Venus','Venus Isolated Pools')),

    aave as (
    select
    value:description::string as description,
    value:category::string as category,
    value:name::string as project_name,
    Run a query to Download Data