GithubHelp home page GithubHelp logo

isabella232 / swap-router-contracts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uniswap/swap-router-contracts

0.0 0.0 0.0 2.64 MB

Smart contracts for swapping on Uniswap V2 and V3

License: GNU General Public License v2.0

Solidity 36.76% TypeScript 63.24%

swap-router-contracts's Introduction

Uniswap Swap Router

Tests Lint

This repository contains smart contracts for swapping on the Uniswap V2 and V3 protocols.

Bug bounty

This repository is subject to the Uniswap V3 bug bounty program, per the terms defined here.

Local deployment

In order to deploy this code to a local testnet, you should install the npm package @uniswap/swap-router-contracts and import bytecode imported from artifacts located at @uniswap/swap-router-contracts/artifacts/contracts/*/*.json. For example:

import {
  abi as SWAP_ROUTER_ABI,
  bytecode as SWAP_ROUTER_BYTECODE,
} from '@uniswap/swap-router-contracts/artifacts/contracts/SwapRouter02.sol/SwapRouter02.json'

// deploy the bytecode

This will ensure that you are testing against the same bytecode that is deployed to mainnet and public testnets, and all Uniswap code will correctly interoperate with your local deployment.

Using solidity interfaces

The swap router contract interfaces are available for import into solidity smart contracts via the npm artifact @uniswap/swap-router-contracts, e.g.:

import '@uniswap/swap-router-contracts/contracts/interfaces/ISwapRouter02.sol';

contract MyContract {
  ISwapRouter02 router;

  function doSomethingWithSwapRouter() {
    // router.exactInput(...);
  }
}

Tests

Some tests use Hardhat mainnet forking and therefore require an archive node. Either create a .env file in the workspace root containing:

ARCHIVE_RPC_URL='...'

Or set the variable when running tests:

export ARCHIVE_RPC_URL='...' && npm run test

swap-router-contracts's People

Contributors

ewilz avatar gakonst avatar hensha256 avatar jfrankfurt avatar lint-action avatar moodysalem avatar nchamo avatar noahzinsmeister avatar smsunarto 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.