INNER CODE UNIT · JavaScript
b
pamgarcia1993/robinhood-lp-bot · legacy/bot.js:67
const b = await CH.balances().catch(() => null);
await edit(mid, [
`<b>${st.meta.symbol}</b> · fee ${(p.fee / 10000).toFixed(2)}% dipilih.`,
b ? `Saldo bisa di-LP: <b>${usableEth(b).toFixed(5)} ETH</b> <i>(WETH ${Number(b.weth).toFixed(4)} + ETH ${Number(b.eth).toFixed(4)})</i>` : "",
``,
`💬 <b>Ketik jumlah ETH</b> yang mau di-LP (contoh: <code>0.005</code>)`,
].filter(Boolean).join("\n"));
}
// User ngetik angka → tampilkan konfirmasi
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.`);