0.19.0 • Published 10 days ago
@rainbow-me/swaps v0.19.0
🌈 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, "1inch" or "0x"
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 (required if not passing buyAmount)
buyAmount, // amount of the output token (required if not passing sellAmount)
slippage // max slippage percentage allowed
}
);
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
);
0.19.0
10 days ago
0.18.0
19 days ago
0.17.0
26 days ago
0.16.0
1 month ago
0.15.0
1 month ago
0.13.0
1 month ago
0.14.0
1 month ago
0.12.0
2 months ago
0.11.0
2 months ago
0.10.0
2 months ago
0.9.0
4 months ago
0.9.1
4 months ago
0.8.0
8 months ago
0.5.0
10 months ago
0.7.0
8 months ago
0.6.0
9 months ago
0.4.1
12 months ago
0.4.0
12 months ago
0.4.2
12 months ago
0.3.0
1 year ago
0.3.1
1 year ago
0.2.0
1 year ago
0.1.16
2 years ago
0.1.17
2 years ago
0.1.15
2 years ago
0.1.10
2 years ago
0.1.11
2 years ago
0.1.12
2 years ago
0.1.13
2 years ago
0.1.14
2 years ago
0.1.8
2 years ago
0.1.7
2 years ago
0.1.9
2 years ago
0.1.6
2 years ago
0.1.4
2 years ago
0.1.5
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago