KaskoazulBridge Transfers with direction
    Updated 2022-11-23
    with app_calls as (
    SELECT tx_group_id,
    tx_sender as app_caller,
    count(1) as number_calls
    FROM algorand.core.ez_transaction_application_call
    WHERE block_timestamp > CURRENT_DATE - {{days}}
    AND app_id = 842126029
    GROUP BY 1,2
    ),
    -- token_bridge app id (Portal in Algoexplorer)
    -- https://github.com/wormhole-foundation/wormhole/blob/dev.v2/sdk/js/src/utils/consts.ts
    --algorand: {
    -- core: "842125965",
    -- token_bridge: "842126029",
    -- nft_bridge: undefined,
    transactions_raw as (
    SELECT tr.block_timestamp,
    tr.tx_group_id,
    tr.tx_id,
    tr.inner_tx,
    tr.tx_sender,
    tr.asset_receiver,
    ac.app_caller,
    case ac.app_caller
    when tr.asset_receiver then 'bridge_in'
    else 'bridge_out'
    end as direction,
    ac.number_calls,
    tr.fee,
    tr.asset_id,
    tr.asset_name,
    tr.asset_amount / pow(10,tr.decimals) as amount,
    amount * ps.price_usd as amount_usd,
    tr.tx_message
    FROM algorand.core.ez_transaction_asset_transfer tr
    Run a query to Download Data