Skip to main content
This tutorial teaches you how to fetch token prices directly from decentralized exchanges on Monad. You’ll learn to query Uniswap V2-style liquidity pools, calculate prices from reserves, and build real-time price monitors.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
TLDR:
  • Query token prices from Uniswap V2-style pools on Monad
  • Calculate prices from liquidity pool reserves
  • Handle token decimals correctly
  • Monitor price changes in real-time
  • Both JavaScript and Python implementations

Prerequisites

  • Chainstack account with a Monad node endpoint
  • Node.js v16+ or Python 3.8+
  • Basic understanding of AMM mechanics

Overview

Monad’s sub-second blocks and fast finality suit DeFi applications where price accuracy matters:
  • Near real-time prices: The latest block is a fraction of a second old
  • Reliable data: Blocks finalize within about a second, and finalized blocks are never reorganized
  • High throughput: DEXs can handle high trading volume without congestion
This tutorial focuses on Uniswap V2-style AMMs, which are the most common DEX architecture on EVM chains.

Understanding AMM pricing

Uniswap V2 pools use the constant product formula:
Where:
  • x = reserve of token A
  • y = reserve of token B
  • k = constant (product of reserves)
The price of token A in terms of token B is:
This is the “spot price” before any trade. Actual trade prices include slippage based on trade size relative to pool liquidity.

Key contract addresses

For this tutorial, you’ll need:
DEX contracts and token addresses change as the Monad ecosystem evolves. Verify current addresses on block explorers like MonVision or Monadscan.

Query Uniswap V2 pool prices

Uniswap V2 Pair ABI

The minimal ABI needed to query prices:

JavaScript price fetcher

fetch-price.js

Python price fetcher

fetch_price.py

Monitor price changes

Build a real-time price monitor:

JavaScript price monitor

monitor-price.js

Python price monitor

monitor_price.py

Calculate price impact

Estimate the price impact of a trade before executing:
price-impact.js

Working with WMON

WMON (Wrapped MON) is essential for DEX trading since most pools pair tokens against WMON rather than native MON.

Wrap MON to WMON

wrap-mon.js

Monad-specific notes

Why Monad excels for DEX price fetching:
  • Sub-second freshness: New blocks arrive several times a second, crucial for arbitrage and trading bots
  • Fast finality: A block is finalized within about a second of being proposed. Reads at latest reflect the newest proposed block; read at finalized when you need final state.
  • High throughput: DEXs can handle more trades per second, leading to more liquid markets
  • No reorgs after finality: Once a block is finalized, a chain reorganization can’t invalidate the prices in it.
Price fetching best practices:
  • Always check liquidity: Low liquidity pools can have unreliable prices
  • Account for fees: Uniswap V2 charges 0.3% per swap
  • Handle decimals carefully: Token decimals vary (6 for USDC, 18 for most tokens)
  • Use multiple sources: Cross-check prices across pools for accuracy

Next steps

Now that you can fetch DEX prices on Monad, you can:
  • Build trading bots that react to price changes
  • Create price aggregators across multiple DEXs
  • Implement arbitrage detection systems
  • Build portfolio tracking dashboards
  • Create price alerts and notifications
Last modified on November 13, 2026