Open hats-bug-reporter[bot] opened 9 months ago
Thank you for the submission.
The exit of a token from one farming does not mean the exit from all farming
delete farms[tokenId][incentiveId];
Clears the Farm structure by tokenId
and incentiveId
, delete
in this case is applied to the structure without attachments, which will lead to its clearing
You can also see that the cleaning is checked: https://github.com/hats-finance/Fenix-Finance-0x83dbe5aa378f3ce160ed084daf85f621289fb92f/blob/08d3a808b6c252d43fbbba869959c8231d0e5934/src/farming/test/unit/EternalFarms.spec.ts#L1661
Accordingly, as the structure is being cleaned, a second enter will be possible
Github username: -- Twitter username: -- Submission hash (on-chain): 0xde3519aab90d6649df40cd508d7a4d962f2a19076db56045f006771ed0df1282 Severity: medium
Description:
Description
AlgebraEternalFarming.exitFarming
function is meant to exitFarmings for Algebra LP token, it dirst updates the position and distributes its entitled rewards, then it deletes the farm :but
farms
is a nested mapping, so deleting it viadelete
will not remove the nested mapping inside it, andgetFarms
for this deleted farm will always return a result :This will prevent the same token with incentive from entering farm again as the liquidity of the farm will not be set to zero upon exiiting
Code Snippet
AlgebraEternalFarming.exitFarming function
Tool used
Manual Review
Recommendation
reset the
farms
mapping related to the deleted farm.