Gathering detailed insights and metrics for @wardenswap/bestrate-sdk
Gathering detailed insights and metrics for @wardenswap/bestrate-sdk
Gathering detailed insights and metrics for @wardenswap/bestrate-sdk
Gathering detailed insights and metrics for @wardenswap/bestrate-sdk
npm install @wardenswap/bestrate-sdk
Typescript
Module System
Node Version
NPM Version
63.1
Supply Chain
93
Quality
80.6
Maintenance
50
Vulnerability
99.5
License
Total Downloads
5,781
Last Day
2
Last Week
14
Last Month
55
Last Year
1,149
Minified
Minified + Gzipped
Latest Version
2.10.0
Package Id
@wardenswap/bestrate-sdk@2.10.0
Unpacked Size
680.36 kB
Size
158.91 kB
File Count
6
NPM Version
10.7.0
Node Version
20.14.0
Publised On
23 Jun 2024
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
133.3%
14
Compared to previous week
Last month
-70.7%
55
Compared to previous month
Last year
-26.4%
1,149
Compared to previous year
An JavaScript/TypeScript SDK library for querying trading quotes from WardenSwap platform. In order to begin trading on WardenSwap, we need the trading path that provide the best rate. The SDK help finding the path with ease!
For more information, check out our documentation here: https://docs.wardenswap.finance/warden/wardenswap-sdk/overview
1# For NPM 2npm install @wardenswap/bestrate-sdk 3 4# For Yarn 5yarn add @wardenswap/bestrate-sdk
Here is the example if JavaScript code for querying best rate and perform a simple swap via WardenSwap SDK.
1// npm install @wardenswap/bestrate-sdk ethers 2const { WardenBestRate } = require('@wardenswap/bestrate-sdk') 3const { ethers } = require('ethers') 4 5// WardenRouter_2_0.abi.json can be found here: https://gist.github.com/AncientWarden/4aeae54509dd21020ab29a13c804cb57 6// or BSCScan: https://bscscan.com/address/0x451ef8D6B645a60115EB8b8bEa76B39C0C761004#code 7const wardenRouterAbi = require('./WardenRouter_2_0.abi.json') 8 9const WARDEN_ROUTER_ADDRESS = '0x451ef8D6B645a60115EB8b8bEa76B39C0C761004' 10 11const src = '0xe9e7cea3dedca5984780bafc599bd69add087d56' // source Token Address: BUSD 12const dest = '0x0feadcc3824e7f3c12f40e324a60c23ca51627fc' // destination Token Address: WAD 13const amountIn = ethers.utils.parseUnits('10', 18) // 10 BUSD in BigNumber 14const gasFee = ethers.BigNumber.from('5000000000') // default BSC gas fee for rate calculation 15const options = { enableSplit: false } // calculate without using split trades 16 17// initialize provider, requires version of ether.js >= 5.4.0 18const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org') 19 20async function getQuote() { 21 // initialize the warden client 22 const wardenClient = new WardenBestRate(provider, 'bsc') 23 24 // get the quote detail with warden client 25 const quote = await wardenClient.getQuote(src, dest, amountIn, gasFee, options) 26 console.log('quote:', quote) 27 28 return quote 29} 30 31async function swap(quote) { 32 // add the acceptable slippage of 1% to amountOut 33 // since the actual amount can be lower or higher. 34 const minAmountOut = ethers.BigNumber.from(quote.amountOut).mul(99).div(100) 35 36 // Get the signer with private key 37 // For using with Metamask, see: https://docs.ethers.io/v5/getting-started/#getting-started--connecting 38 const signer = new ethers.Wallet(YOUR_PRIVATE_KEY, provider) 39 const wardenContract = new ethers.Contract(WARDEN_ROUTER_ADDRESS, wardenRouterAbi, signer) 40 41 // send a swap transaction to warden contract 42 const swapTx = await wardenContract.swap( 43 quote.swapAddress, 44 quote.data, 45 quote.depositAddress, 46 src, 47 amountIn, 48 dest, 49 minAmountOut, 50 signer.address, // dest token receiver 51 0, // Partner ID for profit sharing, default to 0 52 0) // metadata, reserved for future use 53 54 console.log(`swap tx successfully submitted, tx hash: ${swapTx.hash}`) 55} 56 57getQuote().then(quote => swap(quote))
No vulnerabilities found.
No security vulnerabilities found.