haveno-app/lib/utils/xmr_math.dart
2024-08-19 21:35:24 +01:00

14 lines
462 B
Dart

import 'package:fixnum/fixnum.dart';
Object? formatXmr(Int64? atomicUnits, {bool returnString = true}) {
if (atomicUnits == null) {
return returnString ? 'N/A' : null;
}
double value = atomicUnits.toInt() / 1e12;
return returnString ? value.toStringAsFixed(5) : value;
}
String formatFiat(double amount, String currencyCode) {
// This function formats the amount as a fiat currency string
return '$currencyCode ${amount.toStringAsFixed(2)}';
}