Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You should use safe casts here #279

Closed
CloudEllie opened this issue Apr 29, 2022 · 1 comment
Closed

You should use safe casts here #279

CloudEllie opened this issue Apr 29, 2022 · 1 comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists

Comments

@CloudEllie
Copy link
Contributor

Judge @GalloDaSballo has assessed the 6th item in QA Report #254 as Medium risk. The relevant finding follows:

You should use safe casts here:

  deposits[_pid][msg.sender].amount += uint192(_amount);
  deposits[_pid][msg.sender].amount -= uint192(_amount);
  amount : uint192(_amount)

Otherwise, if token amounts are exceeding these limits (e.g. rebasing tokens) the accounted and transferred amounts will differ. For instance, in function deposit it will add less to the user's balance but charge the full amount:

  deposits[_pid][msg.sender].amount += uint192(_amount);
  ...
  lpToken.safeTransferFrom(msg.sender, address(this), _amount);
@CloudEllie CloudEllie added bug Something isn't working duplicate This issue or pull request already exists 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Apr 29, 2022
@CloudEllie
Copy link
Contributor Author

Duplicate of #194

@CloudEllie CloudEllie marked this as a duplicate of #194 Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

1 participant