charliemarketplaceKPI - Stable Sales to non-stables sized
    Updated 9 hours ago
    -- forked from KPI-sell_volume_by_size @ https://flipsidecrypto.xyz/studio/queries/aa31c2ec-2c86-4cee-944a-a68380fa4854
    WITH stablecoins AS (
    SELECT tokens
    FROM (VALUES
    ('a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near'), -- bridged USDC
    ('853d955acef822db058eb8505911ed77f175b99e.factory.bridge.near'), -- frax
    ('17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1'), -- native USDC
    ('dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near'), -- bridged tether
    ('usdt.tether-token.near') -- native USDT
    ) AS s(tokens)
    )
    SELECT
    DATE_TRUNC('month', block_timestamp) AS month_,
    case
    when amount_in_usd >= 1000000 then '$1M+'
    when amount_in_usd >= 100000 then '$100-999k'
    when amount_in_usd >= 10000 then '$10-99k'
    when amount_in_usd >= 1000 then '$1-9.9k'
    else '$0-999' end as size_,
    case
    when amount_in_usd >= 1000000 then '5'
    when amount_in_usd >= 100000 then '4'
    when amount_in_usd >= 10000 then '3'
    when amount_in_usd >= 1000 then '2'
    else '1' end as size_order,
    sum(
    case when token_in_contract IN (select tokens from stablecoins)
    then amount_in_usd else 0 end
    ) as stable_to_nonstable_volume_usd_in_size,
    sum(
    case when token_in_contract = 'wrap.near'
    then amount_in_usd else 0 end
    ) as wnear_to_nonstable_volume_usd_in_size
    from near.defi.ez_dex_swaps
    where block_timestamp >= '2024-01-01'
    and amount_in_usd IS NOT NULL
    Last run: about 9 hours agoAuto-refreshes every 12 hours
    MONTH_
    SIZE_
    SIZE_ORDER
    STABLE_TO_NONSTABLE_VOLUME_USD_IN_SIZE
    WNEAR_TO_NONSTABLE_VOLUME_USD_IN_SIZE
    1
    2024-01-01 00:00:00.000$0-99914924090.353641934726415.30635918
    2
    2024-01-01 00:00:00.000$1-9.9k21354327.465652981253616.00666338
    3
    2024-01-01 00:00:00.000$10-99k3173660.881446144744928.128444334
    4
    2024-01-01 00:00:00.000$100-999k401263325.94389336
    5
    2024-02-01 00:00:00.000$0-99914693869.063246893105137.53194959
    6
    2024-02-01 00:00:00.000$1-9.9k2953503.402479735806901.460236488
    7
    2024-02-01 00:00:00.000$10-99k322685.015956481202916.908920172
    8
    2024-02-01 00:00:00.000$100-999k400
    9
    2024-03-01 00:00:00.000$0-999122161922.121738618248697.708032
    10
    2024-03-01 00:00:00.000$1-9.9k216442994.51225796327237.77079537
    11
    2024-03-01 00:00:00.000$10-99k32072693.748494532097709.98372182
    12
    2024-03-01 00:00:00.000$100-999k4527114.6139764373131154.98603816
    13
    2024-04-01 00:00:00.000$0-999118093325.71721948730968.2656162
    14
    2024-04-01 00:00:00.000$1-9.9k211022923.01784352210119.65655272
    15
    2024-04-01 00:00:00.000$10-99k31047616.70215694709920.116266018
    16
    2024-04-01 00:00:00.000$100-999k403593801.94720866
    17
    2024-05-01 00:00:00.000$0-999114441628.61579226041187.49942641
    18
    2024-05-01 00:00:00.000$1-9.9k28263183.494453281446567.87059742
    19
    2024-05-01 00:00:00.000$10-99k3594185.242924568873651.140191196
    20
    2024-05-01 00:00:00.000$100-999k401123881.06928134
    64
    4KB
    27s