17 lines
412 B
TypeScript
17 lines
412 B
TypeScript
import Big from 'big.js';
|
|
|
|
export function formatAmount(value: string): string {
|
|
return new Big(value).toFixed(2);
|
|
}
|
|
|
|
export function formatQuantity(value: string, assetType: string): string {
|
|
switch (assetType) {
|
|
case 'STOCK':
|
|
return new Big(value).round(0).toString();
|
|
case 'CRYPTO':
|
|
return new Big(value).round(8).toString();
|
|
default:
|
|
return new Big(value).toFixed(2);
|
|
}
|
|
}
|