Complete Guide to a Decentralized Exchange – PancakeSwap

Myron Last Updated : 10 Oct, 2022
12 min read

This article was published as a part of the Data Science Blogathon.

Introduction

We as users require a platform to trade; buy and sell our assets. Traditionally, we use a centralized exchange to trade our assets. These centralized exchanges are the middlemen. Our crypto assets are stored on these exchanges, and the exchanges have control over our keys. If these exchanges decide to suspend withdrawals or any features on the exchange, our assets will be stuck on the exchange. This was a similar case that happened to exchanges such as Celsius, Voyager, and Vauld. Due to this, many users’ funds to date are stuck in these exchanges.

Blockchain resolves the above issues by introducing the concept of decentralization. Blockchain technology eliminates the middlemen, giving users control of their assets.

In this guide, I will walk you through how to use one of the most popular decentralized exchanges in the space – PancakeSwap.

What is a Decentralized Exchange (DEX)?

Decentralization brings power into the hands of the people. A decentralized exchange is a decentralized application (dapp) built on a blockchain that allows users to trade their assets in a decentralized manner. As a result, a user does not have to deposit their funds on the exchange. A DEX places control in the hands of the user. All the transactions that a user wants to perform take place via a crypto wallet, and for these transactions to take place, a user must pay fees which is very little compared to a centralized exchange. Hence, users can trade assets without actually depositing these assets on the exchange.

Every DEX is built on a blockchain. For example, UniSwap is a DEX built on the Ethereum blockchain, Raydium is a DEX built on the Solana blockchain, and PancakeSwap is a DEX built on the balance smart chain network. For interacting with a DEX, some fees are required. These fees are in very small amounts as compared to a CEX. The fees are paid in the underlying blockchain native token.

For example, to interact with UniSwap, a user is supposed to pay fees in ETH. For Raydium a user is supposed to pay fees in SOL and for PancakeSwap, a user is supposed to pay fees in BNB.

What is PancakeSwap?

PancakeSwap is a decentralized exchange that is built on the Binance Smart Chain Network (BSC). PancakeSwap allows users to easily swap, stake, farm their crypto assets, participate in contests, and offer many more features.

PancakeSwap
Source: https://docs.pancakeswap.finance/products/pancakeswap-exchange

To access PancakeSwap, a user must use a wallet connected to the Binance Smart Chain Network.

Furthermore, Users are supposed to pay fees in the form of BNB tokens, to perform any transaction on the dapp.

Wallet Used in PancakeSwap

As specified above, we are supposed to use a crypto wallet to interact with a decentralized application. In this guide, I will use the MetaMask web extension wallet to perform any transactions with the DEX.

MetaMask is a crypto wallet where users can send, receive, swap, store, and buy digital assets easily and securely.

PancakeSwap
Source: https://play.google.com/store/apps/details?id=io.metamask&hl=en_US&gl=US

To learn how to connect your MetaMask with the Binance Smart Chain Network, click here.

Connect your Web3 Wallet to the Dapp

The first step to accessing a DEX is to connect your crypto wallet; here, in our case, the MetaMask wallet. You can connect your crypto wallet by following the steps below:

Click here to go to the PancakeSwap application directly.

  1. Click on the Connect Wallet button.
  2. Select your preferred wallet.
  3. Your wallet will now open on your browser. Select which account of your wallet you want to connect to the DEX.
  4. Click on the Next button in your wallet.
  5. Click on the Connect button.
  6. Once connected, you will notice your wallet address on the home page as well as in the top right-hand corner of the application.
Connect button.
Connect button.
Connect button.

Your wallet is now connected to the DEX. Hence you can now interact with the DEX features.

Swap Tokens

Swapping refers to the process of converting one token to another. For example, converting BNB to ETH.

Users can swap their tokens the following way:

  1. Since we are on the home page, hover over the Trade option in the navbar.
  2. Select the Swap option.
  3. On the Swap page, click on the token you wish to swap.
  4. Select or search for the token with which you want to swap the respective token.
  5. Enter the amount of the token you want to swap.
  6. Click on the Swap button.
  7. Recheck your swap and click on the Confirm Swap button.
  8. Your wallet will now open, from which you are required to confirm the transaction. Click on the Confirm button in your wallet.
Swap Tokens
Swap Tokens
Swap Tokens
Swap Tokens

Once the swap is complete, in your wallet, you will notice a decrease in the quantity of the tokens you swapped with and an increase in the quantity of the tokens you swapped it for.

Limit Orders

The limit option in pancake swap is the same as in trading. Limit here refers to a particular price you want to swap the respective token. You can set the price you want to perform the swap in the limit option. Only if the price is met then will the transaction get executed.

For example, you can set the limit price to $200 to swap BNB for BUSD. Only if the price of BNB reaches $200 will the transaction take place.

Used can swap their tokens using the limit option in the following way:

  1. Select the Limit option below the navbar.
  2. On the Limit page, click on the token you wish to swap.
  3. Select or search for the token with which you want to swap the respective token.
  4. Enter the amount of the token you want to swap.
  5. Enter the price at which you want the swap to take place.
  6. Click on the Swap button.
  7. Your wallet will now open, from which you are required to confirm the transaction. Click on the Confirm button in your wallet.
  8. Scroll down to see your open orders. Your open orders are the orders which are still pending to be executed.
  9. The order history option shows you all your past executed swaps using the limit option.
Limit Orders
Limit Orders

Once the limit price is met, the swap will be executed, and in your wallet, you will notice a decrease in the quantity of the tokens you swapped with and an increase in the quantity of the tokens you swapped for.

Provide Liquidity

Liquidity refers to lending your crypto to the exchange to increase the liquidity of the protocol. A protocol having high liquidity will be able to execute transactions (swap) very easily.

Users are required to provide liquidity in the form of two tokens. Both tokens are required to be in 50-50 weightage.

For example, if you are providing liquidity to the USDT-BUSD pair, you are required to supply the same quantity of BUSD and USDT.

For liquidity, users have rewarded LP tokens that they can stake and earn a good yield. Furthermore, users are also rewarded 0.17% of the fees generated by the respective trading pair.

Users can provide liquidity by following the steps below:

  1. Since we are on the limit page, hover over the Trade option in the navbar.
  2. Select the Liquidity option.
  3. On the Liquidity page, click on the Add Liquidity button.
  4. Select the pair to which you want to add liquidity.
  5. Click on the Add Liquidity button.
  6. Enter the amount of liquidity you want to provide.
  7. Click on the Supply button.
  8. Your wallet will now open, from which you are required to confirm the transaction. Click on the Confirm button in your wallet.
Provide Liquidity| PancakeSwap
Provide Liquidity| PancakeSwap
Provide Liquidity

Once the transaction is processed, you will notice the number of tokens you used to supply liquidity is decreased, and you will notice a new token in your wallet, the LP token.

Earn Features

Lets us now put our crypto to work. In the Earn section, we can earn yield for staking our tokens or LP tokens. This is similar to the concept of dividends in the stock market. Users are required to stake their tokens for a particular time (fixed) or flexible time and, depending on the yield rates, will earn the respective returns.

Farms (LP Staking)

The farm option is similar to the pool option. The only difference is that users are required to stake their LP tokens in the farm option. By staking their LP tokens, users can earn a good additional yield on their tokens.

Users can stake their LP tokens by following the steps below:

  1. Hover over the Earn option in the navbar.
  2. Select the Farm option.
  3. On the Farm page, select the LP tokens you wish to stake.
  4. For first-time users, click on the Enable button and confirm the transaction in your wallet (Skip this step if you have already enabled the farm).
  5. Click on the LP token pair and click the Stake LP button.
  6. Enter the amount of LP tokens you want to stake.
  7. Click on the Confirm button.
  8. Your wallet will now open, from which you are required to confirm the transaction. Click on the Confirm button in your wallet.
Provide Liquidity| PancakeSwap

 

Provide Liquidity| PancakeSwap

 

Provide Liquidity| PancakeSwap
lockup period.

 

lockup period.| PancakeSwap

To calculate your ROI follow the steps below:

  1. On the token you are swapping, click on the calculator icon.
  2. Enter your investment amount.
  3. Select the duration of your lockup period.
  4. Select the compounding period of your profits.
  5. These are your results.
lockup period.

Whatever returns are shown are not guaranteed. The APR fluctuates from day to day. So you can expect your results to be higher or lower.

Your LP tokens will now be earning you yield. Click on the harvest option after selecting your token to withdraw your yield.

Pools (Token Staking)

The pool section is used to stake your tokens to earn yield. You can stake your tokens for a fixed amount of time or variable time. The yield rates for fixed staking are much higher than flexible staking.

Users can stake their tokens by following the steps below:

  1. Select the Pool option from below the navbar.
  2. On the Pool page, select the token you wish to stake.
  3. For first-time users, click on the Enable button and confirm the transaction in your wallet (Skip this step if you have already enabled the pool).
  4. Click on the token and select which staking method you would prefer – flexible or locked.
Pools (Token Staking)
Pools (Token Staking)| PancakeSwap
Pools (Token Staking)
Pools (Token Staking)| PancakeSwap

Follow the steps below for staking via locked or flexible method.

Flexible:

In flexible staking, users can withdraw their staked tokens whenever they please.

  1. Enter the number of tokens you want to stake.,
  2. Click on the Confirm button.
  3. Your wallet will now open, from which you are required to confirm the transaction. Click on the Confirm button in your wallet.
| PancakeSwap

Locked:

In locked staking, users stake their tokens for a fixed time. Users will not be able to withdraw their tokens until maturity (similar to FD). Locked staking provides higher rates.

  1. Enter the number of tokens you want to stake.,
  2. Select the duration you want to lock your tokens for.
  3. Click on the Confirm button.
  4. Your wallet will now open, from which you are required to confirm the transaction. Click on the Confirm button in your wallet.
Locked:

Once the transaction has been confirmed, you will notice the number of tokens you allocated to staking has been decreased in your wallet. Once the duration of your staking is complete, the tokens, along with interest will be automatically transferred to your wallet.

To calculate your ROI follow the steps below:

  1. On the token you are swapping, click on the calculator icon.
  2. Enter your investment amount.
  3. Select the duration of your lockup period.
  4. These are your results.
  5. You can do the same for Flexible staking by clicking on the Flexible option.
Flexible option.

Whatever returns are shown are not guaranteed. The APR fluctuates from day to day. So you can expect your results to be higher or lower.

Prediction

The prediction section is like gambling. Users can bet whether the price of $CAKE or $BNB will go up or down in 5 minutes. If the user predicts the right answer, they will receive their investment x the payout. If the user bets the wrong way, they will lose the entire investment.

For example, if a user invests $10, the payout is 2, and the user’s prediction is UP. If, after 5 minutes, the asset price goes up from the price the user entered, the user will earn 3*10 = $20.

Users can predict by following the steps below:

  1. Hover over the Win option in the navbar.
  2. Select the Prediction option.
  3. On the Prediction page, you will notice the current and next predictions.
  4. On the next prediction, click Up or Down (Wherever you predict the market to move in the next 5 minutes).
  5. You can see the payouts for both predictions.
  6. You can notice the time remaining for the next round to start.
  7. For first-time users, click the Enable button and confirm the transaction in your wallet (Skip this step if you have already enabled the pool).
  8. Enter the amount you wish to invest.
  9. Click on the Confirm button.
  10. Your wallet will now open, from which you are required to confirm the transaction. Click on the Confirm button in your wallet.
Prediction

 

Prediction| PancakeSwap
Prediction| PancakeSwap

 

Prediction | PancakeSwap

If you win, you will receive the payout and your initial investment directly in your wallet.

Bonus Tip!

You must have noticed a slippage option when performing any transaction, such as swapping or adding liquidity.

Slippage refers to the price change between the expected order price and the executed order price.

For example, if your slippage is 10% and you wish to swap an asset, the asset may get swapped when the asset price is +10% or -10%.

To edit the slippage, follow the steps below:

  1. On the swap page, click on the settings icon.
  2. Enter or select your preferred slippage percent.
PancakeSwap

 

Conclusion

There you go, you know now how to use a PancakeSwap Decentralized Exchange. Each blockchain (Ethereum, Avalanche, Solana) has its own DEX having various features. There are several risks associated with a DEX. Therefore, please conduct intensive research before connecting your wallet to a DEX. Many of these risks are related to smart contract hacks. But DEXs such as Pancake Swap, UniSwap, and DEXs in general, which have high liquidity and are very popular, are smart contracts audited. This means the DEX has a small chance of getting hacked. Furthermore, there are risks related to staking as well. A piece of advice to you is – to avoid investing in something too good to be true.

For example, neither invest nor stake coins that offer returns having huge numbers (APR /APY>1000). Normally these tokens end up being a Ponzi scheme and often go to zero. All the content in this article is purely for educational purposes and does not provide any financial advice.

Also, before visiting any dapp site, ensure that the URL is correct. You may do this by visiting the protocol’s social media profiles, such as Twitter, and using the links in the bio. There have been several scams as a result of phishing links.

If you have enjoyed this guide, please let me know in the comments and consider following. Thank you for your time.

Key Takeaways

  1. Decentralized exchange gives control to the people.
  2. A decentralized exchange allows users to trade assets without depositing them on the exchange.
  3. PancakeSwap is a decentralized exchange built on the Binance Smart Chain (BSC) network. Transaction fees on the exchange are paid in the BNB coin.
  4. PancakeSwap allows users to swap, stake, farm, and participate in contests and lottery and offers many more features.
  5. Decentralized applications have risks associated with them. Please conduct intensive research before connecting to any decentralized platform.
  6. Lastly, stay safe in crypto and remember, “not your key, not your crypto.”

The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.

A crypto research analyst, algorithmic trader who is passionate about cryptocurrency, finance, investing and data analytics.
In this blog, I will be mainly focusing on how to use python programming language to derive meaningful insights from datasets in order educate and develop various investing strategies for assets.

In addition, I will be uploading "how to" guides on various decentralized applications running on a number of blockchains and "Top 5" guides. Furthermore, research articles on blockchain projects will be a part of the content.

Responses From Readers

Clear

We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.

Show details