Closed cawthorne closed 3 months ago
Latest commit: 53bd8a6996bebea12ca4d6cc8554464b3e28643e
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Closes #DF-20071
Description
Force rounding down for BigNumber conversion in set-token-index, to match EVM behaviour + add properly handle and add test case for 24 decimal tokens.
Changes
Use .toIntegerValue(BigNumber.ROUND_FLOOR), instead of .toFixed(0), as toFixed by default rounds up or down to the nearest integer, which is not representative of on-chain EVM behaviour when scaling. Also it is generally good practice to round down balances for security reasons.
Also use of BigNumber.toString(10) has been added to stop BigNumber.js using exponential notation when .toString() for larger (~ greater than 1e21) values.
Steps to Test
yarn test set-token-index