Add spot sell retry UI; sell all trading-account coin on sell-back.
Fix coin-margin sell-back to use full available balance instead of bridge record; show retry banner and button on the options positions panel. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1423,7 +1423,33 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
rows.append(row)
|
||||
finally:
|
||||
conn.close()
|
||||
return jsonify({"ok": True, "positions": rows})
|
||||
spot_sell_hint = None
|
||||
try:
|
||||
from lib.options.options_margin_mode_lib import is_coin_margin_mode
|
||||
|
||||
if is_coin_margin_mode():
|
||||
from lib.options.options_spot_bridge_lib import list_open_bridges
|
||||
|
||||
conn_b = cfg["get_db"]()
|
||||
try:
|
||||
from lib.options.options_db import init_options_tables
|
||||
|
||||
init_options_tables(conn_b)
|
||||
open_bridges = list_open_bridges(conn_b)
|
||||
bal = cfg["fetch_options_balances"](ex, scope="main")
|
||||
bridge = open_bridges[0] if open_bridges else None
|
||||
spot_sell_hint = {
|
||||
"bridge_status": str(bridge.get("status") or "") if bridge else None,
|
||||
"bridge_underlying": str(bridge.get("underlying") or "").upper() if bridge else None,
|
||||
"trading_eth": bal.get("trading_eth_avail") or bal.get("trading_eth"),
|
||||
"trading_btc": bal.get("trading_btc_avail") or bal.get("trading_btc"),
|
||||
"default_underly": (cfg.get("default_underly") or "ETH").strip().upper(),
|
||||
}
|
||||
finally:
|
||||
conn_b.close()
|
||||
except Exception:
|
||||
spot_sell_hint = None
|
||||
return jsonify({"ok": True, "positions": rows, "spot_sell": spot_sell_hint})
|
||||
|
||||
@app.route("/api/options/targets")
|
||||
@lr
|
||||
|
||||
Reference in New Issue
Block a user