@x-swap-protocol/universal-router-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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 '@x-swap-protocol/sdk-core'
import { Trade as V2TradeSDK } from '@x-swap-protocol/v2-sdk'
import { Trade as V3TradeSDK } from '@x-swap-protocol/v3-sdk'
import { MixedRouteTrade, MixedRouteSDK, Trade as RouterTrade } from '@x-swap-protocol/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

Readme

Keywords

Package Sidebar

Install

npm i @x-swap-protocol/universal-router-sdk

Weekly Downloads

5

Version

1.1.1

License

MIT

Unpacked Size

977 kB

Total Files

42

Last publish

Collaborators

  • pro100skm