32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Withdrawal network fee helpers (USDT deducted from user ledger).
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.USDT_DECIMALS = void 0;
|
|
exports.getWithdrawalNetworkFeeRaw = getWithdrawalNetworkFeeRaw;
|
|
exports.formatUsdtRawHuman = formatUsdtRawHuman;
|
|
/** USDT uses 6 decimal places on TRON TRC20. */
|
|
exports.USDT_DECIMALS = 6;
|
|
/**
|
|
* Returns the configured network fee in smallest USDT units.
|
|
*/
|
|
function getWithdrawalNetworkFeeRaw(settings) {
|
|
const micro = settings.withdrawal_network_fee_usdt_micro;
|
|
if (!Number.isFinite(micro) || micro < 0)
|
|
return 0n;
|
|
return BigInt(Math.floor(micro));
|
|
}
|
|
/**
|
|
* Formats a raw USDT amount for display (trims trailing zeros).
|
|
*/
|
|
function formatUsdtRawHuman(raw, decimals = exports.USDT_DECIMALS) {
|
|
if (decimals <= 0)
|
|
return raw.toString();
|
|
const divisor = 10n ** BigInt(decimals);
|
|
const intPart = raw / divisor;
|
|
const frac = raw % divisor;
|
|
const fracStr = frac.toString().padStart(decimals, '0').replace(/0+$/, '');
|
|
return fracStr ? `${intPart}.${fracStr}` : intPart.toString();
|
|
}
|
|
//# sourceMappingURL=withdrawalFee.js.map
|