Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

0xHelium - getClaimableCyclesAndAmounts() getter function will return wrong ClaimableCyclesAndAmounts[] because of rounding issues #53

Closed
sherlock-admin opened this issue Nov 29, 2023 · 1 comment
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Nov 29, 2023

0xHelium

high

getClaimableCyclesAndAmounts() getter function will return wrong ClaimableCyclesAndAmounts[] because of rounding issues

Summary

getClaimableCyclesAndAmounts() function is used to get an array of token and reward associated to the Staking position sorted by cycleId. However this function will return wrong values in certain cases causing a difference between real rewards and what is actually returned.

Vulnerability Detail

getClaimableCyclesAndAmounts() function will cause a loss of precision when calculating the cvgAmount. This code is where the issue happens.

For example:

  • amountStaked = 157
  • _cycleInfo[lastClaimedSdt].cvgRewardsAmount= 100
  • totalStaked= 1000
  • cvgAmount will be (157*100)/1000 // it will return 15 instead of 15.7 because of solidity truncation

Impact

Function will return a value different than the real value.

Code Snippet

https://github.com/sherlock-audit/2023-11-convergence/blob/main/sherlock-cvg/contracts/Staking/StakeDAO/SdtStakingPositionService.sol#L1027

Tool used

Manual Review,
VsCode

Recommendation

Use a multiplier for making operations that can lead to rounding down issues

@nevillehuang
Copy link
Collaborator

Based on impact and example provided, hard to assign all of the mentioned instances and its duplicates anything other than Low severity/Invalid given the extremely small loss of precision based on examples provided

@sherlock-admin sherlock-admin changed the title Perfect Coffee Sawfish - getClaimableCyclesAndAmounts() getter function will return wrong ClaimableCyclesAndAmounts[] because of rounding issues 0xHelium - getClaimableCyclesAndAmounts() getter function will return wrong ClaimableCyclesAndAmounts[] because of rounding issues Dec 24, 2023
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Dec 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

2 participants