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

fix: remedy rounding issue in _deposit4626() by adding remainder to _deposit() call #657

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

TamaraRingas
Copy link
Contributor

uint256 msgValue = msg.value / arrayLength; rounds down so the last bit of msg.value is not used.

  • Derive valuePerItem
  • Get remainder from above
  • Pass the sum of these values in the call to deposit()

@TamaraRingas TamaraRingas self-assigned this Nov 22, 2024
Copy link

linear bot commented Nov 22, 2024

@0xTimepunk 0xTimepunk merged commit 1abc86d into v1.5 Nov 25, 2024
4 of 5 checks passed
{
uint256 valuePerItem = (msg.value - (msg.value % arrayLength)) / arrayLength;
uint256 remainingValue = msg.value % arrayLength;
valueToDeposit = valuePerItem + remainingValue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the remainingValue should only be used once - for one of the vaults (or discounted in another way, or neglected)

this calculation: uint256 valuePerItem = msg.value / arrayLength can stay as it was because it rounds down anyway

Perhaps do the calculation of the valueToDeposit in the calling function deposit4626() and add the remainingValue only for the last (or first) item in the loop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants