Updated 2025-04-17
    WITH EthereumDailyPrices AS (
    SELECT
    DATE(hour) AS price_date
    ,AVG(price) AS avg_daily_price
    FROM ethereum.price.ez_prices_hourly
    WHERE token_address = LOWER('0x54991328ab43c7d5d31c19d1b9fa048e77b5cd16')
    GROUP BY DATE(hour)
    ),
    EthereumClassifiedSwaps AS (
    SELECT
    block_timestamp
    ,DATE(block_timestamp) AS swap_date
    ,tx_hash
    ,origin_from_address AS wallet
    ,contract_address AS contract
    ,(decoded_log:amount0) / 1e18 AS soil_amount_tokens
    ,CASE
    WHEN CAST(decoded_log:amount0 AS DECIMAL) < 0 THEN 'Buy SOIL'
    WHEN CAST(decoded_log:amount0 AS DECIMAL) > 0 THEN 'Sell SOIL'
    ELSE 'Unknown'
    END AS buy_soil_or_sell_soil
    ,ABS((decoded_log:amount0) / 1e18) * dp.avg_daily_price AS volume_usd
    FROM ethereum.core.ez_decoded_event_logs
    LEFT JOIN EthereumDailyPrices dp ON DATE(block_timestamp) = dp.price_date
    WHERE
    contract_address = LOWER('0x7090Cc8DFA04b0BBAc6520063c9c1ea677C368a0')
    AND event_name = 'Swap'
    ),
    PolygonDailyPrices AS (
    SELECT
    DATE(hour) AS price_date
    ,AVG(price) AS avg_daily_price
    FROM polygon.price.ez_prices_hourly
    WHERE token_address = LOWER('0x43C73b90E0C2A355784dCf0Da12f477729b31e77')
    GROUP BY DATE(hour)
    ),
    Last run: about 1 month ago
    ethereum wallets
    ethereum tx_hash
    ethereum total sold
    ethereum total bought
    ethereum volume usd
    polygon wallets
    polygon tx_hash
    polygon total sold
    polygon total bought
    polygon volume usd
    total wallets
    total tx_hash
    total sold soil
    total bought soil
    total volume usd
    1
    60284212938.008421375239887.51521145104245.92070968694012834713892570.499171913902347.491274624487145.7551769698612863114105508.507593314142235.00648624591391.6758866
    1
    184B
    1s