AlexayUntitled Query
    Updated 2022-08-02
    with solend_table as (
    select distinct a.signers[0] as wallets
    from solana.fact_transactions a
    inner join solana.dim_labels b
    on a.instructions[0]:programId = b.address
    -- last day
    where block_timestamp >= CURRENT_DATE -1
    and b.label = 'solend'
    and b.label_subtype != 'token_contract'
    and a.succeeded = 'TRUE' ),

    tokens as ( select address,label
    from solana.core.dim_labels
    where label_type ='token'),
    withdrawals as (select sum(amount) as amount, tx_from as wallet, mint
    FROM solana.core.fact_transfers
    WHERE wallet in (select * from solend_table) and mint ='So11111111111111111111111111111111111111112'--in (select address from tokens)
    group by wallet, mint
    order by wallet, mint desc
    ),

    deposits as ( select sum(amount) as amount, tx_to as wallet, mint
    from solana.core.fact_transfers
    where wallet in (select * from solend_table) and mint ='So11111111111111111111111111111111111111112'--in (select address from tokens)
    group by wallet, mint
    order by wallet, mint desc),

    swaps_out as (
    select sum(swap_from_amount) as amount, swapper as wallet, swap_from_mint as mint
    from solana.core.fact_swaps
    where wallet in (select * from solend_table) and mint ='So11111111111111111111111111111111111111112'--in (select address from tokens)
    group by wallet, mint),

    swaps_dep as (
    Run a query to Download Data