Use trading account and USDC/USDT market price for sim convert.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-14 18:52:38 +08:00
parent 9d1495658c
commit ad992ee262
7 changed files with 181 additions and 45 deletions
+5 -4
View File
@@ -43,9 +43,9 @@
<button type="button" class="btn" onclick="simTransfer()">划转</button>
</div>
<h3>USDT ↔ USDC (1:1)</h3>
<h3>USDT ↔ USDC(交易账户 · USDC/USDT 市价)</h3>
<div style="display:flex;gap:0.5rem;flex-wrap:wrap;align-items:center;margin-bottom:1rem">
<select id="sim-conv-account"><option value="funding">资金账户</option><option value="trading">交易账户</option></select>
<select id="sim-conv-account"><option value="trading">交易账户</option><option value="funding">资金账户</option></select>
<select id="sim-conv-from"><option value="USDT">USDT</option><option value="USDC">USDC</option></select>
<span></span>
<select id="sim-conv-to"><option value="USDC">USDC</option><option value="USDT">USDT</option></select>
@@ -142,7 +142,7 @@
};
window.simConvert = function () {
var body = {
account: ($("sim-conv-account") || {}).value || "funding",
account: ($("sim-conv-account") || {}).value || "trading",
from_ccy: ($("sim-conv-from") || {}).value || "USDT",
to_ccy: ($("sim-conv-to") || {}).value || "USDC",
amount: parseFloat(($("sim-conv-amt") || {}).value || "0")
@@ -155,7 +155,8 @@
}).then(function (r) { return r.json(); }).then(function (d) {
if (!d.ok) { msg(d.detail || d.msg || "兑换失败", false); return; }
applyStatus(d);
msg("兑换成功", true);
var px = d.fill_px != null ? (" @" + Number(d.fill_px).toFixed(6)) : "";
msg("兑换成功" + px, true);
}).catch(function (e) { msg(String(e), false); });
};
if (document.readyState === "loading") {