📖
Bella "Tuner" - A Uniswap V3 Simulator
  • Getting Started
    • Overview
    • How "Tuner" Library Works?
    • Installing "Tuner"
    • Quick Start
  • Configuration
    • Configuration
  • Guides
    • (Basic)For anyone who is interested in the Uniswap v3 model
      • Building a client instance
      • About Core Pool Config
      • Getting a Core Pool instance
      • Interacting with Core Pool
    • (Typical)For a quant developer who works on a real pool on mainnet
      • Fetching all the data of a certain pool from Ethereum
      • Getting a pool instance with the data fetched
      • Loading and streaming events into a pool
    • (Advanced)For a better user experience as a state machine
      • PoolState & Transition
      • Post-processor
      • Forking & Retracing
      • Persisting & Recovering
      • SimulatorRoadmapManager
  • Performance
    • Performance
  • Examples
    • Uniswap-v3-Events-Downloader
    • Uniswap-v3-Strategy-Backtest
    • Uniswap-v3-Risk-Analysis(will be available soon)
  • Contributing
    • Contributing
Powered by GitBook
On this page
  1. Guides
  2. (Basic)For anyone who is interested in the Uniswap v3 model

Interacting with Core Pool

A CorePool corresponds to a contract of Uniswap V3 Core Pool. You can inspect its state like sqrtPriceX96, tickCurrent, lquidity and more detailed information on any Tick or Position.

let corePoolView: CorePoolView = configurableCorePool.getCorePool();

corePoolView.tickCurrent;

corePoolView.getTick(tickIndex);

corePoolView.getPosition(owner, tickLower, tickUpper);

Also, you can interact with the pool by mint, burn and swap. However, while interacting with the pool, we recommend using ConfigurableCorePool to get full functionality of the Tuner.

Based on the CorePool, a ConfigurableCorePool is a state machine providing utilities like post-processor, fork, snapshot, step back and recover.

let amount0: JSBI, amount1: JSBI;

({ amount0, amount1 } = await configurableCorePool.mint(
  testUser,
  tickLower,
  tickUpper,
  liquidity
));

({ amount0, amount1 } = await configurableCorePool.burn(
  testUser,
  tickLower,
  tickUpper,
  liquidity
));

({ amount0, amount1 } = await configurableCorePool.swap(
  zeroForOne,
  amountSpecified,
  sqrtPriceLimitX96
));

Since Tuner is focusing on the math model instead of token or stratgy, feel free to mint, burn and swap as you like, then observe whether things go as you expect.

PreviousGetting a Core Pool instanceNext(Typical)For a quant developer who works on a real pool on mainnet

Last updated 3 years ago