SMBSwap
  • SMBSwap Intro
  • 1️⃣Get Started (BSC)
    • Create a Wallet
    • Get BEP20 Tokens
    • Using SMBSwap without Centralized Exchanges
    • Connect Your Wallet to SMBSwap
  • πŸ†˜Help Area
    • General FAQ
    • Troubleshooting Errors
    • Fixing Stuck Pending Transactions in MetaMask
  • πŸ“§Contact Us
    • Business Partnerships
    • Community
    • Customer Support
  • πŸ‘©β€πŸ³The SMB Team
  • πŸ—ΊοΈRoadmap
  • PRODUCTS
    • πŸ”„Exchange
      • πŸͺ™Token Swaps
      • ↕️How To Trade
      • πŸ“³Smart Router
        • How to trade using Smart Router
      • πŸ’΅Liquidity Pools
      • ⚑Zap
      • πŸ“ How to Add/ Remove Liquidity
      • FAQ
    • 🚜Yield Farming
      • How to Use Farms
      • bSELF
        • How to Use bSELF
        • FAQ
      • FAQ
    • πŸ’΅Made Pools - Stake SELF
      • New SELF Made Pool
        • How to Use the Flexible Staking Option
        • How to Use the Fixed-Term Staking Option
        • SELF Made Pool FAQ
      • Other Made Pools
        • Made Pool FAQ & Troubleshooting
    • 🎟️Lottery
      • How to Play SMB Lottery
      • How to Play BUSD Lottery
      • Lottery FAQ
    • πŸ“ŠAnalytics
    • β˜‘οΈVoting
      • How to Vote
  • TOKENOMICS
    • πŸͺ™SELF
      • SELF Tokenomics
      • Controlling SELF Supply
  • DEVELOPERS
    • 🚚v3 Migration
      • How to migrate
      • How v3 APR is calculated
      • FAQ
    • 🚚v2 Migration
      • Migrate Your Stakings
      • MasterChef v2
        • List of Farms
      • SELF Made Pool
    • Smart Contracts (EVM)
      • SMBSwap Exchange
        • v3
          • SMBV3Factory
          • SmartRouterV3
            • V3SwapRouter
            • V2SwapRouter
            • StableSwapRouter
          • NonfungiblePositionManager
          • SMBV3Pool
        • v2
          • Factory v2
          • Router v2
        • Stable Swap
          • StableSwap Pools
        • Smart Router
      • MasterChef
        • MasterChef V3
      • Made Pools
      • SELF Made Pool
      • Lottery
      • Farm Booster (bSELF)
    • 🧠Smart Contracts (BSC)
      • SMBSwap Exchange
        • Factory v2
        • Router v2
      • MasterChef
      • Made Pools
      • SELF Made Pool
      • Lottery
      • Farm Booster (bSELF)
    • πŸͺ°Report a Bug
  • JOIN THE TEAM
    • πŸ”‘Opportunities
  • REFERENCE/ ARCHIVE
    • Auto SELF Made Pool
    • How to Use Farms with BscScan
    • Main Staking/ Made Pool/ MasterChef Contract
    • Auto SELF Made Pool (SelfVault)
Powered by GitBook
On this page
  • Contract info
  • Read functions
  • WETH
  • factory
  • getAmountOut
  • getAmountIn
  • getAmountsOut
  • getAmountsIn
  • quote
  • Write functions
  • addLiquidity
  • addLiquidityETH
  • removeLiquidity
  • removeLiquidityETH
  • removeLiquidityETHSupportingFeeOnTransferTokens
  • removeLiquidityETHWithPermit
  • removeLiquidityETHWithPermitSupportingFeeOnTransferTokens
  • removeLiquidityWithPermit
  • swapETHForExactTokens
  • swapExactETHForTokens
  • swapExactETHForTokensSupportingFeeOnTransferTokens
  • swapExactTokensForETH
  • swapExactTokensForETHSupportingFeeOnTransferTokens
  • swapExactTokensForTokens
  • swapExactTokensForTokensSupportingFeeOnTransferTokens
  • swapTokensForExactETH
  • swapTokensForExactTokens
  • Interface
  1. DEVELOPERS
  2. Smart Contracts (BSC)
  3. SMBSwap Exchange

Router v2

PreviousFactory v2NextMasterChef

Last updated 2 years ago

SMBSwap is based on Uniswap v2. Read the . For more in-depth information on the core contract logic, read the .

Contract info

Contract name: SMBRouter Contract address: 0x009d611490eCfED2dC3F306231Bba7e7F3E9196E

View the .

Read functions

WETH

function WETH() external pure returns (address);

Returns the canonical address for (WETH being a vestige from Ethereum network origins).

factory

function factory() external pure returns (address);

Returns the canonical address for .

For explanations of the following, view the .

getAmountOut

function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut);

getAmountIn

function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn);

getAmountsOut

function getAmountsOut(uint amountIn, address[] memory path) internal view returns (uint[] memory amounts);

getAmountsIn

function getAmountsIn(uint amountOut, address[] memory path) internal view returns (uint[] memory amounts);

quote

function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB);

Write functions

addLiquidity

function addLiquidity(
  address tokenA,
  address tokenB,
  uint amountADesired,
  uint amountBDesired,
  uint amountAMin,
  uint amountBMin,
  address to,
  uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);

Adds liquidity to a BEP20⇄BEP20 pool.

Name
Type

tokenA

address

The contract address of one token from your liquidity pair.

tokenB

address

The contract address of the other token from your liquidity pair.

amountADesired

uint

The amount of tokenA you'd like to provide as liquidity.

amountBDesired

uint

The amount of tokenA you'd like to provide as liquidity.

amountAMin

uint

The minimum amount of tokenA to provide (slippage impact).

amountBMin

uint

The minimum amount of tokenB to provide (slippage impact).

to

address

Address of LP Token recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

addLiquidityETH

function addLiquidityETH(
  address token,
  uint amountTokenDesired,
  uint amountTokenMin,
  uint amountETHMin,
  address to,
  uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);

Adds liquidity to a BEP20⇄WBNB pool.

Name
Type

addLiquidityETH

uint

The payable amount in BNB.

token

address

The contract address of the token to add liquidity.

amountTokenDesired

uint

The amount of the token you'd like to provide as liquidity.

amountTokenMin

uint

The minimum amount of the token to provide (slippage impact).

amountETHMin

uint

The minimum amount of BNB to provide (slippage impact).

to

address

Address of LP Token recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

removeLiquidity

function removeLiquidity(
  address tokenA,
  address tokenB,
  uint liquidity,
  uint amountAMin,
  uint amountBMin,
  address to,
  uint deadline
) external returns (uint amountA, uint amountB);

Removes liquidity from a BEP20⇄BEP20 pool.

Name
Type

tokenA

address

The contract address of one token from your liquidity pair.

tokenB

address

The contract address of the other token from your liquidity pair.

liquidity

uint

The amount of LP Tokens to remove.

amountAMin

uint

The minimum amount of tokenA to remove (slippage impact).

amountBMin

uint

The minimum amount of tokenB to remove (slippage impact).

to

address

Address of LP Token recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

removeLiquidityETH

function removeLiquidityETH(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountETHMin,
  address to,
  uint deadline
) external returns (uint amountToken, uint amountETH);

Removes liquidity from a BEP20⇄WBNB pool.

Name
Type

token

address

The contract address of the token to remove liquidity.

liquidity

uint

The amount of LP Tokens to remove.

amountTokenMin

uint

The minimum amount of the token to remove (slippage impact).

amountETHMin

uint

The minimum amount of BNB to remove (slippage impact).

to

address

Address of LP Token recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

removeLiquidityETHSupportingFeeOnTransferTokens

function removeLiquidityETHSupportingFeeOnTransferTokens(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountETHMin,
  address to,
  uint deadline
) external returns (uint amountETH);

Removes liquidity from a BEP20⇄WBNB for tokens that take a fee on transfer.

Name
Type

token

address

The contract address of the token to remove liquidity.

liquidity

uint

The amount of LP Tokens to remove.

amountTokenMin

uint

The minimum amount of the token to remove (slippage impact).

amountETHMin

uint

The minimum amount of BNB to remove (slippage impact).

to

address

Address of LP Token recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

removeLiquidityETHWithPermit

function removeLiquidityETHWithPermit(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountETHMin,
  address to,
  uint deadline,
  bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);

Removes liquidity from a BEP20⇄WBNB and receives BNB, without pre-approval, via permit.

Name
Type

token

address

The contract address of the token to remove liquidity.

liquidity

uint

The amount of LP Tokens to remove.

amountTokenMin

uint

The minimum amount of the token to remove (slippage impact).

amountETHMin

uint

The minimum amount of BNB to remove (slippage impact).

to

address

Address of LP Token recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

approveMax

bool

Whether or not the approval amount in the signature is for liquidity or uint(-1).

v

uint8

The v component of the permit signature.

r

bytes32

The r component of the permit signature.

s

bytes32

The s component of the permit signature.

removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
  address token,
  uint liquidity,
  uint amountTokenMin,
  uint amountETHMin,
  address to,
  uint deadline,
  bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);

Removes liquidity from a BEP20⇄WBNB and receives BNB via permit for tokens that take a fee on transfer.

Name
Type

token

address

The contract address of the token to remove liquidity.

liquidity

uint

The amount of LP Tokens to remove.

amountTokenMin

uint

The minimum amount of the token to remove (slippage impact).

amountETHMin

uint

The minimum amount of BNB to remove (slippage impact).

to

address

Address of LP Token recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

approveMax

bool

Whether or not the approval amount in the signature is for liquidity or uint(-1).

v

uint8

The v component of the permit signature.

r

bytes32

The r component of the permit signature.

s

bytes32

The s component of the permit signature.

removeLiquidityWithPermit

function removeLiquidityWithPermit(
  address tokenA,
  address tokenB,
  uint liquidity,
  uint amountAMin,
  uint amountBMin,
  address to,
  uint deadline,
  bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);

Removes liquidity from a BEP20⇄BEP20, without pre-approval, via permit.

Name
Type

tokenA

address

The contract address of one token from your liquidity pair.

tokenB

address

The contract address of the other token from your liquidity pair.

liquidity

uint

The amount of LP Tokens to remove.

amountTokenMin

uint

The minimum amount of the token to remove (slippage impact).

amountETHMin

uint

The minimum amount of BNB to remove (slippage impact).

to

address

Address of LP Token recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

approveMax

bool

Whether or not the approval amount in the signature is for liquidity or uint(-1).

v

uint8

The v component of the permit signature.

r

bytes32

The r component of the permit signature.

s

bytes32

The s component of the permit signature.

swapETHForExactTokens

function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
  external
  payable
  returns (uint[] memory amounts);

Receive an exact amount of output tokens for as little BNB as possible.

Name
Type

swapETHForExactTokens

uint

Payable BNB amount.

amountOut

uint

The amount tokens to receive.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

swapExactETHForTokens

function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
  external
  payable
  returns (uint[] memory amounts);

Receive as many output tokens as possible for an exact amount of BNB.

Name
Type

swapExactETHForTokens

uint

Payable BNB amount.

amountOutMin

uint

The minimum amount tokens to receive.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

swapExactETHForTokensSupportingFeeOnTransferTokens

function swapExactETHForTokensSupportingFeeOnTransferTokens(
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external payable;

Receive as many output tokens as possible for an exact amount of BNB. Supports tokens that take a fee on transfer.

Name
Type

swapExactETHForTokensSupportingFeeOnTransferTokens

uint

Payable BNB amount.

amountOutMin

uint

The minimum amount tokens to receive.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

swapExactTokensForETH

function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
  external
  returns (uint[] memory amounts);

Receive as much BNB as possible for an exact amount of input tokens.

Name
Type

amountIn

uint

Payable amount of input tokens.

amountOutMin

uint

The minimum amount tokens to receive.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

swapExactTokensForETHSupportingFeeOnTransferTokens

function swapExactTokensForETHSupportingFeeOnTransferTokens(
  uint amountIn,
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external;

Receive as much BNB as possible for an exact amount of tokens. Supports tokens that take a fee on transfer.

Name
Type

amountIn

uint

Payable amount of input tokens.

amountOutMin

uint

The minimum amount tokens to receive.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

swapExactTokensForTokens

function swapExactTokensForTokens(
  uint amountIn,
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external returns (uint[] memory amounts);

Receive as many output tokens as possible for an exact amount of input tokens.

Name
Type

amountIn

uint

Payable amount of input tokens.

amountOutMin

uint

The minimum amount tokens to receive.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

swapExactTokensForTokensSupportingFeeOnTransferTokens

function swapExactTokensForTokensSupportingFeeOnTransferTokens(
  uint amountIn,
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external;

Receive as many output tokens as possible for an exact amount of input tokens. Supports tokens that take a fee on transfer.

Name
Type

amountIn

uint

Payable amount of input tokens.

amountOutMin

uint

The minimum amount tokens to receive.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

swapTokensForExactETH

function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
  external
  returns (uint[] memory amounts);

Receive an exact amount of ETH for as few input tokens as possible.

Name
Type

amountOut

uint

Payable amount of input tokens.

amountInMax

uint

The minimum amount tokens to input.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

swapTokensForExactTokens

function swapTokensForExactTokens(
  uint amountOut,
  uint amountInMax,
  address[] calldata path,
  address to,
  uint deadline
) external returns (uint[] memory amounts);

Receive an exact amount of output tokens for as few input tokens as possible.

Name
Type

amountOut

uint

Payable amount of input tokens.

amountInMax

uint

The minimum amount tokens to input.

path (address[])

address

An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.

to

address

Address of recipient.

deadline

uint

Unix timestamp deadline by which the transaction must confirm.

Interface

import '@uniswap/v2-core/contracts/interfaces/ISMBRouter.sol';
pragma solidity >=0.6.2;

interface ISMBRouter01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

// File: contracts\interfaces\ISMBRouter02.sol

pragma solidity >=0.6.2;

interface ISMBRouter02 is ISMBRouter01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}
🧠
Uniswap v2 documentation
Uniswap v2 Core whitepaper
SMBSwap: Router v2 contract on BscScan
Binance: WBNB token
SMBFactory
Uniswap v2 Internal Functions documentation