Adjusted precompiles docs to use 6 decimal places instead of 18#294
Adjusted precompiles docs to use 6 decimal places instead of 18#294codebycarson wants to merge 2 commits intomainfrom
Conversation
|
There was a problem hiding this comment.
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.
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.
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.
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.