mo115NEAR stablecoin swaps - Daily - 30Days
    Updated 2024-08-23
    -- forked from NEAR stablecoin swaps @ https://flipsidecrypto.xyz/studio/queries/17f3209b-a6bf-43e2-97d4-a16664e71541

    select date_trunc('day', BLOCK_TIMESTAMP)as "Date"
    , count (distinct TX_HASH) as "Transactions"
    , count (distinct TRADER) as "Wallets"
    , sum(AMOUNT_IN) as "Amount Swapped From"
    , case
    when TOKEN_IN_CONTRACT = 'usdt.tether-token.near' then 'USDt'
    when TOKEN_IN_CONTRACT = 'dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near' then 'USDT.e'
    when TOKEN_IN_CONTRACT = 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near' then 'USDC.e'
    when TOKEN_IN_CONTRACT = '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1' then 'USDC'
    when TOKEN_IN_CONTRACT in ('3.contract.portalbridge.near','16.contract.portalbridge.near') then 'PortalBridge USDC'
    end as "Swapped From"
    , sum(AMOUNT_OUT) as "Amount Swapped To"
    , case
    when TOKEN_OUT_CONTRACT = 'usdt.tether-token.near' then 'USDt'
    when TOKEN_OUT_CONTRACT = 'dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near' then 'USDT.e'
    when TOKEN_OUT_CONTRACT = 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near' then 'USDC.e'
    when TOKEN_OUT_CONTRACT = '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1' then 'USDC'
    when TOKEN_OUT_CONTRACT in ('3.contract.portalbridge.near','16.contract.portalbridge.near') then 'PortalBridge USDC'
    end as "Swapped To"
    , concat("Swapped From", ' --> ', "Swapped To") as swap
    , (sum(AMOUNT_OUT)-sum(AMOUNT_IN)) as diff
    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')
    and BLOCK_TIMESTAMP >= current_date -30
    group by 1,5,7


    QueryRunArchived: QueryRun has been archived