Afonso_DiazOvertime
    Updated 2025-05-15
    WITH pricet AS (
    SELECT
    hour::date AS date,
    token_address,
    decimals,
    symbol,
    AVG(price) AS token_price_usd
    FROM kaia.price.ez_prices_hourly
    GROUP BY 1, 2, 3, 4
    ),

    swaps AS (
    SELECT
    tx_hash,
    block_timestamp,
    origin_from_address AS swapper,
    REPLACE(topics[2], '0x000000000000000000000000', '0x') AS token_in_contract,
    REPLACE(topics[3], '0x000000000000000000000000', '0x') AS token_out_contract,
    utils.udf_hex_to_int('0x' || SUBSTRING(data, 67, 64)) AS amount_in_unadj,
    utils.udf_hex_to_int('0x' || RIGHT(data, 64)) AS amount_out_unadj
    FROM kaia.core.fact_event_logs
    WHERE tx_succeeded
    AND topics[0] = '0x20efd6d5195b7b50273f01cd79a27989255356f9f13293edc53ee142accfdb75'
    AND origin_to_address = '0xf50782a24afcb26acb85d086cf892bfffb5731b5'
    ),

    main AS (
    SELECT
    swaps.*,
    NVL(a.symbol, c.symbol) AS symbol_in,
    NVL(b.symbol, d.symbol) AS symbol_out,
    amount_in_unadj / POW(10, IFF(token_in_contract = '0x0000000000000000000000000000000000000000', 18, NVL(a.decimals, 18))) AS amount_in,
    amount_out_unadj / POW(10, IFF(token_out_contract = '0x0000000000000000000000000000000000000000', 18, NVL(b.decimals, 18))) AS amount_out,
    NVL(amount_in, 0) * NVL(c.token_price_usd, 0) AS amount_in_usd,
    NVL(amount_out, 0) * NVL(d.token_price_usd, 0) AS amount_out_usd,
    COALESCE(amount_in_usd, amount_out_usd, 0) AS amount_usd
    Last run: 10 days ago
    DAY
    SWAPS
    ACTIVE_SWAPPERS
    NEW_SWAPPERS
    OLD_SWAPPERS
    TOTAL_VOLUME_USD
    AVG_SWAP_SIZE_USD
    CUM_VOLUME_USD
    1
    2023-12-01 00:00:00.000252765056382231877539277.42920277298.2781068687539277.42920277
    2
    2024-01-01 00:00:00.0002724455001705434410769730.9168191395.30652315418309008.3460219
    3
    2024-02-01 00:00:00.000217726108256942534293067.52109303197.18296532722602075.8671149
    4
    2024-03-01 00:00:00.000293398187304261526544607.72307987223.06853413829146683.5901948
    5
    2024-04-01 00:00:00.000227646830187955343490406.64600502153.33011096532637090.2361998
    6
    2024-05-01 00:00:00.000170165713111249171646887.426248796.7846395334283977.6624485
    7
    2024-06-01 00:00:00.00018035549091948132446078.99701839135.6295534836730056.6594669
    8
    2024-07-01 00:00:00.00017199564593449472067240.36782977120.19538158238797297.0272967
    9
    2024-08-01 00:00:00.00018746533781047004536774.31569673242.01292626143334071.3429934
    10
    2024-09-01 00:00:00.00019572542898446613482007.14203274177.90757929946816078.4850261
    11
    2024-10-01 00:00:00.00023794604873555195445387.45490676228.85548688452261465.9399329
    12
    2024-11-01 00:00:00.0004821783301967704021053853.1136971436.64792736473315319.05363
    13
    2024-12-01 00:00:00.0004104375141852626838174586.6254705930.111995358111489905.679101
    14
    2025-01-01 00:00:00.0003076997224932548614106237.8876134458.456169769125596143.566714
    15
    2025-02-01 00:00:00.000229735251157341187574691.31454181329.721469314133170834.881256
    16
    2025-03-01 00:00:00.000211884994103842924936201.55709717232.971566788138107036.438353
    17
    2025-04-01 00:00:00.000226475405110746965525124.94188839243.967189557143632161.380241
    18
    2025-05-01 00:00:00.00012256370874832703284216.12909697267.968026199146916377.509338
    18
    2KB
    39s