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 1-second finality makes it ideal for DeFi applications where price accuracy matters:
  • Near real-time prices: Query prices that are at most 1 second old
  • Reliable data: No reorganizations mean prices are immediately trustworthy
  • 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:
  • 1-second freshness: Prices are at most 1 second old, crucial for arbitrage and trading bots
  • Immediate finality: No need to wait for confirmations. The price you see is the price you get.
  • High throughput: DEXs can handle more trades per second, leading to more liquid markets
  • No reorg risk: Price data is reliable immediately. No worrying about chain reorganizations invalidating trades.
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 June 22, 2026