CryptoIcicleSushi-103.Fees on Kashi Markets - Polygon
    Updated 2022-07-10
    -- Fees on Kashi Markets
    -- Q103. How much fees each Kashi market has generated and which are the top markets in terms of fees generated?

    -- Payout 44.248 SUSHI
    -- Grand Prize 132.74 SUSHI
    -- Level Beginner

    -- Hint: you can use the cross-chain sushi ez_lending and ez_borrowing.
    -- Note: Currently the polygon data is only showing the recent months.
    -- We will back-fill the data in the future. Make sure your dashboard mentions the starting date on polygon data.

    with eth_price as (
    select
    date_trunc('day', hour) as date,
    avg(price) as price
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'WETH' and hour >= '{{start_date}}'
    group by date
    ),
    matic_price as (
    select
    date_trunc('day', hour) as date,
    avg(price) as price
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'MATIC' and hour >= '{{start_date}}'
    group by date
    ),
    borrowing_lending_txns as (
    (
    select
    tx_hash,
    concat('Borrow::',lending_pool) as category
    from polygon.sushi.ez_borrowing
    ) union (
    select
    tx_hash,
    Run a query to Download Data