How To Get Into New Farms On PancakeSwap Before Anyone Else For Unfair Superprofits

x · ACryptoS
Oct 18, 2020 · 6 min read

The way new farms are currently added on PancakeSwap makes it unfairly profitable to those who are able to stake first. Getting in first means you get 100% of the rewards allocated to the farm until others can join. Yes, the devs can make it more fair. But instead of waiting on them, I will do my part by sharing the knowledge on how to to be the first into these new farms, getting in even before they are added to the PancakeSwap app by interacting directly with the smart contracts on-chain. More importantly, this will also bring to the reader the added benefit of a deeper understanding of defi smart contracts and how they work.

Image for post
Image for post

In this guide, we will use as an example the newest UNI-BNB farm which was added yesterday.

Step 1: Set up alerts on the Timelock contract

The PancakeSwap devs have created a Timelock so any governance changes to their contracts have to be broadcasted at least 6 hours before they can be executed. The Timelock contract is at 0xA1f482Dc58145Ba2210bC21878Ca34000E2e8fE4. You can use the watchlist feature on BscScan to send you an email whenever a transaction occurs on this contract. For reference, this is the queue transaction to add the UNI-BNB farm, and this is the execute transaction that was sent about 6.5 hours later. (Extra: try using BscScan to decode the input data of the transaction and see if you can find any useful information there) We will use this alert later in step 5.

Step 2: Follow PancakeSwap announcements

Following the official PancakeSwap channels will give you some advance notice on when they are launching new farms.

Image for post
Image for post

Step 3: Accumulate the coins you need

For this farm, we need to accumulate UNI and get it to our BSC wallet. Send your ERC-20 UNI to your Binance.com account or buy UNI on Binance.com, and withdraw UNI as BEP-20 to your BSC wallet. You should also prepare the equivalent amount in BNB to add to the pool.

Step 4: Add liquidity to the pool

Do this as you would normally add liquidity to any PancakeSwap pool. Because we want to do this before everyone else, you will not find UNI (the new coin of the new pool) in the list of coins to add as it would not have been updated in the PancakeSwap app yet. Instead, you will need to manually input the address of UNI here.

Image for post
Image for post

One way to find the address of the new coin is by looking at the transaction sending the UNI to your BSC wallet on BscScan under the “BEP-20 Token Txns” tab. For reference, this is UNI’s address: 0xbf5140a22578168fd562dccf235e5d43a02ce9b1.

Image for post
Image for post

Step 5: Approve PancakeSwap to spend your LP tokens

When the new farm is added to the PancakeSwap app, you can just click “Approve”. However, if you want to do this before everyone else can, you will need to interact directly with the smart contracts. First you will need to find the smart contract of the liquidity pool you just added to in Step 4.

Open the transaction where you added liquidity to the pool in step 4 on BscScan, find the row “Tokens Transferred”, clicking on any of the “Pancake LPs (Cake…” should bring you to the right smart contract. For reference, this is the UNI-BNB pool contract. (Extra: can you find the reference to this pool in the decoded inputs of the Timelock transactions from step 1?)

Image for post
Image for post

Next, navigate to “Contract” -> “Write Contract” -> “approve”. Under spender , input PancakeSwap’s MasterChef contract “0x73feaa1eE314F8c655E354234017bE2193C9E24E”, and under value input the max uint256 value “0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff”. Connect your web3 wallet and execute the transaction.

Image for post
Image for post

Next, go to “Read Contract” -> “balanceOf”, input your wallet’s address and click “Query”. Copy the uint256 response, which is “5259141385165989323” in the example below. This is the amount of LP tokens you have which you will need to use to stake in the farm in step 7.

Step 6: Wait for the farm to be added to PancakeSwap’s MasterChef contract

Go to PancakeSwap’s MasterChef contract page on BscScan and navigate to “Contract” -> “Read Contract”. “poolLength” shows the total number of pools which at this point in time is 26, and if you input “25” into “poolInfo”, it will return some info on the last added pool, which in this case is the UNI-BNB pool. (Note: the pool numbers start from “0”, so pool “0” is the first pool, and pool “25” is the 26th and last added pool) Notice how “lpToken” points at the UNI-BNB contract we were referring to in steps 4 and 5.

Image for post
Image for post

Now we have to wait for the new farm to be added. When this happens, you will receive an email alert from the watchlist you set up in step 1, “poolLength” will increase, and if you input the pool id of “poolLength”-1 in “poolInfo”, it will return information about the newly added farm. “lpToken” should point at the liquidity pool you added to in steps 4–5.

Once this happens, we are ready to stake our LP tokens, and the faster we do this before everyone else, the bigger our profits will be!

Step 7: Stake your LP tokens

When the new farm is up on the PancakeSwap app, you can just click “Stake”. However, we want to do this before everyone else, and will interact directly with the smart contracts. From Step 6, navigate to “Write Contract” -> “deposit”. Input the pool id of the new pool from step 6, and the amount of the LP tokens from step 5. Execute the transaction and you are done!

Image for post
Image for post

Bonus: go to “Read Contract” -> “userInfo”, input the new pool id and your wallet address, hit query and you should see the amount of Cake you are earning increasing.

Image for post
Image for post

Once the farm has been added to the PancakeSwap app itself, you should see your stake there as well.

Unfair Advantage?

We built a bot for our clients that automates the process above, allowing us to get in new pools almost immediately after they are added on-chain to maximise profit. We even shared a simplified version for anyone to use (which doesn’t have this feature). But you really shouldn’t trust anyone with your private keys.

Note to PancakeSwap devs: you can make the farms fairer by adding them with a reward factor of 0, allowing users some time to stake first, before increasing the reward factor to its intended value. But, I think it’s fair to be a bit unfair in favour of those a bit more in the know 😉 Incentivising users to learn more about smart contracts and how to interact with them will benefit the whole community.

x / ACryptoS

ACryptoS

Advanced Crypto Strategies

x · ACryptoS

Written by

https://www.acryptos.com/ · https://twitter.com/acryptosx ·

ACryptoS

ACryptoS

ACryptoS offers 2 products on Binance Smart Chain, yield optimizer ACryptoS Vaults and stablecoin DEX ACryptoS StableSwap. Our tokenomics and fees are designed to encourage longer term staking, and reward long term holders of our ACS and ACSI native tokens.

x · ACryptoS

Written by

https://www.acryptos.com/ · https://twitter.com/acryptosx ·

ACryptoS

ACryptoS

ACryptoS offers 2 products on Binance Smart Chain, yield optimizer ACryptoS Vaults and stablecoin DEX ACryptoS StableSwap. Our tokenomics and fees are designed to encourage longer term staking, and reward long term holders of our ACS and ACSI native tokens.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store