1.21.1 • Published 1 year ago

swap-router-sdk v1.21.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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

1 year ago

1.20.1

1 year ago

1.21.1

1 year ago

1.20.2

1 year ago

1.20.0

1 year ago

1.20.3

1 year ago

1.19.0

1 year ago

1.18.1

1 year ago

1.19.2

1 year ago

1.19.1

1 year ago

1.16.3

2 years ago

1.18.0

2 years ago

1.17.0

2 years ago

1.15.0

2 years ago

1.13.2-beta

2 years ago

1.13.6

2 years ago

1.16.2

2 years ago

1.13.5

2 years ago

1.16.1

2 years ago

1.15.2

2 years ago

1.13.4

2 years ago

1.16.0

2 years ago

1.15.1

2 years ago

1.13.3

2 years ago

1.13.7

2 years ago

1.15.0-beta

2 years ago

1.14.0-beta

2 years ago

1.13.3-beta

2 years ago

1.13.1

2 years ago

1.13.0

2 years ago

1.12.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago