Lens
Quoter Class Reference
The ReadDopplerLens
class provides read-only access to the Doppler Lens contract, which fetches virtual updates to the Doppler Dutch auction that aren't reflected in the current chain state. This is essential for getting accurate real-time pricing and liquidity information during active price discovery phases.
Overview
The Doppler Lens serves as a sophisticated quoter that can simulate swaps against Doppler pools and return detailed information about:
Current pool state (price, tick, liquidity)
Virtual token amounts in each position
Position data for lower, upper, and price discovery slugs
Real-time pricing without executing transactions
Constructor
Parameters:
address
- The address of the DopplerLensQuoter contractdrift
- Drift instance with read adapter (creates default if not provided)
Core Methods
poolManager
Retrieves the address of the Uniswap V4 pool manager used by the lens.
Returns: Promise resolving to the pool manager address
stateView
Retrieves the address of the state view contract used for reading pool state.
Returns: Promise resolving to the state view contract address
quoteDopplerLensData
The main method for getting comprehensive Doppler pool data. This simulates a swap to extract current pool state and position information.
Parameters:
params
- Quote parameters containing:poolKey
- The pool identifier (tokens, fee, tick spacing, hooks)zeroForOne
- Direction of the swap (token0 → token1 or vice versa)exactAmount
- Amount to simulate swappinghookData
- Additional data for the hook (usually empty)
Returns: Promise resolving to:
sqrtPriceX96
- Current pool price in sqrt formatamount0
- Total amount of token0 across all positionsamount1
- Total amount of token1 across all positionstick
- Current tick of the pool
Types
QuoteExactSingleParams
PoolKey
DopplerLensReturnData
Example Usage
Use Cases
Real-time Price Monitoring
Liquidity Analysis
Key Features
Real-time State: Get current pool state without waiting for blockchain updates
Virtual Positions: See combined liquidity across lower, upper, and price discovery positions
Simulation Based: Uses revert-based simulation for gas-free queries
Price Discovery: Essential for monitoring active Dutch auctions
Non-view Functions: Handles complex state calculations that require simulation
Technical Notes
The lens contract uses a revert-based approach where it:
Simulates a swap to update internal state
Calculates position data across all Doppler slugs (lower, upper, price discovery)
Reverts with the calculated data to return results
Parses the revert data to extract meaningful information
This approach allows complex calculations that wouldn't be possible with pure view functions while maintaining gas efficiency for off-chain queries.
Last updated