diff --git a/package-lock.json b/package-lock.json index f74426e..446df6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "simple-pancakeswap-sdk", + "name": "simple-pancakeswap-sdk-with-multicall-fix", "version": "1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "simple-pancakeswap-sdk", + "name": "simple-pancakeswap-sdk-with-multicall-fix", "version": "1.1.1", "license": "ISC", "dependencies": { diff --git a/src/common/tokens/btcb.ts b/src/common/tokens/btcb.ts new file mode 100644 index 0000000..8539e2f --- /dev/null +++ b/src/common/tokens/btcb.ts @@ -0,0 +1,19 @@ +import { ChainId } from '../../enums/chain-id'; + +/** + * BTCB token context + */ +export class BTCB { + /** + * Get BTCB token info + */ + public static token() { + return { + chainId: ChainId.BSC, + contractAddress: '0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c', + decimals: 18, + symbol: 'BTCB', + name: 'Binance-Peg BTCB Token', + }; + } +} \ No newline at end of file diff --git a/src/common/tokens/busd.ts b/src/common/tokens/busd.ts new file mode 100644 index 0000000..778cb83 --- /dev/null +++ b/src/common/tokens/busd.ts @@ -0,0 +1,19 @@ +import { ChainId } from '../../enums/chain-id'; + +/** + * BUSD token context + */ +export class BUSD { + /** + * Get BUSD token info + */ + public static token() { + return { + chainId: ChainId.BSC, + contractAddress: '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', + decimals: 18, + symbol: 'BUSD', + name: 'Binance-Peg BUSD Token', + }; + } +} \ No newline at end of file diff --git a/src/common/tokens/index.ts b/src/common/tokens/index.ts index 5fa074e..c699911 100644 --- a/src/common/tokens/index.ts +++ b/src/common/tokens/index.ts @@ -3,3 +3,5 @@ export { COMP } from './comp'; export { DAI } from './dai'; export { USDC } from './usdc'; export { USDT } from './usdt'; +export { BTCB } from './btcb'; +export { BUSD } from './busd'; \ No newline at end of file diff --git a/src/factories/router/pancakeswap-router.factory.ts b/src/factories/router/pancakeswap-router.factory.ts index 6b687c3..9b27a62 100644 --- a/src/factories/router/pancakeswap-router.factory.ts +++ b/src/factories/router/pancakeswap-router.factory.ts @@ -13,6 +13,8 @@ import { COMP } from '../../common/tokens/comp'; import { DAI } from '../../common/tokens/dai'; import { USDC } from '../../common/tokens/usdc'; import { USDT } from '../../common/tokens/usdt'; +import { BTCB } from '../../common/tokens/btcb'; +import { BUSD } from '../../common/tokens/busd'; import { formatEther } from '../../common/utils/format-ether'; import { hexlify } from '../../common/utils/hexlify'; import { onlyUnique } from '../../common/utils/only-unique'; @@ -56,6 +58,8 @@ export class PancakeswapRouterFactory { this.mainCurrenciesPairsForDAI, this.mainCurrenciesPairsForUSDC, this.mainCurrenciesPairsForWETH, + this.mainCurrenciesPairsForBTCB, + this.mainCurrenciesPairsForBUSD, [[this._fromToken, this._toToken]], ]; } else { @@ -533,6 +537,8 @@ export class PancakeswapRouterFactory { private get allMainTokens(): Token[] { if (this._ethersProvider.provider.network.chainId === ChainId.BSC) { return [ + this.BTCBTokenForConnectedNetwork, + this.BUSDTokenForConnectedNetwork, this.USDTTokenForConnectedNetwork, this.COMPTokenForConnectedNetwork, this.USDCTokenForConnectedNetwork, @@ -546,6 +552,8 @@ export class PancakeswapRouterFactory { private get mainCurrenciesPairsForFromToken(): Token[][] { const pairs = [ + [this._fromToken, this.BTCBTokenForConnectedNetwork], + [this._fromToken, this.BUSDTokenForConnectedNetwork], [this._fromToken, this.USDTTokenForConnectedNetwork], [this._fromToken, this.COMPTokenForConnectedNetwork], [this._fromToken, this.USDCTokenForConnectedNetwork], @@ -563,6 +571,8 @@ export class PancakeswapRouterFactory { [this.USDCTokenForConnectedNetwork, this._toToken], [this.DAITokenForConnectedNetwork, this._toToken], [this.WETHTokenForConnectedNetwork, this._toToken], + [this.BTCBTokenForConnectedNetwork, this._toToken], + [this.BUSDTokenForConnectedNetwork, this._toToken], ]; return pairs.filter((t) => t[0].contractAddress !== t[1].contractAddress); @@ -574,6 +584,8 @@ export class PancakeswapRouterFactory { [this.USDTTokenForConnectedNetwork, this.DAITokenForConnectedNetwork], [this.USDTTokenForConnectedNetwork, this.USDCTokenForConnectedNetwork], [this.USDTTokenForConnectedNetwork, this.WETHTokenForConnectedNetwork], + [this.USDTTokenForConnectedNetwork, this.BUSDTokenForConnectedNetwork], + [this.USDTTokenForConnectedNetwork, this.BTCBTokenForConnectedNetwork], ]; } @@ -583,6 +595,8 @@ export class PancakeswapRouterFactory { [this.COMPTokenForConnectedNetwork, this.DAITokenForConnectedNetwork], [this.COMPTokenForConnectedNetwork, this.USDCTokenForConnectedNetwork], [this.COMPTokenForConnectedNetwork, this.WETHTokenForConnectedNetwork], + [this.COMPTokenForConnectedNetwork, this.BUSDTokenForConnectedNetwork], + [this.COMPTokenForConnectedNetwork, this.BTCBTokenForConnectedNetwork], ]; } @@ -590,6 +604,8 @@ export class PancakeswapRouterFactory { return [ [this.DAITokenForConnectedNetwork, this.COMPTokenForConnectedNetwork], [this.DAITokenForConnectedNetwork, this.WETHTokenForConnectedNetwork], + [this.DAITokenForConnectedNetwork, this.BUSDTokenForConnectedNetwork], + [this.DAITokenForConnectedNetwork, this.BTCBTokenForConnectedNetwork], ]; } @@ -599,6 +615,8 @@ export class PancakeswapRouterFactory { [this.USDCTokenForConnectedNetwork, this.COMPTokenForConnectedNetwork], [this.USDCTokenForConnectedNetwork, this.DAITokenForConnectedNetwork], [this.USDCTokenForConnectedNetwork, this.WETHTokenForConnectedNetwork], + [this.USDCTokenForConnectedNetwork, this.BUSDTokenForConnectedNetwork], + [this.USDCTokenForConnectedNetwork, this.BTCBTokenForConnectedNetwork], ]; } @@ -608,9 +626,33 @@ export class PancakeswapRouterFactory { [this.WETHTokenForConnectedNetwork, this.COMPTokenForConnectedNetwork], [this.WETHTokenForConnectedNetwork, this.DAITokenForConnectedNetwork], [this.WETHTokenForConnectedNetwork, this.USDCTokenForConnectedNetwork], + [this.WETHTokenForConnectedNetwork, this.BUSDTokenForConnectedNetwork], + [this.WETHTokenForConnectedNetwork, this.BTCBTokenForConnectedNetwork], ]; } + private get mainCurrenciesPairsForBTCB(): Token[][] { + return [ + [this.BTCBTokenForConnectedNetwork, this.USDTTokenForConnectedNetwork], + [this.BTCBTokenForConnectedNetwork, this.COMPTokenForConnectedNetwork], + [this.BTCBTokenForConnectedNetwork, this.DAITokenForConnectedNetwork], + [this.BTCBTokenForConnectedNetwork, this.USDCTokenForConnectedNetwork], + [this.BTCBTokenForConnectedNetwork, this.WETHTokenForConnectedNetwork], + [this.BTCBTokenForConnectedNetwork, this.BUSDTokenForConnectedNetwork], + ] + } + + private get mainCurrenciesPairsForBUSD(): Token[][] { + return [ + [this.BUSDTokenForConnectedNetwork, this.USDTTokenForConnectedNetwork], + [this.BUSDTokenForConnectedNetwork, this.COMPTokenForConnectedNetwork], + [this.BUSDTokenForConnectedNetwork, this.DAITokenForConnectedNetwork], + [this.BUSDTokenForConnectedNetwork, this.USDCTokenForConnectedNetwork], + [this.BUSDTokenForConnectedNetwork, this.BTCBTokenForConnectedNetwork], + [this.BUSDTokenForConnectedNetwork, this.WETHTokenForConnectedNetwork], + ] + } + private get USDTTokenForConnectedNetwork() { return USDT.token(); } @@ -630,4 +672,12 @@ export class PancakeswapRouterFactory { private get WETHTokenForConnectedNetwork() { return BNB.token(); } + + private get BTCBTokenForConnectedNetwork() { + return BTCB.token(); + } + + private get BUSDTokenForConnectedNetwork() { + return BUSD.token(); + } }