-
Notifications
You must be signed in to change notification settings - Fork 49
Adjusted precompiles docs to use 6 decimal places instead of 18 #294
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
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Updates the staking precompile documentation to use 6 decimal places instead of 18, aligning with Cosmos standards rather than Ethereum standards for SEI token amounts.
- Replaced
parseEther()calls with raw numeric values using 6 decimal places - Updated import statements to remove unused
parseEtherfunction - Added clarifying comments indicating amounts use 6 decimals
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #294 +/- ##
=======================================
Coverage 79.29% 79.29%
=======================================
Files 82 82
Lines 1280 1280
Branches 184 184
=======================================
Hits 1015 1015
Misses 259 259
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| const success = await stakingContract.delegate( | ||
| "seivaloper1...", | ||
| { value: parseEther("100") } // Delegate 100 SEI | ||
| { value: 100000000 } // Delegate 100 SEI (6 decimals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While using delegate, specifically this one function uses 18 decimals inputs truncated to 6 decimals. Basically, you do something like:
10.123456789 -> 10.123456 -> parseEther(10.123456)
Best practice would be to always have amount.toFixed(6) -> parseEther(fixedAmount)
We need to change from having 6 decimals in delegate function to 18 decimals which is truncated to 6 decimals
| functionName: 'delegate', | ||
| args: [validatorAddress], | ||
| value: parseEther(amount) | ||
| value: amount // (6 decimals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
18 decimals truncated to 6 decimals
| const stakingWithSigner = stakingContract.connect(signer); | ||
|
|
||
| const tx = await stakingWithSigner.delegate(validatorAddress, { | ||
| value: ethers.parseEther(amount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseEther was correct as its delegate function but have a amount.toFixed(6)
The current docs for precompiles use the ethereum standard for decimal places (18) where the Sei precompiles expect the Cosmos standard (6 decimals). This PR adjusts the examples in the docs to let developers know about this difference.