fix: HL balance now reads spot USDC via SpotUserState

HL testnet USDC lives in the spot account, not the perp clearinghouse.
GetBalance() was calling UserState() (perp clearinghouseState), which
returned /usr/bin/bash. Switched to SpotUserState() and parse USDC.total - USDC.hold.

Also cleaned up .gitignore to exclude .env, binary, logs, data/.
This commit is contained in:
jackyu66git
2026-05-04 17:48:14 +08:00
parent 156ce22474
commit 49da6fd35b
7 changed files with 143 additions and 171 deletions
+15 -3
View File
@@ -579,10 +579,22 @@ func (d *Dashboard) handleStatus(w http.ResponseWriter, r *http.Request) {
positions := d.trader.ReadSnapshot()
converged, diverged, flat, total := d.trader.GetClosedStats()
// Format exchange funds (snake_case, like SSE)
exFunds := d.trader.GetExchangeFunds()
exFundsMap := make(map[string]map[string]float64, len(exFunds))
for ex, ef := range exFunds {
exFundsMap[ex] = map[string]float64{
"balance": math.Round(ef.Balance*100) / 100,
"total_fee": math.Round(ef.TotalFee*100) / 100,
"total_pnl": math.Round(ef.TotalPnl*100) / 100,
}
}
resp := map[string]interface{}{
"prices": snap,
"positions": len(positions),
"stats": map[string]int{"total": total, "converged": converged, "diverged": diverged, "flat": flat},
"prices": snap,
"positions": len(positions),
"stats": map[string]int{"total": total, "converged": converged, "diverged": diverged, "flat": flat},
"exchange_funds": exFundsMap,
}
writeJSON(w, resp)
}