Submitted by Abdessamed, also found by 0xAlix2, carrotsmuggler, Lambda, and Tigerfrake
/contracts/farm-manager/src/helpers.rs#L128-L175
In the farming mechanism, users can claim rewards from active farms based on their locked LP token share. The rewards distribution must adhere to the following invariant:
However, the current implementation allows the creation of farms with a start_epoch in the past. This breaks the invariant, as users who have already claimed rewards for past epochs will miss out on additional rewards assigned retroactively to those epochs. This issue arises because the validate_farm_epochs function does not enforce that the farms start epoch must be in the future relative to the current epoch:
The function lacks a check to ensure that start_epoch is not earlier than current_epoch + 1, allowing farms to be created retroactively. This leads to unfair rewards distribution.
The following test case demonstrates that a farm can be created in such a way that it starts in a past epoch, copy and paste the following test to /contracts/farm-manager/tests/integration.rs:
The transaction passes without reverting, creating a farm that starts in a past epoch.
Ensure the start_epoch is always in the future relative to the current_epoch:
jvr0x (MANTRA) confirmed
