calculate netAsset if it's zero

This commit is contained in:
c9s 2022-05-04 17:08:42 +08:00
parent 1844035abb
commit f33e8a3de2
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -211,14 +211,20 @@ func (m BalanceMap) Assets(prices map[string]fixedpoint.Value, priceTime time.Ti
continue continue
} }
total := b.Available.Add(b.Locked)
netAsset := b.NetAsset
if netAsset.IsZero() {
netAsset = total.Sub(b.Borrowed)
}
asset := Asset{ asset := Asset{
Currency: currency, Currency: currency,
Total: b.Available.Add(b.Locked), Total: total,
Time: priceTime, Time: priceTime,
Locked: b.Locked, Locked: b.Locked,
Available: b.Available, Available: b.Available,
Borrowed: b.Borrowed, Borrowed: b.Borrowed,
NetAsset: b.NetAsset, NetAsset: netAsset,
} }
usdMarkets := []string{currency + "USDT", currency + "USDC", currency + "USD", "USDT" + currency} usdMarkets := []string{currency + "USDT", currency + "USDC", currency + "USD", "USDT" + currency}