PapasotUSDC stats algofi
    Updated 2022-05-30
    -- Original author nih2 @ https://app.flipsidecrypto.com/dashboard/algofi-decentralized-lending--vB0HV

    with usdc_supply as (
    select
    date_trunc('day', block_timestamp) as daily, count(*) as supply_tx, count(distinct sender) as active_supplier, sum(amount) as usdc_supply
    -- block_timestamp, sender, amount, ay.tx_group_id
    from (
    select tx_group_id
    from algorand.application_call_transaction
    where
    block_timestamp >= '2022-01-01' and block_timestamp < '2022-05-30'
    and app_id = 465814103 -- USDC 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-01-01' and block_timestamp < '2022-05-30') as aa
    on ay.tx_group_id = aa.tx_group_id
    group by 1
    ),

    usdc_repay as (
    select
    date_trunc('day', block_timestamp) as daily, count(*) as repay_tx, count(distinct sender) as active_repayer, sum(amount) as usdc_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-01-01' and block_timestamp < '2022-05-30'
    and app_id = 465814103 -- USDC Market App
    and try_base64_decode_string(tx_message:txn:note::string) = 'Market: rb' -- Repaying
    group by 1
    Run a query to Download Data