mo115NEAR stablecoin swaps-Total copy
    Updated 2024-08-23
    -- forked from NEAR stablecoin swaps-Total @ https://flipsidecrypto.xyz/studio/queries/952e1e81-9b02-4798-ab7b-f35ebc602cc9

    -- forked from NEAR stablecoin swaps @ https://flipsidecrypto.xyz/studio/queries/17f3209b-a6bf-43e2-97d4-a16664e71541
    with txs as (
    select ---date_trunc('day', BLOCK_TIMESTAMP)as "Date"
    TX_HASH
    , TRADER
    , AMOUNT_IN
    , AMOUNT_OUT
    , case when ((AMOUNT_OUT)-(AMOUNT_IN)) > 0 then 'Positive' else 'Negative' end as type
    from near.defi.ez_dex_swaps
    where SYMBOL_OUT in ('USDt' , 'USDT.e' ,'USDC' ,'USDC.e')
    and SYMBOL_IN in ('USDt' , 'USDT.e' ,'USDC' ,'USDC.e')
    )
    SELECT
    count (distinct TX_HASH) as "Transactions"
    , count (distinct TRADER) as "Wallets"
    , sum(AMOUNT_IN) as "Amount Swapped From"
    , sum(AMOUNT_OUT) as "Amount Swapped To"
    , (sum(AMOUNT_OUT)-sum(AMOUNT_IN)) as diff
    ,type
    from txs
    group by type

    QueryRunArchived: QueryRun has been archived