@uniswap/swap-router-contracts

1.3.1 • Public • Published

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

/@uniswap/swap-router-contracts/

    Package Sidebar

    Install

    npm i @uniswap/swap-router-contracts

    Homepage

    uniswap.org

    Weekly Downloads

    47,965

    Version

    1.3.1

    License

    GPL-2.0-or-later

    Unpacked Size

    397 kB

    Total Files

    51

    Last publish

    Collaborators

    • uniswap-labs-service-account
    • cmcewen
    • mtoda
    • alicehenshaw
    • sarareynolds
    • emag3m
    • willpote
    • akarys01
    • ezhong1900
    • zachyang_uniswap