INNER CODE UNIT · JavaScript
GAS_RESERVE
pamgarcia1993/robinhood-lp-bot · legacy/bot.js:53
const GAS_RESERVE = 0.0004; // ETH native disisain buat gas (~4-5 tx; gas Robinhood ~0.0001/tx)
// Usable = WETH (udah wrap) + ETH native yang bisa di-wrap (dikurang cadangan gas)
function usableEth(b) {
return Number(b.weth) + Math.max(0, Number(b.eth) - GAS_RESERVE);
}
// Pilih pool → TANYA jumlah ETH (user ketik sendiri)
async function onPick(idx, mid) {
const st = pending.get(chatId);
if (!st) return;
const p = st.pools[idx];
st.chosen = p;
st.awaitingAmount = true;
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>` : "",