Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Yield Farming Concepts
📖 Scenario: You want to understand how yield farming works by simulating a simple yield farming scenario in Python. Yield farming means you deposit tokens into a pool and earn rewards based on your deposit and a reward rate.
🎯 Goal: Build a small program that calculates the rewards earned by different users based on their deposits and a fixed reward rate.
📋 What You'll Learn
Create a dictionary with user names and their deposited token amounts
Create a variable for the reward rate (percentage)
Calculate the rewards for each user using a dictionary comprehension
Print the rewards dictionary showing each user and their earned rewards
💡 Why This Matters
🌍 Real World
Yield farming is a popular way in blockchain to earn passive income by depositing tokens and earning rewards. This project simulates the basic math behind it.
💼 Career
Understanding yield farming concepts and how to manipulate data structures is useful for blockchain developers and analysts working with decentralized finance (DeFi) applications.
Progress0 / 4 steps
1
Create the deposit data
Create a dictionary called deposits with these exact entries: 'Alice': 1000, 'Bob': 1500, 'Charlie': 500
Blockchain / Solidity
Hint
Use curly braces to create a dictionary with keys as user names and values as their deposits.
2
Set the reward rate
Create a variable called reward_rate and set it to 0.05 (which means 5%)
Blockchain / Solidity
Hint
Just assign the number 0.05 to the variable reward_rate.
3
Calculate rewards using dictionary comprehension
Create a dictionary called rewards using dictionary comprehension that calculates each user's reward by multiplying their deposit by reward_rate. Use user and amount as the loop variables in for user, amount in deposits.items()
Blockchain / Solidity
Hint
Use the syntax: {key: value_expression for key, value in dictionary.items()} to create the rewards dictionary.
4
Print the rewards
Write a print statement to display the rewards dictionary
Blockchain / Solidity
Hint
Use print(rewards) to show the rewards dictionary.
Practice
(1/5)
1. What is the main purpose of yield farming in blockchain?
easy
A. To trade cryptocurrencies on exchanges
B. To earn rewards by staking cryptocurrency in pools
C. To mine new cryptocurrency coins
D. To create new blockchain networks
Solution
Step 1: Understand yield farming basics
Yield farming involves staking crypto assets to earn rewards.
Step 2: Compare options to yield farming
Mining, trading, and creating blockchains are different activities.
Final Answer:
To earn rewards by staking cryptocurrency in pools -> Option B
Quick Check:
Yield farming = earning rewards by staking [OK]
Hint: Yield farming means staking crypto to earn rewards [OK]
Common Mistakes:
Confusing yield farming with mining
Thinking yield farming is trading
Believing yield farming creates new blockchains
2. Which of the following is the correct way to describe a yield farming pool?
easy
A. A software to trade cryptocurrencies instantly
B. A wallet to store cryptocurrencies securely
C. A blockchain that creates new tokens automatically
D. A place where users stake crypto to earn rewards
Solution
Step 1: Define a yield farming pool
A pool is where users stake crypto to earn rewards.
Step 2: Eliminate unrelated options
Wallets store crypto, blockchains create tokens, and software trades crypto.
Final Answer:
A place where users stake crypto to earn rewards -> Option D
Quick Check:
Pool = staking place for rewards [OK]
Hint: Pools are for staking crypto to earn rewards [OK]
Common Mistakes:
Mixing pools with wallets
Thinking pools create tokens
Confusing pools with trading software
3. Consider this simplified code snippet for calculating yield farming rewards: