Sandeshdex liquidity pool MPH
    Updated 2025-02-07
    /*
    Description:
    This query analyzes token activity across Ethereum chain for karrat token.
    It calculates liquidity, volume metrics, and identifies liquidity pools for each DEX platform.
    The query uses Common Table Expressions (CTEs) to organize complex logic and improve readability.

    Key features:
    1. Volume calculations for different time periods (7-day, 1-month, total)
    2. Liquidity pool identification and balance calculation
    3. Platform-specific aggregations


    All thanks to andrew hong for the query which this query is based on.
    */



    -- DEX Pool Identification and Volume Calculation
    WITH dex_pools AS (
    SELECT
    platform,
    contract_address AS liquidity_pools,
    SUM(CASE
    WHEN (block_timestamp > current_timestamp - INTERVAL '7 days')
    THEN COALESCE(amount_in_usd, amount_out_usd)
    ELSE NULL
    END) AS seven_day_volume,
    SUM(CASE
    WHEN (block_timestamp > current_timestamp - INTERVAL '1 month')
    THEN COALESCE(amount_in_usd, amount_out_usd)
    ELSE NULL
    END) AS one_month_volume,
    SUM(COALESCE(amount_in_usd, amount_out_usd)) AS total_volume,
    count (distinct (CASE
    WHEN (block_timestamp > current_timestamp - INTERVAL '1 month')
    THEN COALESCE(sender, '')
    Last run: 3 months ago
    PLATFORM
    TOTAL_LIQUIDITY
    SEVEN_DAY_VOLUME
    ONE_MONTH_VOLUME
    TOTAL_VOLUME
    MONTHLY_USER
    POOL_ADDRESSES
    1
    uniswap-v3344911.364827007915619.925608150.22116862825.0457
    [ "0x7a233f0e957a9ff4726c738e9d790b9956f4c894" ]
    1
    117B
    24s