PapasotSTBL borrowing and lending
    Updated 2022-05-18
    -- Original author = Analyst nih2

    -- Past submission - https://app.flipsidecrypto.com/dashboard/algofi-decentralized-lending--vB0HV

    with stbl_supply as (
    select
    date_trunc('day', block_timestamp) as daily, count(*) as supply_tx, count(distinct sender) as active_supplier, sum(amount) as stbl_supply
    -- block_timestamp, sender, amount, ay.tx_group_id
    from (
    select tx_group_id
    from algorand.application_call_transaction
    where
    block_timestamp >= '2022-05-08' and block_timestamp < '2022-05-15'
    and app_id = 465814278 -- STBL Market App
    and try_base64_decode_string(tx_message:txn:note::string) = 'Market: mt' -- Providing liquidity
    group by 1
    ) as ay
    left join (
    select
    block_timestamp, sender, asset_amount/1e6 as amount, tx_id, tx_group_id
    from algorand.asset_transfer_transaction
    where block_timestamp >= '2022-05-08' and block_timestamp < '2022-05-15') as aa
    on ay.tx_group_id = aa.tx_group_id
    group by 1
    ),

    stbl_repay as (
    select
    date_trunc('day', block_timestamp) as daily, count(*) as repay_tx, count(distinct sender) as active_repayer, sum(amount) as stbl_repay
    -- block_timestamp, sender, asset_amount/1e6 as amount, sr.tx_group_id
    from (
    select tx_group_id
    from algorand.application_call_transaction
    where
    block_timestamp >= '2022-05-08' and block_timestamp < '2022-05-15'
    and app_id = 465814278 -- STBL Market App
    Run a query to Download Data