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

Evaluating N_BYTES value of the circuit #13

Open
kiseln opened this issue Feb 28, 2024 · 0 comments
Open

Evaluating N_BYTES value of the circuit #13

kiseln opened this issue Feb 28, 2024 · 0 comments

Comments

@kiseln
Copy link
Collaborator

kiseln commented Feb 28, 2024

Summary
Currently deployed verifier has a range check of 8 bytes. Let's evaluate whether this is sufficient to represent tokens with very large supply.

Additional context

Max 8-byte number is 18,446,744,073,709,551,615 or roughly 18e18. This number needs to represent not only the integer part of the balance but also the decimal part. While ERC20 tokens tend to have 18 decimals, on most exhanges like Binance, balances are limited to 8 decimals. Therefore an 8-byte range check can work if balances do not exceed 18e10 tokens.

This value will be enough for most of the crypto assets. However, let's have a look at tokens with huge supply and small nominal worth like SHIB and PEPE. Looking at the holder distribution of SHIB we can see that the top exchanges hold amounts that exceed 1e13. However, if we look at how exchanges handle these type of tokens, they tend to have less decimals than other assets. Both SHIB and PEPE have only 2 decimals on Binance. With 2 decimals we need to be able to support 1e15 values which is within the bounds of our range check.

Additionally, if some token's balances reach the boundary of 18e18, it can be acceptable to cut a few decimals off to store balances in MST. Precision loss will not be significant.

Conclusion
N_BYTES of 8 looks to be enough to support all popular tokens with necessary level of precison.

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

No branches or pull requests

1 participant