Giter VIP home page Giter VIP logo

swapper's Introduction

Requirements

To run the project you need:

  • Python 3.8 local development environment and Node.js 10.x development environment for Ganache.
  • Brownie local environment setup. See instructions for how to install it here.
  • Local env variables for Etherscan API and Infura (ETHERSCAN_TOKEN, WEB3_INFURA_PROJECT_ID,PRIVATE_KEY).
  • Local Ganache environment installed with npm install -g ganache.

Explanations

This repo contain the code for making a swap using UNI-V3 route. Swapper is a contract that allow you to perform a swap through UniswapV3. The swap is done between native ETH and the token of your choices. The script will check if there is liquidity in the pool and let you know the liquidity available. If you are happy with the liquidity you can choose how many ETH you want to swap.

Instructions

This repo is intended to work in a mainnet fork env.

To run the script use brownie run scripts/deploy.py --network mainnet-fork

Follow the instructions provided in your terminal prompt.

Examples

  • Example 1 : Swapping 5 ETH for UST (lol)

UST

You will notice that the UNI pool contains only 17k of UST liquidity.

  • Example 2 : Swapping 5 ETH for APE Coin

Ape

Improvements

This contract is very basic and only use UNI-v3 route. To improve the Swapper contract, we can add more route (such as UNI-v2 or other AMM), we can also integrate an aggregator in our contracts for making swaps (such as 1inch, Paraswap ...). To check the liquidty in USD or ETH value of the pool where we want to swap the token, we could implement UNI-v3 TWAP as on-chain oracle to query the liquidity available. In our case it is better to implement liquidity check off-chain, this is an unecessary gas consuming task to do it on-chain in our case.

swapper's People

Contributors

chalex-eth 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.