UNPKG

@anton-seriesfi/doppler-v3-sdk

Version:
89 lines 2.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReadUniswapV3Pool = void 0; const drift_1 = require("@delvtech/drift"); const abis_1 = require("../../abis"); /** * A class providing read-only access to a Uniswap V3 pool contract. * Enables querying pool state, events, and key parameters including: * - Swap, mint, and burn events * - Pool slot0 state (current price/tick) * - Token addresses * - Fee tier */ class ReadUniswapV3Pool { /** * Create a ReadUniswapV3Pool instance * @param address - Contract address of the Uniswap V3 pool * @param drift - Drift instance for blockchain interaction (defaults to new instance) */ constructor(address, drift = (0, drift_1.createDrift)()) { this.pool = drift.contract({ abi: abis_1.uniswapV3PoolAbi, address, }); } /** * Retrieve Mint events from the pool contract * @param options - Optional filters for event retrieval (block range, listener) * @returns Array of Mint event logs */ async getMintEvents(options) { return this.pool.getEvents("Mint", { ...options, }); } /** * Retrieve Burn events from the pool contract * @param options - Optional filters for event retrieval (block range, listener) * @returns Array of Burn event logs */ async getBurnEvents(options) { return this.pool.getEvents("Burn", { ...options, }); } /** * Retrieve Swap events from the pool contract * @param options - Optional filters for event retrieval (block range, listener) * @returns Array of Swap event logs */ async getSwapEvents(options) { return this.pool.getEvents("Swap", { ...options, }); } /** * Get current pool state including: * - sqrtPriceX96: Current sqrt(price) as Q64.96 * - tick: Current pool tick * - observationIndex/observationCardinality: Oracle-related parameters * @returns Object containing slot0 state values */ async getSlot0() { return this.pool.read("slot0"); } /** * Get address of first token in pool pair * @returns Contract address of token0 */ async getToken0() { return this.pool.read("token0"); } /** * Get address of second token in pool pair * @returns Contract address of token1 */ async getToken1() { return this.pool.read("token1"); } /** * Get pool's fee tier * @returns Fee percentage represented as an integer (e.g., 3000 = 0.3%) */ async getFee() { return this.pool.read("fee"); } } exports.ReadUniswapV3Pool = ReadUniswapV3Pool; //# sourceMappingURL=ReadUniswapV3Pool.js.map