Yousefi_1994Total StableCoin supply on Algorand is being lent or borrowed
    Updated 2022-06-03
    with supplying_list as (
    select
    'lent' as type,
    case
    when transfer.asset_id = 312769 then 'Tether USD (USDT)'
    when transfer.asset_id = 31566704 then 'USD Coin (USDC)'
    when transfer.asset_id = 2757561 then 'realioUSD (rUSD)'
    end as stable_coin,
    sum(transfer.asset_amount/1e6) as amount
    from algorand.application_call_transaction application
    left join algorand.asset_transfer_transaction transfer using(tx_group_id)
    where try_base64_decode_string(application.tx_message:txn:note::string) = 'Market: mt'
    and transfer.asset_id in (312769, 31566704, 2757561)
    group by type, stable_coin
    having amount > 0
    ),
    borrowing_list as (
    select
    'borrowed' as type,
    case
    when transfer.asset_id = 312769 then 'Tether USD (USDT)'
    when transfer.asset_id = 31566704 then 'USD Coin (USDC)'
    when transfer.asset_id = 2757561 then 'realioUSD (rUSD)'
    end as stable_coin,
    sum(transfer.asset_amount/1e6) as amount
    from algorand.application_call_transaction application
    left join algorand.asset_transfer_transaction transfer using(tx_group_id)
    where try_base64_decode_string(application.tx_message:txn:note::string) = 'Market: b'
    and transfer.asset_id in (312769, 31566704, 2757561)
    group by type, stable_coin
    having amount > 0
    )
    select * from supplying_list
    union
    select * from borrowing_list


    Run a query to Download Data