This repository has been archived by the owner on Nov 24, 2024. It is now read-only.
d17vv - Reward Distribution Skewed by Initial Deposit of 1 wei #82
Labels
Excluded
Excluded by the judge without consulting the protocol or the senior
Non-Reward
This issue will not receive a payout
d17vv
medium
Reward Distribution Skewed by Initial Deposit of 1 wei
Summary
The current reward distribution mechanism in the
SophonFarming
contract can be exploited by a user who makes an initial minimal deposit and receives the full reward for that block. Subsequent larger deposits in the next block will receive fewer rewards relative to their deposit size, which can lead to an unfair distribution of rewards.Vulnerability Detail
In the
SophonFarming
contract, rewards are distributed based on the proportion of a user’s deposit to the total deposits in the pool. If a user, say Alice, is the first to deposit a minimal amount (e.g.,1 wei
) in a new block, she will receive the entire reward for that block. If another user, Bob, deposits a significant amount (e.g.,10 ETH
) in the next block, Bob's rewards will be proportional to the total pool size including Alice's minimal deposit. This creates a situation where Alice, with a minimal deposit, receives a disproportionately large reward compared to her contribution. HerpendingPoints
will even be slightly more than Bob's (demonstrated below).The average block time on Ethereum is
12 seconds
, so it is extremely likely that if Alice monitors the pool she may be the first one to deposit in the initial block and actually get the whole reward.Impact
Medium. This issue can cause a loss of funds for subsequent depositors like Bob, who will receive fewer rewards than expected. The loss is constrained by the need for Alice to continually monitor and deposit in the pool. While the core functionality of the contract remains intact, the fairness and expected distribution of rewards are compromised, leading to potential loss of confidence and participation in the pool.
Code Snippet
https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L574-L624
Paste this function in
SophonFarming.t.sol
:Tool used
Manual Review
Recommendation
Make a large initial deposit to set a fair baseline for the pool.
Implement a minimum deposit requirement to qualify for rewards.
The text was updated successfully, but these errors were encountered: