#!/usr/bin/env python3 """X10 ROT buy dry run (D-025). QUOTE ONLY: never sends a swap. For each ROT live coin, prices $USD of the chain's native coin, asks GMGN for a quote from the ROT wallet, and prints the exact swap command ROT will run once the wallet is funded. Usage: python3 rot_buy.py [--usd 20] [--wallet 0x...] (default wallet: the first EVM wallet the API key sees that is not FW's wallet 1). Prints no keys. Spaces GMGN calls 8 s apart (ban rule).""" import json, subprocess, sys, time, urllib.request, shutil W1 = "0x0184ef9b23476ed84107cc5e15485a4a7ee6b286" # FW GMGN wallet 1, never ROT's NATIVE = "0x0000000000000000000000000000000000000000" COINS = [ # sym, gmgn chain, contract, native coin for pricing (DOGO stays paper: one $17/day pool, 14% to get in) ("SHARE", "bsc", "0x5FCA51aff213bFBEAB0b711b93c3374252fD6aC3", "BNB"), ("BREW", "bsc", "0xfa6D9B504848606Eb9aeC04CCc161D169B3f2159", "BNB"), ("FOLD", "eth", "0xe172e9b6cfbeeb5593bdce3f077356fdb33af904", "ETH"), ("MWXT", "base", "0x93918567cdd1bc845be955325a43419a7c56d66f", "ETH"), ] CLI = shutil.which("gmgn-cli") or "gmgn-cli" arg = lambda k, d=None: sys.argv[sys.argv.index(k) + 1] if k in sys.argv else d def cli(*a, timeout=40): r = subprocess.run([CLI, *a, "--raw"], capture_output=True, text=True, timeout=timeout) try: return json.loads(r.stdout) except Exception: return {"error": (r.stdout + r.stderr).strip()[:160]} def px(sym): r = urllib.request.urlopen(urllib.request.Request("https://api.coinbase.com/v2/prices/%s-USD/spot" % sym, headers={"User-Agent": "Mozilla/5.0"}), timeout=8) return float(json.loads(r.read())["data"]["amount"]) def rot_wallet(): info = cli("portfolio", "info") evm = [] for w in info.get("wallets", []) if isinstance(info, dict) else []: a = (w.get("address") or "").lower() if a.startswith("0x") and a != W1 and a not in evm: evm.append(a) return evm, info usd = float(arg("--usd", 20)) wallet = arg("--wallet") if not wallet: evm, _ = rot_wallet() if not evm: print("NO ROT WALLET YET: the API key sees only wallet 1 (%s). Ben: bind wallet 2 to the key on gmgn.ai/ai, then rerun." % W1) sys.exit(2) wallet = evm[0] print("ROT wallet (seen by the API key): %s" % wallet) prices = {s: px(s) for s in {c[3] for c in COINS}} print("prices: %s | ticket $%.2f | %s Bangkok" % (prices, usd, time.strftime("%d %b %H:%M", time.gmtime(time.time() + 7 * 3600)))) for sym, chain, tok, nat in COINS: amt = int(usd / prices[nat] * 1e18) q = cli("order", "quote", "--chain", chain, "--from", wallet, "--input-token", NATIVE, "--output-token", tok, "--amount", str(amt), "--slippage", "10") if "output_amount" in q: print("%-5s %-4s quote OK: %s %s in -> %s out (min %s), router %s" % ( sym, chain, amt / 1e18, nat, q["output_amount"], q["min_output_amount"], (q.get("tx") or {}).get("to"))) else: print("%-5s %-4s quote FAILED: %s" % (sym, chain, q.get("error") or str(q)[:160])) print(" to buy (ROT runs it, needs GMGN_ALLOW_AUTOMATED_TRADES=1): gmgn-cli swap --chain %s --from %s --input-token %s " "--output-token %s --amount %d --slippage 10 --yes" % (chain, wallet, NATIVE, tok, amt)) time.sleep(8) print("DRY RUN ONLY: no swap was sent.")