KARTODTop 10 users, who Borrowed SOL and USDC to Solend
    Updated 2022-07-03
    with sol as (
    select
    date_trunc('day', block_timestamp) as day,
    SIGNERS[0] as users,
    sum(INNER_INSTRUCTIONS[0]:instructions[1]:parsed:info:amount/1e9) as sol_borrowed
    from solana.core.fact_transactions
    where INSTRUCTIONS[1]:programId = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'--
    and INNER_INSTRUCTIONS[0]:instructions[0]:parsed:info:authority = 'DdZR6zRFiUt4S5mg7AV1uKB2z1f1WzcNYCaTEEWPAuby'
    and PRE_TOKEN_BALANCES[0]:mint = 'So11111111111111111111111111111111111111112'
    and succeeded = 'TRUE'
    and day >= '2022-01-01'
    group by 1,2
    ),

    usdc as (
    select date_trunc('day', block_timestamp) as day, SIGNERS[0] as users,
    sum(INNER_INSTRUCTIONS[0]:instructions[1]:parsed:info:amount/1e6) as usdc_borrowed
    -- count(distinct(pretokenbalances[0]:owner))
    from solana.core.fact_transactions
    where INSTRUCTIONS[1]:programId = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'--
    and INNER_INSTRUCTIONS[0]:instructions[0]:parsed:info:authority = 'DdZR6zRFiUt4S5mg7AV1uKB2z1f1WzcNYCaTEEWPAuby'
    and POST_TOKEN_BALANCES[0]:mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
    and succeeded = 'TRUE'
    and day >= '2022-01-01'
    group by 1,2
    ),

    solprice as (select date_trunc('day', block_timestamp) as day,
    avg(swap_to_amount/swap_from_amount) as sol_price
    from solana.core.fact_swaps
    where day >= '2022-01-01'
    and swap_from_mint = 'So11111111111111111111111111111111111111112' --wSOL
    and swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' --USDC
    and swap_to_amount > 0
    and swap_from_amount > 0
    and succeeded = 'TRUE'
    Run a query to Download Data