Add OKX env toggle to show or hide perpetual funds in the header.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-05 17:55:15 +08:00
parent 55e94fe059
commit 22e6b68e6d
11 changed files with 105 additions and 10 deletions
@@ -1149,8 +1149,23 @@ function setFundsFieldText(field, text){
el.innerText = text;
});
}
function applyPerpFundsVisibility(show){
const on = show !== false;
document.querySelectorAll("[data-perp-funds='1']").forEach((el) => {
el.style.display = on ? "" : "none";
});
}
function accountSnapshotFundingMissing(data){
if(!data || typeof data !== "object") return true;
if(data.show_perp_funds === false){
const hasTotal = data.total_funds != null && data.total_funds !== "";
const hasOpt =
data.options_funding_usdc != null ||
data.options_funding_usdt != null ||
data.options_trading_usdc != null ||
data.options_trading_usdt != null;
return !hasTotal && !hasOpt;
}
const hasFunding = data.funding_usdt != null && data.funding_usdt !== "";
const hasTotal = data.total_funds != null && data.total_funds !== "";
const hasTrading = data.current_capital != null && data.current_capital !== "";
@@ -1159,6 +1174,9 @@ function accountSnapshotFundingMissing(data){
let accountSnapshotRetryCount = 0;
function applyAccountSnapshot(data){
if(!data || typeof data !== "object") return;
if(typeof data.show_perp_funds !== "undefined"){
applyPerpFundsVisibility(data.show_perp_funds);
}
if(data.funding_usdt != null && data.funding_usdt !== ""){
setFundsFieldText("total-capital", `${Number(data.funding_usdt).toFixed(2)}U`);
}