0.1.1-beta ā€¢ Published 2 years ago

simple-quickswap-sdk v0.1.1-beta

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

simple-quickswap-sdk

Quickswap SDK which handles the routes automatically for you, changes in trade quotes reactive subscriptions, exposure to formatted easy to understand information, bringing back the best trade quotes automatically, generating transactions for you and much more. All the Quickswap logic for you in a simple to easy understand interface to hook straight into your dApp without having to understand how it all works.

Please note this is not owned or maintained by Quickswap and is a open source package for anyone to use freely.

Features šŸš€

šŸš€ Supports quickswap prices together and returns you the best price, so you do not need to query both yourself šŸš€ Queries all the best routes and finds the best price for you šŸš€ Exposes all the route paths it tried so you can see every detail in how it worked out the best price šŸš€ Factor in the cost of the transaction into the quotes with 1 config change šŸš€ Easy subscriptions to get alerted when the price moves or the trade expires šŸš€ The transaction is generated for you, just fill it with the gas details and send it on its way šŸš€ All the figures are all formatted for you, no need to worry about timing it back to its decimal formatted place, just render it straight onto your UI šŸš€ Exposes all the tokens metadata for you, name, symbol, decimals šŸš€ Uses multicall for every on chain lookup, so even though it could be doing 100 JSONRPC calls it is all put into a few calls meaning it can stay very fast šŸš€ Tidy bundle size šŸš€ Fully typescript supported with full generated typings šŸš€ query many tokens in 1 jsonrpc call perfect to get token metadata fast šŸš€ and much more!!

This repo is in beta phase and just suitable for fetching the price quotes

Sample usage:

import { UniswapPair, ChainId as UniswapChainId, UniswapPairSettings, UniswapVersion, TradeDirection} from 'simple-quickswap-sdk';


const uniswapPair = new UniswapPair({
    // the contract address of the token you want to convert FROM
    fromTokenContractAddress: token1Address,
    // the contract address of the token you want to convert TO
    toTokenContractAddress: token2Address,
    // the ethereum address of the user using this part of the dApp
    ethereumAddress: '0x207ca4370639120f9A049aF9CAB4fCaa608F2445',
    // you can pass in the provider url as well if you want
    providerUrl: Provider.PolygonMainnet,
    chainId: QuickChainId.MATIC,
    settings: new UniswapPairSettings({
      uniswapVersions: [UniswapVersion.v2],      
    })
  });
  const UniswapPairFactory = await uniswapPair.createFactory();
  const tradeRoutes = await UniswapPairFactory.findAllPossibleRoutesWithQuote('1',TradeDirection.input)