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));

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.21.128latest
1.15.0-beta0beta

Version History

VersionDownloads (Last 7 Days)Published
1.21.128
1.21.00
1.20.30
1.20.20
1.20.11
1.20.00
1.19.20
1.19.10
1.19.00
1.18.10
1.18.00
1.17.00
1.16.30
1.16.21
1.16.13
1.16.00
1.15.20
1.15.10
1.15.00
1.15.0-beta0
1.14.0-beta0
1.13.71
1.13.60
1.13.50
1.13.40
1.13.30
1.13.3-beta0
1.13.2-beta0
1.13.10
1.13.00
1.12.00
1.11.00
1.10.00
1.9.00
1.8.00
1.7.00
1.6.00
1.5.00
1.4.00

Package Sidebar

Install

npm i swap-router-sdk

Weekly Downloads

34

Version

1.21.1

License

MIT

Unpacked Size

1.05 MB

Total Files

132

Last publish

Collaborators

  • madfish