npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bsc-dex-helper

v1.0.0

Published

BSC DEX (PancakeSwap V2) helpers for trading bots: quotes, swap params, slippage

Readme

bsc-dex-helper

BSC DEX helpers for trading bots: PancakeSwap V2 router/factory addresses, getAmountsOut/getAmountsIn quotes, and slippage utilities.

Install

npm install bsc-dex-helper

Use with a BSC provider (e.g. bsc-provider-helper):

npm install bsc-provider-helper bsc-dex-helper

Usage

const { getProvider } = require('bsc-provider-helper');
const {
  getRouterV2,
  getWbnb,
  getAmountsOut,
  getAmountsIn,
  quoteOut,
  applySlippageBps,
} = require('bsc-dex-helper');

const provider = getProvider();
const WBNB = getWbnb(56);
const BUSD = '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56'; // BSC mainnet example

// Quote: 1 BNB -> expected BUSD out
const oneBnb = 10n ** 18n;
const amounts = await getAmountsOut(provider, oneBnb, [WBNB, BUSD]);
const expectedOut = amounts[amounts.length - 1];

// Min amount out with 0.5% slippage (50 bps)
const minOut = applySlippageBps(expectedOut, 50);

// Required amount in for 1000 BUSD out
const wantOut = 1000n * 10n ** 18n;
const requiredIn = await quoteIn(provider, wantOut, WBNB, BUSD);

Subpath imports

const { getRouterV2, getWbnb } = require('bsc-dex-helper/addresses');
const { getAmountsOut, quoteOut } = require('bsc-dex-helper/quotes');
const { applySlippageBps, addSlippageBps } = require('bsc-dex-helper/slippage');

API

Addresses (lib/addresses.js)

| Method / Constant | Description | |------------------|-------------| | getRouterV2(chainId?) | PancakeSwap V2 router address (BSC 56 / testnet 97) | | getFactoryV2(chainId?) | PancakeSwap V2 factory address | | getWbnb(chainId?) | WBNB token address | | ROUTER_V2, FACTORY_V2, WBNB_MAINNET, WBNB_TESTNET | Raw address maps |

Quotes (lib/quotes.js)

| Method | Description | |--------|-------------| | getAmountsOut(provider, amountIn, path, chainId?) | Router getAmountsOut; returns array of amounts (last = expected out) | | getAmountsIn(provider, amountOut, path, chainId?) | Router getAmountsIn; returns array (first = required in) | | quoteOut(provider, amountIn, tokenIn, tokenOut, chainId?) | Single-hop expected amountOut | | quoteIn(provider, amountOut, tokenIn, tokenOut, chainId?) | Single-hop required amountIn |

Slippage (lib/slippage.js)

| Method | Description | |--------|-------------| | applySlippageBps(amount, slippageBps) | Min amount after slippage (e.g. 50 bps = 0.5%) | | applySlippagePercent(amount, slippagePercent) | Same using percentage (e.g. 0.5) | | addSlippageBps(amount, slippageBps) | Max amount (e.g. for amountInMax) |

Dependencies

  • ethers ^6.x

Optional peer: bsc-provider-helper for getProvider() when using this in a bot.

License

MIT