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

VAL-23 Implement rounding per 4626 #67

Merged
merged 1 commit into from
Oct 28, 2022
Merged

VAL-23 Implement rounding per 4626 #67

merged 1 commit into from
Oct 28, 2022

Conversation

ams9198
Copy link
Contributor

@ams9198 ams9198 commented Oct 27, 2022

Updates the rounding per 4626 to round UP in certain cases. Per 4626,

  • convertToAssets, convertToShares should both round DOWN
  • previewDeposit, and deposit should round DOWN (i.e. calculating how many Y shares to mint for X assets)
  • previewMint, and mint should round UP (i.e. calculating how many Y assets to transfer from lender to mint X shares)
  • previewWithdraw, and withdraw rounds UP (i.e. calculating how many shares required to withdraw assets)
  • previewRedeem, and redeem rounds DOWN (i.e. calculating how many assets to transfer TO lender for X shares)

Please sanity check that's correct: https://eips.ethereum.org/EIPS/eip-4626#security-considerations

Also simplified some of the PoolLib methods since they were duplicative at this point (consolidated to a single PoolLib.calculateConversion method).

@ams9198 ams9198 changed the title VAL-23 Implement rounding per 4626 and add tests for money inflows VAL-23 Implement rounding per 4626 Oct 28, 2022
Copy link
Contributor

@bricestacey bricestacey left a comment

Choose a reason for hiding this comment

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

Looks good -- confirmed with the EIP and your implementation.

The only part that was not explicit is withdraw and redeem. I believe the EIP doesn't mention how they should be rounded, but I assume it follows the preview methods.

@ams9198 ams9198 merged commit ef0d5a8 into circlefin:master Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants