Skip to content

Commit

Permalink
Merge pull request #1207 from Itheum/claims-hotfix
Browse files Browse the repository at this point in the history
Claims formatting fix
  • Loading branch information
damienen committed Feb 12, 2024
2 parents 077ed2f + ff948c1 commit 3196bbc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libs/utils/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ const formatToHundreds = (number: number) => {
const formatToThousands = (number: number) => {
const thousands = Math.floor(number / 1000);
const remainder = Math.floor((number % 1000) * 100) / 100;
return `${thousands},${remainder !== 0 ? remainder : ""}`;
const paddedRemainder = remainder < 10 ? `00${remainder}` : remainder < 100 ? `0${remainder}` : remainder;
return `${thousands},${paddedRemainder}`;
};

const formatToMillions = (number: number) => {
const millions = Math.floor(number / 1000000);
const thousands = Math.floor((number % 1000000) / 1000);
const paddedThousands = thousands < 10 ? `00${thousands}` : thousands < 100 ? `0${thousands}` : thousands;
const remainder = Math.floor((number % 1000) * 100) / 100;
return `${millions},${thousands !== 0 ? `${thousands}` : ""},${remainder !== 0 ? remainder : ""}`;
const paddedRemainder = remainder < 10 ? `00${remainder}` : remainder < 100 ? `0${remainder}` : remainder;
return `${millions},${paddedThousands},${paddedRemainder}`;
};
//
const BIG_NUMBER_ROUNDING_MODE = BigNumber.ROUND_FLOOR;
Expand Down

0 comments on commit 3196bbc

Please sign in to comment.