CryptoIcicleSushi-104.Celsius and Sushi - LPing
    Updated 2022-07-12
    -- Celsius and Sushi
    -- Payout 66.372 SUSHI
    -- Grand Prize 199.12 SUSHI
    -- Level Intermediate

    -- Q104. Find out what Celsius platform has done on sushi (swaps, lending, LP'ing, farming).
    -- Make sure to use cross-chain tables as much as possible to capture data on all chains.
    -- currently, we have swaps, lending, and borrowing data cross-chain.
    -- Hint: you can find all addresses belonging to Celsius network by querying this table: flipside_prod_db.crosschain.address_labels
    -- NOTE: This bounty will be paid on the ETH network. Please give your Sushiswap address on ETH when submitting

    with wallets as (
    select address
    from crosschain.address_labels
    where address_name = 'celsius wallet'
    ),
    pools as (
    select
    pool_name,
    pool_address
    from ethereum.core.dim_dex_liquidity_pools
    where platform = 'sushiswap'
    group by pool_name, pool_address
    )

    select
    date_trunc('day',block_timestamp) as date,
    pool_name,
    count(distinct(tx_hash)) as txn_volume,
    Rank() over (Partition BY date ORDER BY txn_volume DESC ) AS txn_volume_rank
    from ethereum.core.fact_event_logs e
    join pools t on t.pool_address = origin_to_address
    join wallets w on w.address = origin_from_address
    where origin_function_signature = '0xf305d719' -- Add Liquidity
    group by date, pool_name
    qualify txn_volume_rank <= 10
    Run a query to Download Data