CryptoIcicleSushi-65.Kashi TVL
    Updated 2022-04-11
    -- Kashi TVL
    -- Payout 27.1 SUSHI
    -- Grand Prize 81.3 SUSHI
    -- Level Intermediate
    -- Q65. What is the Total Value Locked (TVL) by liquidity pool on Kashi? draw a weekly chart for 2022. what are the top 10 pools?

    with token_price as (
    select
    date_trunc('week',hour) as date,
    token_address,
    symbol,
    avg(price) as price
    from ethereum.token_prices_hourly
    where hour >= '2022-01-01'
    group by date, symbol, token_address
    ),
    kashi_txns as (
    select
    distinct tx_id
    -- distinct contract_name, contract_address
    from ethereum.events_emitted
    where
    block_timestamp::date >= '2022-01-01'
    and contract_name like 'KashiPair%'
    ),
    lending_txns as (
    select
    t.date,
    t.symbol as token,
    sum((event_inputs:amount * t.price)/1e18) as tvl,
    sum(tvl) over (partition by token order by date asc rows between unbounded preceding and current row) as cum_tvl

    -- e.*
    from ethereum.events_emitted e
    join ethereum.labels l on event_inputs:token = l.address
    join token_price t on event_inputs:token = t.token_address and t.date = date_trunc('week',block_timestamp)
    Run a query to Download Data