swap-router-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.21.1 • Public • Published

Tezos Swap Router SDK

Library that helps you ti find most profitable way to swap tokens on Tezos ecosystem.

Supported DEXes:

  • QuipuSwap
  • Plenty
  • Liquidity Baking
  • QuipuSwap Token to Token
  • Youves
  • Vortex
  • QuipuSwap curve-like DEXes, also known as Stableswap
  • Spicy
  • Spicy Wrap
  • Quipuswap Dex 2.0
  • Quipuswap V3

Installation

yarn add swap-router-sdk

Prerequisites & explenation

TEZOS_DEXES_API_URL: string - url to the WebSocket server that returns list of available pairs and their liquidity
inputAssetSlug: string - slug (address_id || tez) of input token
outputAssetSlug: string - slug (address_id || tez) of desired output token
inputMutezAmount: BigNumber - number of input token (1 TEZ = 1 000 000 mutez)
outputMutezAmount: BigNumber - number of output token (1 TEZ = 1 000 000 mutez)
slippageTolerance: number | undefined - slippage tolerance percent maxDepth?: number - maximal depth of search, which is equal to maximal route length. Default value is 3 receiverPublicKeyHash?: string - public key hash of swap output receiver. Default value is sender's public key hash referralAddress?: string - the address of referral fees receiver for QuipuSwap curve-like DEXes referralCode?: string | null - the ID of V3 pool methods calls source. 1 stands for Quipuswap, 2 stands for Temple Wallet.

Usage

const allRoutePairs = useAllRoutePairs(TEZOS_DEXES_API_URL);

const routePairsCombinations = useRoutePairsCombinations(
  inputAssetSlug,
  outputAssetSlug,
  allRoutePairs.data,
  maxDepth
);

...

const bestTradeExactIn = getBestTradeExactInput(inputMutezAmount, routePairsCombinations);
const bestTradeExactOutput = getBestTradeExactOutput(outputMutezAmount, routePairsCombinations);

...

const bestTradeWithSlippageTolerance = useTradeWithSlippageTolerance(
  inputMutezAmount,
  bestTrade,
  slippageTolerance
);

...

const tradeTransferParams = await getTradeOpParams(bestTradeWithSlippageTolerance, account.publicKeyHash, tezos, referralAddress, receiverPublicKeyHash);

const walletParamsWithKind = tradeTransferParams.map(transferParams => parseTransferParamsToParamsWithKind(transferParams));

Readme

Keywords

none

Package Sidebar

Install

npm i swap-router-sdk

Weekly Downloads

32

Version

1.21.1

License

MIT

Unpacked Size

1.05 MB

Total Files

132

Last publish

Collaborators

  • madfish