Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

swap-router-sdk

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swap-router-sdk

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

npmnpm
Version
1.18.1
Version published
Weekly downloads
21
-66.13%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

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

FAQs

Package last updated on 15 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts