Professional Documents
Culture Documents
Guide To Emergency Withdraw Your LP in A Yield Farm
Guide To Emergency Withdraw Your LP in A Yield Farm
Guide To Emergency Withdraw Your LP in A Yield Farm
Open in app
Imagine you’re yield farming on a degen yield farm with 60,000% APY and suddenly
the UI goes down, what do you do? Maybe you’d want to withdraw your funds, but you
can’t because the website is down!
https://medium.com/stakingbits/guide-to-emergency-withdraw-your-lp-in-a-yield-farm-7104873a7e71 1/7
11/24/21, 9:24 AM Guide to Emergency Withdraw your LP in a yield farm | by Stakingbits | Stakingbits | Nov, 2021 | Medium
In this guide, we’ll show you how you can emergency withdraw your funds from the
yield farm by interacting directly with the smart contracts.
Most yield farming projects have a typical MasterChef contract which acts as the brain
and control centre of a yield farming platform; it typically wields much power and has
the ability to pull all users’ funds from the platform.
In order to emergency withdraw, you’d need to first start with identifying this
important piece of smart contract which your funds are controlled by.
We can find the link to the MasterChef contract, and clicking on it brings us to the
smart contract on BSCscan.
https://medium.com/stakingbits/guide-to-emergency-withdraw-your-lp-in-a-yield-farm-7104873a7e71 2/7
11/24/21, 9:24 AM Guide to Emergency Withdraw your LP in a yield farm | by Stakingbits | Stakingbits | Nov, 2021 | Medium
Most other farms should have a similar MasterChef contract, regardless whether the
farm is on BSC, Polygon, Fantom or Avalanche.
In another example, let’s take a look at CronaSwap — a DEX on Cronos. The link to the
MasterChef on Cronos Explorer is located here.
Step 2: Locate the pool ID (pid) of the pool you were farming in
The second step is to find the pid of the liquidity pool you were farming in.
Each pool deployed by the MasterChef is associated with a pid, which is then used to
identify the pool and perform actions within the MasterChef contract such as
harvesting rewards.
To locate the pid, look for the transaction in which you’ve deposited your LP
tokens in the MasterChef contract on the block explorer.
Scroll down on the block explorer until you find Input Data.
This will decode the data and show you the pid of the pool that you’ve deposited in.
https://medium.com/stakingbits/guide-to-emergency-withdraw-your-lp-in-a-yield-farm-7104873a7e71 3/7
11/24/21, 9:24 AM Guide to Emergency Withdraw your LP in a yield farm | by Stakingbits | Stakingbits | Nov, 2021 | Medium
Click on Write Contract, then Connect to Web3 and authenticate with Metamask.
https://medium.com/stakingbits/guide-to-emergency-withdraw-your-lp-in-a-yield-farm-7104873a7e71 4/7
11/24/21, 9:24 AM Guide to Emergency Withdraw your LP in a yield farm | by Stakingbits | Stakingbits | Nov, 2021 | Medium
Enter the pid for the pool to exit, then click Write.
Note that if the funds have been already drained by an exploit or hacker, calling emergency
withdraw would not return any funds to your wallet.
https://medium.com/stakingbits/guide-to-emergency-withdraw-your-lp-in-a-yield-farm-7104873a7e71 5/7
11/24/21, 9:24 AM Guide to Emergency Withdraw your LP in a yield farm | by Stakingbits | Stakingbits | Nov, 2021 | Medium
This means users can monitor the timelock smart contract for suspicious activities, and
withdraw their funds if needed.
The timelock is usually set as the owner of the MasterChef contract. For example,
PancakeSwap’s MasterChef has the address
0xA1f482Dc58145Ba2210bC21878Ca34000E2e8fE4 set as the owner, which points to
the timelock smart contract.
By having the timelock in place, and verified publicly, every transaction that takes
place needs to be first queued before it can be executed.
You can view the timelock delay (in seconds) by reading the timelock contract and
scrolling to view the delay function. 21700 seconds represents a timelock of 6 hours.
https://medium.com/stakingbits/guide-to-emergency-withdraw-your-lp-in-a-yield-farm-7104873a7e71 6/7
11/24/21, 9:24 AM Guide to Emergency Withdraw your LP in a yield farm | by Stakingbits | Stakingbits | Nov, 2021 | Medium
Subscribe to our newsletter so that you don’t miss our latest updates!
The Wild Forest is the fastest growing DeFi newsletter with content summaries, guides, monthly
roundups and more. We help our 1000+ subscribers navigate DeFi's wild forest and you don't want to
miss. Take a look.
https://medium.com/stakingbits/guide-to-emergency-withdraw-your-lp-in-a-yield-farm-7104873a7e71 7/7