Lens
Quoter Class Reference
Last updated
async poolManager(): Promise<Address>async stateView(): Promise<Address>async quoteDopplerLensData(
params: QuoteExactSingleParams
): Promise<DopplerLensReturnData>interface QuoteExactSingleParams {
poolKey: PoolKey;
zeroForOne: boolean;
exactAmount: bigint;
hookData: Hex;
}interface PoolKey {
currency0: Address;
currency1: Address;
fee: number;
tickSpacing: number;
hooks: Address;
}interface DopplerLensReturnData {
sqrtPriceX96: bigint;
amount0: bigint;
amount1: bigint;
tick: number;
}import { ReadDopplerLens } from "doppler-v4-sdk";
// Create lens instance
const lens = new ReadDopplerLens(lensAddress);
// Get pool manager and state view addresses
const poolManager = await lens.poolManager();
const stateView = await lens.stateView();
// Quote current pool state
const poolKey = {
currency0: numeraireAddress,
currency1: tokenAddress,
fee: 20_000,
tickSpacing: 2,
hooks: dopplerHookAddress,
};
const quoteData = await lens.quoteDopplerLensData({
poolKey,
zeroForOne: true,
exactAmount: 1, // Simulate swapping 1 wei
hookData: "0x",
});
console.log("Current pool state:", {
price: quoteData.sqrtPriceX96,
tick: quoteData.tick,
token0Amount: quoteData.amount0.toString(),
token1Amount: quoteData.amount1.toString(),
});// Monitor price changes during Dutch auction
async function monitorPrice() {
const data = await lens.quoteDopplerLensData({
poolKey: myPoolKey,
zeroForOne: true,
exactAmount: parseEther("1"),
hookData: "0x",
});
// Convert sqrt price to human-readable price
const price = (Number(data.sqrtPriceX96) / 2 ** 96) ** 2;
console.log(`Current price: ${price}`);
}// Analyze total liquidity across all positions
async function analyzeLiquidity() {
const data = await lens.quoteDopplerLensData({
poolKey: myPoolKey,
zeroForOne: false,
exactAmount: 1n, // Minimal amount for state query
hookData: "0x",
});
console.log("Total liquidity:", {
totalToken0: formatEther(data.amount0),
totalToken1: formatEther(data.amount1),
tick: data.tick,
});
}