bergOverTime copy
    Updated 2024-01-31
    WITH PRICES AS (
    SELECT
    TRUNC(hour, 'DAY') as DATE_TIME,
    symbol,
    AVG(PRICE) AS PRICE
    FROM crosschain.price.ez_hourly_token_prices
    WHERE symbol like Any('WETH', 'MATIC', 'BNB')
    GROUP BY 1, 2
    )

    SELECT
    TRUNC(t1.block_timestamp, 'WEEK') as WEEKLY,
    CASE
    when platform ilike '%uniswap%' then 'uniswap'
    when platform ilike '%sushiswap%' then 'sushiswap'
    when platform ilike '%curve%' then 'curve'
    when platform ilike '%balancer%' then 'balancer'
    when platform ilike '%hashflow%' then 'hashflow'
    when platform ilike '%dodo%' then 'dodo'
    END AS SWAP_PROGRAM,
    COUNT(DISTINCT t1.tx_hash) as TRANSACTIONS,
    COUNT(DISTINCT origin_from_address) as TOTAL_USERS,
    SUM(amount_in_usd) as VOLUME_USD,
    AVG(amount_in_usd) as VOLUME_USD_AVG,
    SUM(tx_fee * PRICES.PRICE) as FEE_USD,
    AVG(tx_fee * PRICES.PRICE) as FEE_USD_AVG,
    SUM(VOLUME_USD) OVER (PARTITION BY SWAP_PROGRAM ORDER BY WEEKLY) AS VOLUME_CUM
    FROM base.defi.ez_dex_swaps t1
    JOIN base.core.fact_transactions t2
    ON t1.tx_hash = t2.tx_hash
    JOIN PRICES ON TRUNC(t1.block_timestamp, 'DAY') = DATE_TIME AND symbol = 'WETH'
    WHERE platform ilike Any ('%uniswap%', '%sushiswap%', '%curve%', '%balancer%', '%hashflow%', '%dodo%')
    AND status ilike 'success'
    AND t1.block_timestamp >= '2023-01-01'
    GROUP BY SWAP_PROGRAM, WEEKLY
    ORDER BY SWAP_PROGRAM, WEEKLY
    Last run: over 1 year ago
    WEEKLY
    SWAP_PROGRAM
    TRANSACTIONS
    TOTAL_USERS
    VOLUME_USD
    VOLUME_USD_AVG
    FEE_USD
    FEE_USD_AVG
    VOLUME_CUM
    1
    2023-07-24 00:00:00.000balancer110.10.10.41193899450.41193899450.1
    2
    2023-07-31 00:00:00.000balancer4811460.250.08333333333566.6996746180.72007582540.35
    3
    2023-08-07 00:00:00.000balancer487613181035568.314707.12868181812847.6565590322.3103140731035568.66
    4
    2023-08-14 00:00:00.000balancer365413301273860.796337.6158706474858.330858511.0621624092309429.45
    5
    2023-08-21 00:00:00.000balancer39521810439263.392185.392314.6203648620.42895114252748692.84
    6
    2023-08-28 00:00:00.000balancer48082229307403.7998.0639610392384.6674263660.39651935923056096.54
    7
    2023-09-04 00:00:00.000balancer614426592773695.651818.8168196722205.365749280.29090697135829792.19
    8
    2023-09-11 00:00:00.000balancer514424792618850.721643.9740866292060.7974619840.31612171538448642.91
    9
    2023-09-18 00:00:00.000balancer378919323259521.792700.5151532732210.3906631370.456315165811708164.7
    10
    2023-09-25 00:00:00.000balancer425820841243092.76783.297265281923.676072620.244152312812951257.46
    11
    2023-10-02 00:00:00.000balancer472122622082439.131044.3526228691760.0086905870.214844810915033696.59
    12
    2023-10-09 00:00:00.000balancer617230602297585.48534.1979725652020.7973527490.170072155617331282.07
    13
    2023-10-16 00:00:00.000balancer81403519879105.61150.1204935112013.4047771840.116106613118210387.68
    14
    2023-10-23 00:00:00.000balancer750232181636366.74244.3432492163985.7770481530.200229933119846754.42
    15
    2023-10-30 00:00:00.000balancer597829962781919.75530.69815913241.3471839260.208486986822628674.17
    16
    2023-11-06 00:00:00.000balancer719631671493536.81490.8106506745157.3398251050.420389617324122210.98
    17
    2023-11-13 00:00:00.000balancer65923798963215.2252.6134801995591.4946627350.439513807825085426.18
    18
    2023-11-20 00:00:00.000balancer65393703822446.66215.9786397065109.8905039420.407227486825907872.84
    19
    2023-11-27 00:00:00.000balancer584434651084807.23222.981958895400.023833610.462014359526992680.07
    20
    2023-12-04 00:00:00.000balancer570033442923700.86457.5431705798313.8303343290.694207609729916380.93
    ...
    105
    11KB
    26s