mehdimarjanUntitled Query
    Updated 2022-07-17
    with lending as (
    select
    symbol,
    coalesce(sum(AMOUNT_USD),0) as LogAddAsset
    from ethereum.sushi.ez_lending
    where
    LENDING_POOL like '%km%'
    -- and LENDING_POOL like '%/%-%'
    -- and symbol in ('USDC','USDT','UST','DAI')
    and action = 'Deposit'
    group by symbol
    ),

    unlending as (
    select
    symbol,
    coalesce(sum(AMOUNT_USD),0) as LogRemoveAsset
    from ethereum.sushi.ez_lending
    where
    LENDING_POOL like '%km%'
    -- and LENDING_POOL like '%/%-%'
    -- and symbol in ('USDC','USDT','UST','DAI')
    and action = 'Withdraw'
    group by symbol
    )

    select
    tbl1.symbol,
    ifnull(LogAddAsset, 0) as LogAddAsset,
    ifnull(LogRemoveAsset, 0) as LogRemoveAsset,
    LogAddAsset - LogRemoveAsset as TVL
    from lending tbl1
    left join unlending tbl2
    on tbl1.symbol = tbl2.symbol
    order by 4 desc

    Run a query to Download Data