Uniswap Integration
Uniswap is NMT's most complex integration, spanning three protocol versions (V2, V3, V4) with different mechanics.
Uniswap V2 — Basic AMM
What it is: The classic automated market maker. Liquidity providers deposit equal values of two tokens into a pool and may receive a share of trading fees. Fee generation depends on trading volume and is not guaranteed.
How NMT integrates:
| Layer | Component |
|---|---|
| Contract | UniswapV2Module.sol — handles swap, addLiquidity, removeLiquidity |
| Backend | workers/src/defi/services/uniswap_v2/ — indexes pairs and positions |
| Frontend | lib/defi/uniswap/v2/ — encodes V2 transactions |
| Data source | Krystal API |
Min TVL filter: $100,000
Uniswap V3 — Concentrated Liquidity
What it is: An advanced AMM where liquidity providers choose a specific price range for their capital. This increases capital efficiency but requires active management.
Key concepts:
- Tick range — the price bounds for a position (lower tick to upper tick)
- In-range — the position is currently eligible to accrue fees
- Out-of-range — the price has moved outside the position's bounds
- Position NFT — each V3 position is a unique NFT owned by the user's Safe
How NMT integrates:
| Layer | Component |
|---|---|
| Contract | UniswapV3Module.sol — mint, burn, collect, increase/decrease liquidity |
| Backend | workers/src/defi/services/uniswap_v3/ — indexes positions, calculates values |
| Frontend | lib/defi/uniswap/v3/ — range selection, position encoding |
| Data source | Krystal API |
Min TVL filter: $500,000
Backend update interval: Every 2 minutes (more frequent than other protocols because CL data changes rapidly)
Uniswap V4 — Hooks
What it is: The newest version of Uniswap, introducing "hooks" — custom logic that runs before/after swaps and liquidity operations.
How NMT integrates:
| Layer | Component |
|---|---|
| Contract | (via V3 module) |
| Backend | workers/src/defi/services/uniswap_v4/ — dedicated service with its own position parsing, fee calculation, and backfill |
| Frontend | lib/defi/uniswap/v4/ — dedicated adapter |
| Data source | Krystal API |
V4 originally shared V3's backend service but now has its own UniswapV4Service with dedicated modules for metadata, polling, and position handling (parsing, backfill, contracts, types). Key differences from V3:
- Fee calculation — V4 fees owed are calculated via on-chain contract calls specific to V4's PoolManager
- Zeroed positions — special handling for V4 positions that report zero liquidity
- Skip pools — configurable set of V4 pool addresses to exclude from indexing
Min TVL filter: $500,000
Key Addresses
| Chain | Contract | Address |
|---|---|---|
| Ethereum | V3 NonfungiblePositionManager | 0xC36442b4a4522E871399CD717aBDD847Ab11FE88 |
| Base | V3 NonfungiblePositionManager | 0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1 |
| Ethereum | V2 Router | 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D |