DEXPriceAggregatorUniswapV3 Smart Contract Module in Bunzz

The DEXPriceAggregatorUniswapV3 module is a DEX-based price oracle aggregating spot and TWAP rates from Uniswap V3 that selects the worst rate between spot and TWAP.

The module is able to handle queries for asset prices across an intermediate liquidity pool (e.g. WBTC -> WETH -> USDC).

It’s useful for all price queries:

  • Reverts if no pool route is found for the given tokenIn and tokenOut
  • Reverts if twapPeriod is 0
  • Reverts if the twapPeriod is too large for the underlying pool’s history. In this case, you will have to increase the history stored by the pool by calling UniswapV3Pool#increaseObservationCardinalityNext() (see v3 whitepaper section 5.1).

You can access this Module and the code here: https://bit.ly/3zhVDqZ

How to Use

  1. Deploy smart contract via Bunzz
  2. When deploy, specify UniswapV3Factory address, wrapped native token address (for example, for Ethereum, WETH address), and default pool fee (for example 3000).
  3. Users can set pool for the route using setPoolForRoute function.
  4. Users can query prices using assetToAsset, assetToEth, ethToAsset functions.

Functions

#WRITE

  • setPoolForRoute
  • transferOwnership
  • renounceOwnership

#READ

  • assetToAsset
  • assetToEth
  • defaultPoolFee
  • ethToAsset
  • fetchCurrentTicks
  • getQuoteAtTick
  • getQuoteCrossingTicksThroughWeth
  • overriddenPoolForRoute
  • owner
  • uniswapV3Factory
  • weth
  • getPoolForRoute

You can access this Module and the code here: https://bit.ly/3zhVDqZ

If you still haven’t signed up to Bunzz, what are you waiting for?

Sign up here https://app.bunzz.dev/signup and get your smart contracts deployed in 5 minutes through our great GUI.

Share this article:

Leave a Comment

Your email address will not be published. Required fields are marked *