"""The first trade, by hand: the wallet sells $5 of ETH for USDG through Orblivion.""" from orblivion import OrblivionClient, format_token from common import confirm, load, tx client = OrblivionClient(account=load("wallet")) # A dry run: Orblivion plans the trade, the SDK checks every part of it and signs it here, but sends nothing. plan = client.trade(sell="ETH", buy="USDG", amount_usd=5, dry_run=True) print(f"Sell {format_token(plan.amount_in, 'ETH')} ETH") print(f"Expect {format_token(plan.simulated_out, 'USDG')} USDG (simulated on chain)") print(f"At least {format_token(plan.min_out, 'USDG')} USDG, or the trade reverts") print(f"Fee {plan.fee_bps / 100:.2f}% to {plan.fee.recipient}") print(f"Checked {sum(c.ok for c in plan.checks)} of {len(plan.checks)} checks passed before signing") confirm("This sends a real trade on Robinhood Chain.") t = client.trade(sell="ETH", buy="USDG", amount_usd=5) fee_symbol = "ETH" if t.fee.side == "input" else "USDG" print(f"\nReceived {format_token(t.amount_out, 'USDG')} USDG ({t.diff_bps:+.2f} bps against the simulation)") print(f"Fee paid {format_token(t.fee.amount, fee_symbol)} {fee_symbol}") print(f"Mined as signed: {t.as_built}") print(tx(t.tx_hash))