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

Added unit test for USDC + rounding error (ERC20 tokens with less than 18 decimals) #198

Merged
merged 3 commits into from
May 25, 2023

Conversation

xtools-at
Copy link
Contributor

@xtools-at xtools-at commented Apr 3, 2023

Motivation

In #197 the rounding issue with partial fills was solved, with the limitation that the sale price is only allowed to have a certain amount of decimal places for the maths to safely check out. At the time of authoring that PR, it was still unclear how ERC20 tokens with less than 18 decimals are affected by the limitations laid out in #197.

Solution

This PR adds an additional unit test with a mocked USDC ERC20 token, to prove the eligibility of the solution as well as the further limitations.

Result

Prices for orders paid in ERC20 tokens with 6 decimals (like USDC) must not have more than two decimals, when used together with seaport-js' fees feature and partial fills (i.e. 1.23 per NFT is ok, 1.234 may break for certain fee-basisPoints values).
When not using fees, this limitation doesn't apply, i.e. you can use the full range of six decimals safely.

Copy link
Collaborator

@ryanio ryanio left a comment

Choose a reason for hiding this comment

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

nice, lgtm, thanks!

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (ecd0213) 93.13% compared to head (1699440) 93.13%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #198   +/-   ##
=======================================
  Coverage   93.13%   93.13%           
=======================================
  Files          16       16           
  Lines        3790     3790           
  Branches      334      334           
=======================================
  Hits         3530     3530           
  Misses        250      250           
  Partials       10       10           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ryanio ryanio merged commit da2852f into ProjectOpenSea:main May 25, 2023
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.

3 participants