As recipes are to kitchens, smart contracts are to DeFi. And in the DeFi kitchen, the most celebrated of smart contracts is the appropriately named MasterChef. This code is one of the most forked smart contracts in the blockchain ecosystem and forms the core logic of DEXes far and wide. Like you can’t step foot into a professional kitchen without knowing how to fry an egg, you can’t build a DEX without knowing about MasterChef.
Why is MasterChef so prevalent? This contract allows users to lock assets into a pool and earn a token reward in exchange. This is one of the fundamental utilities of a DEX. Without it, users would have little incentive to provide liquidity. To earn LP rewards, users must provide liquidity; the MasterChef contract is what slices, sieves, sprinkles, and sautés your liquidity into yield. SushiSwap served up this excellent code base and profited incredibly from this innovation.
More than a fork
Sushiswap is one of the first decentralized exchanges and was built on Ethereum. The platform forked its code from the original DEX, the renowned UniSwap. Building MasterChef on top of the UniSwap codebase enabled new features for users, such as liquidity mining. On UniSwap, users provide LP tokens into a pool and earn fees from other users\’ swaps that utilize those tokens. SushiSwap’s MasterChef contract allows for an additional incentive; users could earn $SUSHI reward tokens alongside the swap fees.
SushiSwap was a game-changer.
Teams could easily copy the codebase, utilizing the functions that are permitted. This allowed for a simplistic approach to farming for new protocols with a single contract underpinning everything regarding liquidity pool emissions. Here is a simple breakdown:
- The contract tracks the farm on the platform allowing teams to easily adjust the weighting of token emissions
- When a user enters a pool the contract issues LP tokens in proportion to the amount of liquidity provided
- Token rewards are then allocated depending on the emission schedule and users share of the pool
The MasterChef contract was a pivotal piece of technology that changed the DeFi landscape as we know it, it crops up in more DEX’s code than any others, but does it have any faults? Of course! Code always carries risks.
Market Risk – Mercenary capital
This is one of the number 1 problems that teams within DeFi face. Mercenary capital is when investors primarily take advantage of short-term incentive programs. When farms initially launch on a DEX, the APR is ludicrously high, but this rate drops over time as users enter the farm and dilute the overall share of LP tokens. This leads to certain investors dumping these initial reward tokens and deploying capital elsewhere.
This Nansen article is over a year old, but it analyses how long users stayed within a farm deployed with the MasterChef contract:
The article states that 42% of yield farmers enter a farm on the day it launches and exit within 24 hours; by the third day, 70% of users would have withdrawn from the contract! This affirms that many liquidity providers are short-term investors, profiting from the initial high rewards and then leaving once these subside.
Code Risk – Migrate function
Initially, the code contained a migration function that allowed the contract owner to send all the base LP tokens to an arbitrary address. You know the term “Rug Pull\” – this function enables it. Sound scary? Don’t worry; most teams will delete this function immediately, but it’s always worth checking that a new DEX has removed this function before providing liquidity.
Code/Economic Risk – Emission rate change
The contract owner can change the token\’s emission rate without any limits. Why is this a potential problem? Tokens price is based on supply and demand, and a rapid increase in token emissions rate leads to the token\’s devaluation if demand doesn’t keep up. See inflation. Additionally, purely incentivizing pools with rewards tokens is not sustainable; tokens can not emit forever….
DeFi is constantly evolving; gone are the simple days of simply staking and earning emission tokens. Let’s break down how some of the technologies that have improved liquidity mining for both users and developers:
- Vaults – Many protocols have incorporated Vaults that implement strategies to earn users additional rewards for staking their LP tokens. These strategies incorporate the pool\’s funds into borrowing and lending markets to further improve the yield of reward tokens. Instead of increasing the emissions, protocols can utilize strategies, earning other tokens and then swapping these back for their native token.
- Balancer v2 – Balancer V2 allows for a unique approach to pool design by incorporating pools that can hold up to 8 tokens with unequal weights. The contract differs from MasterChef by utilizing a concept known as the “protocol Vault.” Instead of separate contracts managing each specific pool and asset within, Balancer technology incorporates a single vault that holds and manages ALL the assets across ALL the pools. This allows developers to directly plug into Balancers existing liquidity instead of needing to build their own DEX.
- veCRV Mechanic – Curve offers users additional ways to earn extra rewards from liquidity mining via its veCRV mechanic. The $CRV token is not only used to incentivize liquidity on the platform; it can also be locked up as veCRV to earn increased rewards on certain pools. Users can earn a boost of up to 2.5x the standard incentivized rewards. Locking these tokens and providing a boost on yield offers an alternative approach for users who chase these short-term gains.
The MasterChef contract revolutionized liquidity mining and changed the DeFi game forever. However, any innovation brings with it a new host of problems. The primary downside of this contract has been the creation of mercenary capital and unsustainable emissions. Teams have built on this technology, improving the shortfalls of certain aspects of the contract\’s liquidity provision by providing additional yield and utilizing other strategies. What’s next? Just like the culinary world, DeFi does not stand still; just like the culinary world, there are always new cooks stepping into the kitchen aiming to create the next MasterChef….