Giter VIP home page Giter VIP logo

routing-api-uniswapv3's Introduction

Uniswap Routing API

This repository contains routing API for the Uniswap V3 protocol.

It deploys an API to AWS that uses @uniswap/smart-order-router to search for the most efficient way to swap token A for token B.

Development

The develop on the Routing API you must have an AWS account where you can deploy your API for testing.

Deploying the API

The best way to develop and test the API is to deploy your own instance to AWS.

  1. Install and configure AWS CLI and AWS CDK V1.
  2. Create .env file in the root directory of the project with :
    THROTTLE_PER_FIVE_MINS = '' # Optional
    WEB_RPC_{CHAIN ID} = { RPC Provider}
    # RPC Providers must be set for the following CHAIN IDs:
    # MAINNET = 1
    # ROPSTEN = 3
    # RINKEBY = 4
    # GÖRLI = 5
    # KOVAN = 42
    # OPTIMISM = 10
    # OPTIMISTIC_KOVAN = 69
    # ARBITRUM_ONE = 42161
    # ARBITRUM_RINKEBY = 421611
    # POLYGON = 137
    # POLYGON_MUMBAI = 80001
    
  3. Install and build the package
    npm install && npm run build
    
  4. To deploy the API run:
    cdk deploy RoutingAPIStack
    
    This will deploy to the default account your AWS CLI is configured for. Once complete it will output something like:
    RoutingAPIStack.Url = https://...
    
    You can then try it out:
    curl --request GET '<INSERT_YOUR_URL_HERE>/quote?tokenInAddress=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&tokenInChainId=1&tokenOutAddress=0x1f9840a85d5af5bf1d1762f925bdaddc4201f984&tokenOutChainId=1&amount=100&type=exactIn'
    

Integration Tests

The integration tests fetch quotes from your deployed API, then execute the swaps on a Hardhat mainnet fork.

  1. First deploy your test API using the intructions above. Then update your .env file with the URL of the API, and the RPC URL of an archive node:

    UNISWAP_ROUTING_API='...'
    ARCHIVE_NODE_RPC='...'
    
  2. Run the tests with:

    npm run integ-test
    

routing-api-uniswapv3's People

Contributors

ewilz avatar lint-action avatar raghava-pamula avatar snreynolds avatar willpote 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.