期期: green index after lower target, USDC transfer, clearer selected state.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
ooCloseModeEnabled: root.getAttribute("data-oo-close-mode-enabled") !== "0",
|
||||
ooCloseMode: "close_all",
|
||||
tradingUsdc: null,
|
||||
fundingUsdc: null,
|
||||
tradeBudgetUsdc: null,
|
||||
budgetBuffer: 0.95,
|
||||
};
|
||||
@@ -185,6 +186,9 @@
|
||||
if (acct.trading_usdc != null && acct.trading_usdc !== "") {
|
||||
state.tradingUsdc = Number(acct.trading_usdc);
|
||||
}
|
||||
if (acct.funding_usdc != null && acct.funding_usdc !== "") {
|
||||
state.fundingUsdc = Number(acct.funding_usdc);
|
||||
}
|
||||
if (chain && chain.trade_budget_usdc != null && chain.trade_budget_usdc !== "") {
|
||||
state.tradeBudgetUsdc = Number(chain.trade_budget_usdc);
|
||||
}
|
||||
@@ -200,11 +204,49 @@
|
||||
fmt(acct.funding_usdc, 2);
|
||||
const el = $("hp-opt-bal-line");
|
||||
if (el) el.textContent = line;
|
||||
const oo = $("hp-oo-bal-line");
|
||||
if (oo) oo.textContent = line;
|
||||
const fundEl = $("hp-oo-funding-usdc");
|
||||
const tradeEl = $("hp-oo-trading-usdc");
|
||||
if (fundEl) fundEl.textContent = fmt(acct.funding_usdc, 2);
|
||||
if (tradeEl) tradeEl.textContent = fmt(acct.trading_usdc, 2);
|
||||
autoFillOoSheets();
|
||||
}
|
||||
|
||||
function setOoXferMsg(text, kind) {
|
||||
const el = $("hp-oo-xfer-msg");
|
||||
if (!el) return;
|
||||
el.textContent = text || "";
|
||||
el.classList.toggle("is-err", kind === "err");
|
||||
el.classList.toggle("is-ok", kind === "ok");
|
||||
}
|
||||
|
||||
function ooXferDir() {
|
||||
const sel = $("hp-oo-xfer-dir");
|
||||
return (sel && sel.value) || "funding_to_trading";
|
||||
}
|
||||
|
||||
async function submitOoUsdcTransfer(amount) {
|
||||
const dir = ooXferDir();
|
||||
const from = dir === "trading_to_funding" ? "trading" : "funding";
|
||||
const to = dir === "trading_to_funding" ? "funding" : "trading";
|
||||
setOoXferMsg("划转中…", null);
|
||||
try {
|
||||
const d = await apiJson("/api/options/transfer", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ ccy: "USDC", from: from, to: to, amount: amount }),
|
||||
});
|
||||
if (!d.ok) {
|
||||
setOoXferMsg(d.msg || "划转失败", "err");
|
||||
return;
|
||||
}
|
||||
setOoXferMsg("划转成功", "ok");
|
||||
if ($("hp-oo-xfer-amount")) $("hp-oo-xfer-amount").value = "";
|
||||
await loadChain();
|
||||
} catch (e) {
|
||||
setOoXferMsg(e.message || "划转失败", "err");
|
||||
}
|
||||
}
|
||||
|
||||
function resolveOoBudget() {
|
||||
const buf = state.budgetBuffer > 0 ? state.budgetBuffer : 0.95;
|
||||
const trading = state.tradingUsdc;
|
||||
@@ -294,6 +336,8 @@
|
||||
document.querySelectorAll(".hp-oo-size-mode").forEach(function (b) {
|
||||
const on = b.getAttribute("data-oo-size") === state.ooSheetsMode;
|
||||
b.classList.toggle("active", on);
|
||||
b.classList.toggle("is-selected", on);
|
||||
b.setAttribute("aria-pressed", on ? "true" : "false");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -305,6 +349,8 @@
|
||||
document.querySelectorAll(".hp-oo-close-mode").forEach(function (b) {
|
||||
const on = b.getAttribute("data-oo-close") === state.ooCloseMode;
|
||||
b.classList.toggle("active", on);
|
||||
b.classList.toggle("is-selected", on);
|
||||
b.setAttribute("aria-pressed", on ? "true" : "false");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -515,7 +561,7 @@
|
||||
"指数 " + uly + " " + fmt(d.index_px, 2) + " · " + (d.inst_family || "") + " · 实值含平值";
|
||||
}
|
||||
const ooIdx = $("hp-oo-index");
|
||||
if (ooIdx) ooIdx.textContent = "指数 " + uly + " " + fmt(d.index_px, 2);
|
||||
if (ooIdx) ooIdx.textContent = "指数 " + fmt(d.index_px, 2);
|
||||
setOptionsBalance(d);
|
||||
fillExpSelect($("hp-exp-select"), d);
|
||||
fillExpSelect($("hp-oo-exp-select"), d);
|
||||
@@ -992,6 +1038,32 @@
|
||||
updateOoBudgetLine(null);
|
||||
});
|
||||
});
|
||||
if ($("hp-oo-xfer-btn")) {
|
||||
$("hp-oo-xfer-btn").addEventListener("click", function () {
|
||||
const amount = Number(($("hp-oo-xfer-amount") && $("hp-oo-xfer-amount").value) || 0);
|
||||
if (!(amount > 0)) {
|
||||
setOoXferMsg("请输入有效数量", "err");
|
||||
return;
|
||||
}
|
||||
void submitOoUsdcTransfer(amount);
|
||||
});
|
||||
}
|
||||
if ($("hp-oo-xfer-all")) {
|
||||
$("hp-oo-xfer-all").addEventListener("click", function () {
|
||||
const dir = ooXferDir();
|
||||
const max =
|
||||
dir === "trading_to_funding" ? Number(state.tradingUsdc || 0) : Number(state.fundingUsdc || 0);
|
||||
if (!(max > 0)) {
|
||||
setOoXferMsg("划出账户可用余额不足", "err");
|
||||
return;
|
||||
}
|
||||
const amt = Math.floor(max * 100) / 100;
|
||||
const label = dir === "trading_to_funding" ? "交易 → 资金" : "资金 → 交易";
|
||||
if (!window.confirm("确认全部划转?\n方向:" + label + "\n数量:" + amt + " USDC")) return;
|
||||
if ($("hp-oo-xfer-amount")) $("hp-oo-xfer-amount").value = String(amt);
|
||||
void submitOoUsdcTransfer(amt);
|
||||
});
|
||||
}
|
||||
if ($("hp-preview-btn"))
|
||||
$("hp-preview-btn").addEventListener("click", function () {
|
||||
state.mode = "perp_options";
|
||||
|
||||
@@ -3258,6 +3258,70 @@ html[data-theme="light"] .opt-be-dist-down {
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-target-row {
|
||||
align-items: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px 14px;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-index {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin: 0 0 2px;
|
||||
padding: 4px 0;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: #3dd68c;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer {
|
||||
margin: 10px 0 4px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-bals {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 6px 8px;
|
||||
margin-bottom: 8px;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-bals strong {
|
||||
color: var(--text, #e6edf3);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-unit {
|
||||
opacity: 0.75;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-form select,
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-form input[type="number"] {
|
||||
font-size: 0.74rem;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-form input[type="number"] {
|
||||
width: 96px;
|
||||
max-width: 30vw;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-msg {
|
||||
margin: 6px 0 0;
|
||||
font-size: 0.72rem;
|
||||
min-height: 1.1em;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-msg.is-err {
|
||||
color: #ff8a8a;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-transfer-msg.is-ok {
|
||||
color: #3dd68c;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-controls {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
@@ -3289,12 +3353,29 @@ html[data-theme="light"] .opt-be-dist-down {
|
||||
min-width: 4.5em;
|
||||
justify-content: center;
|
||||
padding: 5px 8px;
|
||||
position: relative;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-check {
|
||||
display: none;
|
||||
margin-right: 4px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-size-mode.is-selected,
|
||||
.hedge-plan-page-wrap .hp-oo-close-mode.is-selected,
|
||||
.hedge-plan-page-wrap .hp-oo-size-mode.active,
|
||||
.hedge-plan-page-wrap .hp-oo-close-mode.active {
|
||||
border-color: var(--accent, #00d4ff);
|
||||
color: var(--text, #fff);
|
||||
background: rgba(0, 212, 255, 0.12);
|
||||
background: rgba(0, 212, 255, 0.16);
|
||||
box-shadow: inset 0 0 0 1px rgba(0, 212, 255, 0.35);
|
||||
font-weight: 700;
|
||||
}
|
||||
.hedge-plan-page-wrap .hp-oo-size-mode.is-selected .hp-oo-check,
|
||||
.hedge-plan-page-wrap .hp-oo-close-mode.is-selected .hp-oo-check,
|
||||
.hedge-plan-page-wrap .hp-oo-size-mode.active .hp-oo-check,
|
||||
.hedge-plan-page-wrap .hp-oo-close-mode.active .hp-oo-check {
|
||||
display: inline;
|
||||
color: var(--accent, #00d4ff);
|
||||
}
|
||||
.hedge-plan-page-wrap #hp-oo-close-mode-row.hidden {
|
||||
display: none !important;
|
||||
|
||||
Reference in New Issue
Block a user