Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rainbow-me/swaps

Package Overview
Dependencies
Maintainers
9
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rainbow-me/swaps

This SDK handles

  • 0.1.0
  • npm
  • Socket score

Version published
Weekly downloads
68
decreased by-46.87%
Maintainers
9
Weekly downloads
 
Created
Source

🌈 Rainbow Swap Aggregator JS SDK

This SDK handles

  • Token to ETH swaps

  • Token to Token swaps

  • ETH to Token swaps

  • Use of permit when supported (to avoid an extra approval)

  • Supported chains are: Mainnet, Ropsten, Rinkeby, Kovan, Optimism, Arbitrum and Polygon

Installation

yarn add @rainbow-me/swaps

Usage

Get a quote for a pair
const quote = await getQuote(
    { 
        source,             //  optional, "oneinch" or "zerox"
        chainId,            //  numeric chain id
        fromAddress,        //  address of the wallet to execute the swap from
        sellTokenAddress,   // address of the input token
        buyTokenAddress,    // address of the output token
        sellAmount,         // amount of the input token (optional)
        buyAmount,          // amount of the output token (optional)
        slippage            // max slippage percentage allowed (optional)
    }   
);

Estimate gas for the swap
const { params, method, methodArgs } = getQuoteExecutionDetails(
        quote,                     //  quote returned from getQuote
        { from: quote.from },      //  transaction options
        provider                   //  ethers provider
      );

const estimatedGas = await method(methodArgs);

Execute swap for a given quote
const tx = await fillQuote(
      quote,                //  quote returned from getQuote
      transactionOptions,   //  gasLimit, maxFeePerGas, maxPriorityFeePerGas, nonce, value,  from 
      permit,               //  true if you want to use the permit
      chainId,              //  numeric chain id
);

FAQs

Package last updated on 14 Mar 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc