In yield farming, users provide liquidity to a pool and earn rewards. Which of the following best describes how rewards are typically calculated?
Think about fairness in sharing rewards based on contribution size.
In yield farming, rewards are usually proportional to the liquidity a user provides compared to the total pool. This ensures users who contribute more get more rewards.
Given the following Python code that calculates a user's share percentage in a liquidity pool, what is the output?
total_liquidity = 1000 user_liquidity = 250 user_share = (user_liquidity / total_liquidity) * 100 print(f"User share: {user_share:.1f}%")
Divide user liquidity by total liquidity and multiply by 100 to get percentage.
The user provides 250 out of 1000 total liquidity, so the share is (250/1000)*100 = 25.0%.
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)?
def calculate_rewards(liquidity, reward_rate): return liquidity * reward_rate print(calculate_rewards(500, 0.05))
Multiply liquidity by reward rate to get rewards.
500 * 0.05 equals 25.0, which is the reward amount.
What error will this Python code produce when run?
rate = 0.1 rewards = {user: liquidity * rate for user, liquidity in [('Alice', 100), ('Bob', 200)]} print(rewards)
Check the order of variable definitions and usage.
The variable 'rate' is used inside the dictionary comprehension before it is defined, causing a NameError.
Which of the following is the most significant risk unique to yield farming compared to traditional savings?
Think about what can go wrong specifically in blockchain-based yield farming.
Yield farming involves smart contracts which can have bugs or be exploited, risking users' funds. This risk is unique compared to traditional savings.