Skip to content

Commit

Permalink
fix: Fix sdk decimal issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Halibao-Lala committed Dec 20, 2024
1 parent 745c29c commit 5414b01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/canonical-bridge-sdk/src/core/utils/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ export function removeAfterDecimals(num: string | number, decimals = 8) {
return result;
}

export const formatNumber = (value: number, decimals = 18) => {
export const formatNumber = (
value: number,
decimals = 18,
useGrouping = true
) => {
const num = removeAfterDecimals(value, decimals);
return num.toLocaleString('fullwide', {
maximumFractionDigits: decimals,
useGrouping,
});
};

Expand Down
2 changes: 1 addition & 1 deletion packages/canonical-bridge-sdk/src/layerZero/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class LayerZero {
];
const nativeFee = fees[0];
const minAmount = parseUnits(
String(formatNumber(Number(formatUnits(amount, 18)), 8)),
String(formatNumber(Number(formatUnits(amount, 18)), 8, false)),
18
);
const cakeArgs = {
Expand Down

0 comments on commit 5414b01

Please sign in to comment.