Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 807ae7a

Browse files
committed
remove unnecessary math
1 parent bd426ed commit 807ae7a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

token/js/src/actions/amountToUiAmount.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,10 @@ export function amountToUiAmountWithoutSimulation(
116116
const decimalFactor = Math.pow(10, decimals);
117117

118118
// Convert to UI amount by:
119-
// 1. Dividing by decimal factor to get decimal places
120-
// 2. Multiplying back up to avoid floating point errors
121-
// 3. Truncating to remove any remaining decimals
122-
// 4. Dividing back down to get final UI amount
123-
// 5. Converting to string
124-
return (Math.trunc((scaledAmount / decimalFactor) * decimalFactor) / decimalFactor).toString();
119+
// 1. Truncating to remove any remaining decimals
120+
// 2. Dividing by decimal factor to get final UI amount
121+
// 3. Converting to string
122+
return (Math.trunc(scaledAmount) / decimalFactor).toString();
125123
}
126124

127125
/**

0 commit comments

Comments
 (0)