UNPKG

astra-universal-router-sdk

Version:

sdk for integrating with the Astra Router contracts

47 lines (34 loc) 1.27 kB
# universal-router-sdk This SDK facilitates interactions with the contracts in [Universal Router](https://github.com/Uniswap/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()` ```typescript import { TradeType } from 'astra-sdk-core' import { Trade as V2TradeSDK } from 'astra-classic-sdk' import { Trade as V3TradeSDK } from 'astra-cl-sdk-dev' import { MixedRouteTrade, MixedRouteSDK, Trade as RouterTrade } from 'astra-router-sdk' const options = { slippageTolerance, recipient } const routerTrade = new RouterTrade({ v2Routes: classicRoutes, v3Routes: clRoutes, 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 ```bash yarn install yarn test:hardhat ``` Run forge integration tests ```bash forge install yarn test:forge ```