Code Monkey home page Code Monkey logo

univ3-usage's Introduction

UniV3 usage

Illustrates UniswapV3 usage in minimal examples.

Code is written with educational purpose and is unfit for production uses.

Examples are meant to be examined in the following order:

  1. Factory - creation of a uniswap v3 pool
  2. AddLiquidity - adding liquidity to a pool directly and via npm
  3. SingleSwap - perform a swap in one direction
  4. SwapAllLiquidity - perform swaps until liquidity in one side is depleted
  5. TWAP - calculate TWAP for a newly created pool
  6. LiveTWAP - calculate TWAP for production USDC/WETH pool

Some explanations are omitted in later examples for brevity.

Structure

Some of the interfaces needed to be copied to the project's src/ folder, because of OZ import path issues.

Tests

Run the following command in terminal:

forge test -vv

Note

Working directly with the Uniswap V3 contracts brings multitude of issues:

  1. They have strict compiler checks for older versions - (=0.7.6).
  2. Lots of u/int casts that are not allowed in newer compiler versions.
  3. They are incompatible with newer OZ versions.

All of this makes the Uniswap V3 implementation contracts difficult to work with. This is why projects import only the univ3 interfaces and then run tests on forked blockchain state.

Articles

univ3-usage's People

Contributors

georgiivanov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.