async function checkSmileBalance(config) {
  const balance = config.smileBalance;
  const currency = config.smileBalanceCurrency;

  if (balance <= config.smileCriticalBalance) {
    return {
      ok: false,
      type: "lowBalance",
      code: "smile_balance_critical",
      message: `Smile.one balance is critical: ${balance.toLocaleString()} ${currency}.`,
      details: {
        balance,
        currency,
        level: "critical",
        threshold: config.smileCriticalBalance,
        source: config.smileBalanceSource,
      },
    };
  }

  if (balance <= config.smileWarningBalance) {
    return {
      ok: false,
      type: "lowBalance",
      code: "smile_balance_warning",
      message: `Smile.one balance is low: ${balance.toLocaleString()} ${currency}.`,
      details: {
        balance,
        currency,
        level: "warning",
        threshold: config.smileWarningBalance,
        source: config.smileBalanceSource,
      },
    };
  }

  return {
    ok: true,
    code: "smile_balance_ok",
    details: {
      balance,
      currency,
      source: config.smileBalanceSource,
    },
  };
}

module.exports = {
  checkSmileBalance,
};
