pandaSushi Query | Blockchain: Gnosis(Inflow)
    Updated 2023-03-19
    WITH arbitrum_raw_sushi AS --Arbitrum stable coin activities
    (
    SELECT
    BLOCK_TIMESTAMP,
    TX_HASH,
    AMOUNT_IN,
    AMOUNT_OUT,
    SYMBOL_IN,
    SYMBOL_OUT
    FROM
    arbitrum.sushi.ez_swaps
    WHERE
    (POOL_NAME ilike '%USD%' OR POOL_NAME ilike '%DAI%') AND EVENT_NAME = 'Swap'
    ),

    arbitrum_sushi AS
    (
    SELECT
    'Arbitrum' as blockchain,
    'Outflow' as swap_type,
    BLOCK_TIMESTAMP,
    TX_HASH,
    CASE WHEN SYMBOL_IN = 'USDC' then 'USDC'
    WHEN SYMBOL_IN = 'USDT' then 'USDT'
    WHEN SYMBOL_IN = 'BUSD' then 'BUSD'
    WHEN SYMBOL_IN = 'TUSD' then 'TUSD'
    WHEN SYMBOL_IN = 'DAI' then 'DAI'
    ELSE 'Others' END AS token_names,
    AMOUNT_IN * -1 * b.price as volume
    FROM
    arbitrum_raw_sushi a JOIN ethereum.core.fact_hourly_token_prices b ON (a.BLOCK_TIMESTAMP::date = b.hour::date AND a.SYMBOL_IN = b.SYMBOL)
    WHERE
    token_names != 'Others'

    UNION ALL