Giter Club home page Giter Club logo

paraswap-connext-sdk's Introduction

ParaSwap Connext SDK

Prerelase for local testing! The package will be available on package managers soon.

Summary

This package allows to do bridge and swap calls via ParaSwap and Connext. The Li.Fi API is used under the hood to find the best cross-chain quote. The quote can then be executed using any signer/wallet.

Supported Chains and Tokens

Transfers of the defined tokens are possible between all combinations of chains supported by Connext. The combination with ParaSwap enables you to swap+bridge any token from chains supported by ParaSwap and receive any token on these chains aswell (bride+swap).

Chain Chain Id Chain Key Tokens when sending chain Tokens when receiving chain
Ethereum 1 ETH ✅ access to most tokens ✅ access to most tokens
Optimism 10 OPT ETH, USDC, USDT, DAI, WBTC ETH, USDC, USDT, DAI, WBTC
Binance 56 BSC ✅ access to most tokens ✅ access to most tokens
Gnosis 100 DAI ETH, USDC, USDT, DAI, WBTC ETH, USDC, USDT, DAI, WBTC
Polygon 137 POL ✅ access to most tokens ✅ access to most tokens
Fantom 250 FTM ETH, USDC, USDT, DAI, WBTC ETH, USDC, USDT, DAI, WBTC
Moonriver 1285 MOR USDC, USDT USDC, USDT
Arbitrum 42161 ARB ETH, USDC, USDT, DAI, WBTC ETH, USDC, USDT, DAI, WBTC
Avalanche 43114 AVA ✅ access to most tokens ✅ access to most tokens

Usage

First you request a quote (getQuote) for the assets you want to transfer and swap. The returned quote contains a transactionRequest which can be passed to your wallet to start the transfer. Afterwards you want to use the getStatus function to check if the transfer has been been completed on the destination chain.

import { providers, Wallet } from 'ethers'
import { ParaswapConnextSdk } from '../src'

const sdk = new ParaswapConnextSdk()

// get quote
const quote = await sdk.getQuote(
  'USDC',
  'POL',
  'USDT',
  'DAI',
  '1000000',
  await wallet.getAddress()
)

// start transfer
const sendTx = await wallet.sendTransaction(quote.transactionRequest)
await sendTx.wait()

// check status
console.log('>> Check status')
let result
do {
  result = await sdk.getStatus(quote.action.fromChainId, quote.action.toChainId, sendTx.hash)
  await new Promise((resolve) => {
    setTimeout(resolve, 10_000)
  })
} while (
  !result ||
  (result.status !== 'DONE' && result.status !== 'FAILED')
)
console.log('>> FINISHED', result)

Please check the demo script ./demo/demo.js for a complete example.

Extend the SDK

Install dependencies:

yarn

Test

Test your code with Jest framework:

yarn test

Build

Build production (distribution) files in your dist folder:

yarn build

Publish

In order to update the package, commit all new changes first. Then run the following command:

yarn release

This will

  • bump the version number according to the types of the last commits (i.e. if it is a major, minor or bug fix release)
  • create a new git tag
  • update the CHANGELOG.md

Next you need to push both, the code and the new version tag:

git push && git push --tags

paraswap-connext-sdk's People

Contributors

maxklenk avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.