binhachonTinyman 1.1 Launch Swaps - Frequency
    Updated 2022-01-28
    with tinyman_pool_address as (
    select distinct address from algorand.account_app where app_id = 552635992
    ),
    swap_tx_group_id as (
    select
    distinct tx_group_id
    from algorand.application_call_transaction
    where tx_message:txn:apaa[0]::string = 'c3dhcA=='
    and (tx_message:txn:apaa[1]::string = 'Zmk=' or tx_message:txn:apaa[1]::string = 'Zm8=')
    and app_id = 552635992
    ),
    swap_tx_group_id_with_count as (
    select
    tx_group_id,
    count(tx_group_id) as number_of_txs
    from algorand.asset_transfer_transaction
    where tx_group_id in (select tx_group_id from swap_tx_group_id)
    group by tx_group_id
    ),
    tinyman_swap_algo_transactions as (
    select
    algorand.payment_transaction.block_id,
    algorand.block.block_timestamp,
    case when sender in (select address from tinyman_pool_address) then receiver else sender end as address,
    case when sender in (select address from tinyman_pool_address) then sender else receiver end as pool_address,
    tx_id,
    tx_group_id,
    sum(amount) as asset0_amount
    from algorand.payment_transaction
    left join algorand.block on algorand.block.block_id = algorand.payment_transaction.block_id
    where tx_group_id in (select tx_group_id from swap_tx_group_id_with_count where number_of_txs = 1)
    and amount > 0.01
    group by algorand.payment_transaction.block_id, algorand.block.block_timestamp, address, pool_address, tx_id, tx_group_id
    ),
    tinyman_swap_asset_transactions as (
    select
    Run a query to Download Data