Implementing a Frontend for Staking and Farming
As discussed in Chapter 9, Building Smart Contracts for Staking and Farming staking and farming are two DeFi features that incentivize users to hold cryptos and generate passive income. Although the two features can share the same set of smart contracts, farming (or yield farming) is a special case of staking that is for liquidity pool tokens (LP tokens). We have learned the principles and how to implement smart contracts for staking and farming.
In this chapter, we will complete the two features by implementing the frontend. First, we will implement the features for staking; the feature will only support common ERC20 tokens (non-LP tokens) as the staked tokens and reward tokens. Then, we will reuse the majority of the frontend code for farming (for a farming pool, the staked token is an LP token, and the reward token is a non-LP token). We will also address the main differences between the two features in the frontend code.
By...