73 lines
3.2 KiB
JavaScript
73 lines
3.2 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const node_test_1 = require("node:test");
|
|
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
const hotLiquidityService_1 = require("../services/hotLiquidityService");
|
|
(0, node_test_1.describe)('evaluateHotLiquidity', () => {
|
|
(0, node_test_1.test)('TRON: allows when USDT + TRX sufficient (cross-network, no inventory)', () => {
|
|
const v = (0, hotLiquidityService_1.evaluateHotLiquidity)({
|
|
network: 'TRON',
|
|
usdtBalanceRaw: 1000000000n, // 1000 USDT
|
|
nativeBalanceRaw: hotLiquidityService_1.MIN_TRX_SUN_FOR_WITHDRAWAL,
|
|
ledgerAmountRaw: 1000000000n,
|
|
});
|
|
strict_1.default.equal(v.ok, true);
|
|
});
|
|
(0, node_test_1.test)('TRON: rejects when hot USDT below payout', () => {
|
|
const v = (0, hotLiquidityService_1.evaluateHotLiquidity)({
|
|
network: 'TRON',
|
|
usdtBalanceRaw: 999999999n,
|
|
nativeBalanceRaw: hotLiquidityService_1.MIN_TRX_SUN_FOR_WITHDRAWAL,
|
|
ledgerAmountRaw: 1000000000n,
|
|
});
|
|
strict_1.default.equal(v.ok, false);
|
|
if (!v.ok)
|
|
strict_1.default.equal(v.reason, 'usdt');
|
|
});
|
|
(0, node_test_1.test)('TRON: rejects when TRX below gas floor', () => {
|
|
const v = (0, hotLiquidityService_1.evaluateHotLiquidity)({
|
|
network: 'TRON',
|
|
usdtBalanceRaw: 1000000000n,
|
|
nativeBalanceRaw: hotLiquidityService_1.MIN_TRX_SUN_FOR_WITHDRAWAL - 1n,
|
|
ledgerAmountRaw: 1n,
|
|
});
|
|
strict_1.default.equal(v.ok, false);
|
|
if (!v.ok)
|
|
strict_1.default.equal(v.reason, 'gas');
|
|
});
|
|
(0, node_test_1.test)('BSC: scales ledger 6-dec to 18-dec USDT requirement', () => {
|
|
const ledger = 5000000n; // 5 USDT
|
|
const chainNeeded = ledger * 10n ** 12n;
|
|
const ok = (0, hotLiquidityService_1.evaluateHotLiquidity)({
|
|
network: 'BSC',
|
|
usdtBalanceRaw: chainNeeded,
|
|
nativeBalanceRaw: hotLiquidityService_1.MIN_BNB_WEI_FOR_WITHDRAWAL,
|
|
ledgerAmountRaw: ledger,
|
|
});
|
|
strict_1.default.equal(ok.ok, true);
|
|
const short = (0, hotLiquidityService_1.evaluateHotLiquidity)({
|
|
network: 'BSC',
|
|
usdtBalanceRaw: chainNeeded - 1n,
|
|
nativeBalanceRaw: hotLiquidityService_1.MIN_BNB_WEI_FOR_WITHDRAWAL,
|
|
ledgerAmountRaw: ledger,
|
|
});
|
|
strict_1.default.equal(short.ok, false);
|
|
if (!short.ok)
|
|
strict_1.default.equal(short.reason, 'usdt');
|
|
});
|
|
(0, node_test_1.test)('BSC: rejects when BNB below gas floor', () => {
|
|
const v = (0, hotLiquidityService_1.evaluateHotLiquidity)({
|
|
network: 'BSC',
|
|
usdtBalanceRaw: 10n ** 18n,
|
|
nativeBalanceRaw: hotLiquidityService_1.MIN_BNB_WEI_FOR_WITHDRAWAL - 1n,
|
|
ledgerAmountRaw: 1000000n,
|
|
});
|
|
strict_1.default.equal(v.ok, false);
|
|
if (!v.ok)
|
|
strict_1.default.equal(v.reason, 'gas');
|
|
});
|
|
});
|
|
//# sourceMappingURL=hotLiquidity.test.js.map
|