binhachonSolend - Total activity of SOL market
    Updated 2022-03-01
    with lending_transactions as (
    select
    block_timestamp,
    posttokenbalances[0]:mint::string as token,
    posttokenbalances[0]:uiTokenAmount:decimals::float as decimals,
    inner_instruction:instructions[0]:parsed:info:amount::float as raw_amount,
    raw_amount/pow(10, decimals) as amount,
    inner_instruction:instructions[0]:parsed:info:authority::string as address,
    inner_instruction:instructions[0]:parsed:info:source::string as account
    from solana.events
    where block_timestamp::date > '2021-08-01' --Solend mainet Aug 13th
    and instruction:programId::string = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
    and inner_instruction:instructions[1]:parsed:type::string = 'mintTo'
    and inner_instruction:instructions[1]:parsed:info:mintAuthority::string = 'DdZR6zRFiUt4S5mg7AV1uKB2z1f1WzcNYCaTEEWPAuby'
    and inner_instruction:instructions[0]:parsed:type::string = 'transfer'
    ),
    borrow_transactions as (
    select
    block_timestamp,
    posttokenbalances[0]:mint::string as token,
    posttokenbalances[0]:uiTokenAmount:decimals::float as decimals,
    inner_instruction:instructions[0]:parsed:info:amount::float + inner_instruction:instructions[1]:parsed:info:amount::float as raw_amount,
    raw_amount/pow(10, decimals) as amount,
    posttokenbalances[1]:owner::string as address,
    inner_instruction:instructions[1]:parsed:info:destination::string as account
    from solana.events
    where block_timestamp::date > '2021-08-01' --Solend mainet Aug 13th
    and instruction:programId::string = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
    and inner_instruction:instructions[0]:parsed:type::string = 'transfer'
    and inner_instruction:instructions[0]:parsed:info:authority::string = 'DdZR6zRFiUt4S5mg7AV1uKB2z1f1WzcNYCaTEEWPAuby' --Solend address
    and inner_instruction:instructions[0]:parsed:info:source::string = inner_instruction:instructions[1]:parsed:info:source::string
    and inner_instruction:instructions[1]:parsed:type::string = 'transfer'
    and inner_instruction:instructions[1]:parsed:info:authority::string = 'DdZR6zRFiUt4S5mg7AV1uKB2z1f1WzcNYCaTEEWPAuby'
    ),
    repay_transactions as (
    select
    Run a query to Download Data