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

CL001 - Using the predicted value as Minimum amount of reward to receive may result in user losses #170

Closed
sherlock-admin2 opened this issue Nov 29, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Nov 29, 2023

CL001

medium

Using the predicted value as Minimum amount of reward to receive may result in user losses

Summary

_withdrawRewards() function in SdtRewardReceiver.sol calls _poolCvgsdt.exchage() converts all SDT into CvgSDT.
The poolCvgsdt.exchage() function uses the return value of the get_dy() method as min_dy(Minimum amount of 'reward' to receive) may result in user losses.

Vulnerability Detail

https://etherscan.io/address/0xCA0253A98D16e9C1e3614caFDA19318EE69772D0#code#L769
InpoolCvgsdt.exchange()function compares the calculated 'rewardAmount' with the minimum rewardAmount(min_dy), forcing the actual 'rewardAmount' of received to be greater than or equal to min_dy.

However, the poolCvgsdt.exchage() function uses the return value of the get_dy() method as min_dy,
Curve pool.get_dy() method returns a predicted value that may be less than the user expects(actual rewardAmount)
https://etherscan.io/address/0xCA0253A98D16e9C1e3614caFDA19318EE69772D0#code#L721

As in the code comments “Only swap if the returned amount in CvgSdt is gretear than the amount rewarded in SDT”, This is to avoid losses to the user
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Staking/StakeDAO/SdtRewardReceiver.sol#L234

Impact

Leads to loss of rewards for users

Code Snippet

https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Staking/StakeDAO/SdtRewardReceiver.sol#L234

Tool used

Manual Review

Recommendation

Use actual 'rewardAmount' as min_dy

ICrvPoolPlain _poolCvgSDT = poolCvgSDT;
/// @dev Only swap if the returned amount in CvgSdt is gretear than the amount rewarded in SDT
- _poolCvgSDT.exchange(0, 1, rewardAmount, _poolCvgSDT.get_dy(0, 1, rewardAmount), receiver);

+ _poolCvgSDT.exchange(0, 1, rewardAmount, rewardAmount, receiver);

Duplicate of #180

@github-actions github-actions bot closed this as completed Dec 2, 2023
@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Dec 2, 2023
@sherlock-admin2 sherlock-admin2 changed the title Precise Snowy Eagle - Using the predicted value as Minimum amount of reward to receive may result in user losses CL001 - Using the predicted value as Minimum amount of reward to receive may result in user losses Dec 24, 2023
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Dec 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant