INNER CODE UNIT · JavaScript

onAmount

pamgarcia1993/robinhood-lp-bot · legacy/bot.js:77

async function onAmount(text) {
  const st = pending.get(chatId);
  if (!st?.awaitingAmount || !st.chosen) return;
  const eth = parseFloat(text);
  if (!(eth > 0)) return send("Masukin angka ETH yang bener, contoh: 0.005");
  const b = await CH.balances().catch(() => null);
  if (b && eth > usableEth(b) + 1e-9) return send(`⚠️ Kegedean. Yang bisa di-LP cuma ${usableEth(b).toFixed(5)} ETH (WETH ${Number(b.weth).toFixed(4)} + ETH ${Number(b.eth).toFixed(4)}, sisain gas). Ketik lebih kecil.`);
  if (b && Number(b.eth) < GAS_RESERVE) return send(`⚠️ ETH native cuma ${Number(b.eth).toFixed(5)} — kurang buat gas (butuh min ${GAS_RESERVE}). Isi sedikit ETH native, ATAU unwrap dikit WETH → ETH.`);
  st.ethAmt = String(eth);
  st.awaitingAmount = false;
  const [pS, pI] = await Promise.all([
    CH.previewRange(st.token, st.chosen.pool, "single").catch(() => null),
    CH.previewRange(st.token, st.chosen.pool, "inrange").catch(() => null),
  ]);
  const rng = (p) => p ? `${CH.fmtMcap(p.rangeMcapLow)} → ${CH.fmtMcap(p.rangeMcapHigh)}` : "?";
  await send([
    `<b>Konfirmasi mint · Robinhood v3</b>`,
    `${st.meta.symbol} · fee ${(st.chosen.fee / 10000).toFixed(2)}% · deposit <b>${eth} ETH</b> · width ${cfg.lp.widthPct}%`,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…