0
0
Blockchain / Solidityprogramming~30 mins

Yield farming concepts in Blockchain / Solidity - Mini Project: Build & Apply

Choose your learning style9 modes available
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
Need a 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
Need a 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
Need a 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
Need a hint?

Use print(rewards) to show the rewards dictionary.