There’s been lots of talk in the yield farming space about how migrators are “essential” or “useful” in some way.
But after reviewing over 1,000 farms with and without migrator codes…
We’ve come to the conclusion that migrator codes are NOT essential and only add unnecessary risk.
In fact, if we take a look at last month’s yield farms that had a migrator code…
100% of the farms resulted in a rug and stolen funds.
So why exactly is the migrator code so dangerous? And why do some farms insist on keeping it?
Let’s explore what a migrator code really is and where it came from, starting with…
What is a Migrator Code and Why is It Dangerous?
A migrator code is a function in a yield farm’s MasterChef contract that allows the owner of the contract (usually a timelock or developer’s address) to move all funds from that contract to any other address. This can result in the total loss of funds if the owner of the contract moves the funds into his or her own private wallet.
Binance even explicitly states that a migrator code can be used to steal funds in malicious contracts:
Where Did the Migrator Code Come From?
Some people might think the migrator code originated from PancakeSwap, however it all started earlier on the Ethereum Network when SushiSwap migrated $830 million worth of crypto assets from Uniswap to its own community-owned automated market maker (AMM).
PancakeSwap also added on the migrator code, as you can see on line 179 of their MasterChef contract:
Why Do So Many Farms Have the Migrator Code?
Take one look into yield farms and you’ll see that many farms look the same.
That’s because they forked from the granddaddy of them all, PancakeSwap.
And since many other farms forked PancakeSwap (read: copied their code), they also included PancakeSwap’s migrator code in their MasterChef contract as well.
So if the migrator code is so “common,” this brings us to the next question:
Why Remove The Migrator Code?
You might remember the first Medium post from Goose Finance titled ‘First to remove Rugpull Migrator Code.’
After PopcornSwap drained over $2 million, Goose Finance claimed to be the first fork to remove the migrator code, stating that “evil devs like PopcornSwap used this ‘directly forked from Pancake’ excuse to dodge due diligence checks.”
After that, it became the “gold standard” to remove the migrator code.
After all, why would a user willingly stake their funds in a farm if it had potential to rug?
And why would a yield farm even include the migrator code, when it could simply be removed by deleting it from the smart contract?
Now onto the golden question…
Is There ANY Reason to Have a Migrator Code At All?
According to this Reddit post, a PancakeSwap developer said the following about their migrator code:
- Chef Chungus, [19.02.21 01:23] It allows a protocol to upgrade in the future
- Chef Chungus, [19.02.21 01:23] If a protocol wants to innovate and build, then it requires the migrator code
- Chef Chungus, [19.02.21 01:19] We plan to upgrade our contracts, therefore it’s necessary
But is it REALLY necessary?
You see, when PancakeSwap upgraded their contracts from V1 to V2, the migrator code was NOT used.
In their Medium post, the PancakeSwap team explained why they did not use the migrator function:
So in the end, PancakeSwap didn’t even need the migrator code function.
The safer alternative to a migrator function is to simply ask users to unstake their funds and restake them in the new contract.
This is exactly what PancakeSwap did, and the best solution to provide safety to users while also allowing farms to implement upgrades in their contract.
So in the end, migrators are NOT worth the risk. They are used far more maliciously than they ever do good—this is the reason we rate farms that have a migrator code as HIGH RISK.
To learn more about our risk rating system, check out our article or watch our video below:
What About a Timelock?
Unfortunately, once a contract is set in stone, a timelock does NOT prevent the migrator function from being called on.
It only means there’s a set amount of time before the migrator code can be “activated.”
In other words, the PancakeSwap MasterChef could steal all funds within 6 hours if they wanted to.
…And if nobody’s checking the contract interactions, then you may have even less time depending on when someone sees the timelock activated.
So don’t rely on a timelock to save your funds… They could literally disappear overnight while you’re sleeping.
The Not-So-Great Migration
In summary, we highly recommend to stay away from yield farms with a migrator code, even if they have flashy graphics.
If you want to be sure, feel free to ask our amazing community via our Telegram group if you have any questions about yield farming.
Or, head on over to our comprehensive list of farms to see if your farm is on our list.
And as always,
Stay safe out in the DeFi world!