Fix coin-margin expiry breakeven to use coin premium formula.

Use K/(1-p) and K/(1+p) for coin calls/puts instead of adding ETH premium to USD strike; align T-view straddle band with coin quotes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-23 08:11:52 +08:00
parent 68869e35c3
commit 6d2d345b70
3 changed files with 66 additions and 6 deletions
+10 -1
View File
@@ -614,7 +614,13 @@
if (strike == null || per == null) return "—";
const k = Number(strike);
const d = Number(per);
if (!Number.isFinite(k) || !Number.isFinite(d)) return "—";
if (!Number.isFinite(k) || !Number.isFinite(d) || d <= 0) return "—";
if (isCoinMarginMode()) {
if (d >= 1) return "—";
const lo = Math.round((k / (1 + d)) * 10) / 10;
const hi = Math.round((k / (1 - d)) * 10) / 10;
return lo.toFixed(0) + " ~ " + hi.toFixed(0);
}
const lo = Math.round((k - d) * 10) / 10;
const hi = Math.round((k + d) * 10) / 10;
return lo.toFixed(0) + " ~ " + hi.toFixed(0);
@@ -623,6 +629,9 @@
function formatStraddlePremiumCell(callAsk, putAsk) {
const per = straddleAskPerUnit(callAsk, putAsk);
if (per == null) return '<span class="muted">不可双买</span>';
if (isCoinMarginMode()) {
return fmt(per, 4) + " " + (state.underlying || "ETH");
}
return fmtUsdc(per) + " USDC";
}