games_app/backend/src/utils/withdrawalLimits.ts
2026-07-07 15:03:17 +02:00

13 lines
540 B
TypeScript

/**
* USD approximation for withdrawal limit checks (stablecoins 1:1).
*/
/** Converts raw on-chain units to approximate USD for limit enforcement. */
export function rawAmountToUsdApprox(walletTypeCode: string, amountRaw: bigint, decimals: number): number {
const human = Number(amountRaw) / 10 ** decimals;
const code = walletTypeCode.toUpperCase();
if (code.includes('USDT') || code.includes('USDC')) return human;
// Platform is USDT-first; other assets treated 1:1 at human scale as conservative fallback.
return human;
}