Building Smart Contracts for Staking and Farming
Staking is a type of incentive mechanism for users to gain extra tokens as a reward. As we discussed in the Overview of DeFi applications section in Chapter 1, Introduction to DeFi staking is a generic team that covers all mechanisms that can generate passive income, whereas yield farming is a specific type of staking whose staked tokens are liquidity pool (LP tokens). It encourages liquidity pool growth and stabilizes the price impact for DEX trading. For some DeFi projects, staking has reduced its scope, whose staked tokens are non-LP tokens. By leveraging staking and yield farming, a crypto project can encourage people to buy the token for staking or provide liquidity for it, which will help reduce the selling pressure of the token.
In this chapter, we will use the term farming to simplify the term yield farming.
Although staking and farming are two different features, they share the same principle: deposit a standardized token...