JSPM

  • Created
  • Published
  • Downloads 95
  • Score
    100M100P100Q81118F
  • License MIT

sdk for integrating with the Universal Router contracts

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@gfxlabs/uniswap-universal-router-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    universal-router-sdk

    This SDK facilitates interactions with the contracts in Universal Router

    Usage

    Install latest version of universal-router-sdk. Then import the corresponding Trade class and Data object for each protocol you'd like to interact with.

    Trading on Uniswap

    warning: swapERC20CallParameters() to be deprecated in favor of swapCallParameters()

    import { TradeType } from '@uniswap/sdk-core'
    import { Trade as V2TradeSDK } from '@uniswap/v2-sdk'
    import { Trade as V3TradeSDK } from '@uniswap/v3-sdk'
    import { MixedRouteTrade, MixedRouteSDK, Trade as RouterTrade } from '@uniswap/router-sdk'
    
    const options = { slippageTolerance, recipient }
    const routerTrade = new RouterTrade({ v2Routes, v3Routes, mixedRoutes, tradeType: TradeType.EXACT_INPUT })
    // Use the raw calldata and value returned to call into Universal Swap Router contracts
    const { calldata, value } = SwapRouter.swapCallParameters(routerTrade, options)

    Running this package

    Make sure you are running node v18 Install dependencies and run typescript unit tests

    yarn install
    yarn test:hardhat

    Run forge integration tests

    forge install
    yarn test:forge