INNER CODE UNIT · JavaScript

onList

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

async function onList(mid = null) {
  if (!mid) {
    const m = await send("⏳ Memuat posisi…");
    mid = m?.result?.message_id ?? null;
  }
  const out = (txt, extra) => (mid ? edit(mid, txt, extra) : send(txt, extra));
  let rows;
  try { rows = await CH.listPositions(); } catch (e) { return out(`❌ ${String(e.message).slice(0, 80)}`); }
  const refreshBtn = [{ text: "🔄 Refresh", callback_data: "refresh" }];
  if (!rows.length) return out("Tidak ada posisi LP terbuka.", { reply_markup: { inline_keyboard: [refreshBtn] } });
  const px = await CH.ethUsd().catch(() => 0);
  const sg = (n, d) => (n >= 0 ? "+" : "") + n.toFixed(d);
  const usd = (e) => px ? `$${(e * px).toFixed(2)}` : "?";
  let totEth = 0, totPnl = 0, totFee = 0, totDep = 0;

  const T = [];
  rows.forEach((r, i) => {
    totEth += r.valEth || 0; totFee += r.feeEth || 0; totDep += r.depEth || 0; if (r.pnlEth != null) totPnl += r.pnlEth;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…