0
0
Blockchain / Solidityprogramming~20 mins

Yield farming concepts in Blockchain / Solidity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Yield Farming Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Yield Farming Rewards

In yield farming, users provide liquidity to a pool and earn rewards. Which of the following best describes how rewards are typically calculated?

ARewards are randomly assigned to users each day.
BRewards are proportional to the amount of liquidity a user provides relative to the total pool.
CRewards depend only on the time a user has held tokens, not the amount provided.
DRewards are fixed and distributed equally regardless of the amount provided.
Attempts:
2 left
💡 Hint

Think about fairness in sharing rewards based on contribution size.

Predict Output
intermediate
1:30remaining
Calculate User Share in a Liquidity Pool

Given the following Python code that calculates a user's share percentage in a liquidity pool, what is the output?

Blockchain / Solidity
total_liquidity = 1000
user_liquidity = 250
user_share = (user_liquidity / total_liquidity) * 100
print(f"User share: {user_share:.1f}%")
AUser share: 250.0%
BUser share: 2.5%
CUser share: 0.25%
DUser share: 25.0%
Attempts:
2 left
💡 Hint

Divide user liquidity by total liquidity and multiply by 100 to get percentage.

Predict Output
advanced
1:30remaining
Yield Farming Reward Calculation with Variable Rates

Consider this Python function that calculates rewards based on liquidity and a variable reward rate. What is the output when calling calculate_rewards(500, 0.05)?

Blockchain / Solidity
def calculate_rewards(liquidity, reward_rate):
    return liquidity * reward_rate

print(calculate_rewards(500, 0.05))
A500.05
B10.0
C25.0
D0.025
Attempts:
2 left
💡 Hint

Multiply liquidity by reward rate to get rewards.

🔧 Debug
advanced
2:00remaining
Identify the Error in Reward Distribution Code

What error will this Python code produce when run?

Blockchain / Solidity
rate = 0.1
rewards = {user: liquidity * rate for user, liquidity in [('Alice', 100), ('Bob', 200)]}
print(rewards)
A{'Alice': 10.0, 'Bob': 20.0}
BTypeError due to wrong multiplication
CNameError because 'rate' is used before assignment
DSyntaxError in dictionary comprehension
Attempts:
2 left
💡 Hint

Check the order of variable definitions and usage.

🧠 Conceptual
expert
2:30remaining
Risks in Yield Farming Strategies

Which of the following is the most significant risk unique to yield farming compared to traditional savings?

ASmart contract vulnerabilities causing loss of funds
BInflation risk reducing the value of rewards
CInterest rate changes by central banks
DBank insolvency leading to loss of deposits
Attempts:
2 left
💡 Hint

Think about what can go wrong specifically in blockchain-based yield farming.