max: add net asset field to max's balance

This commit is contained in:
c9s 2022-05-04 21:42:48 +08:00
parent 2a02c4928c
commit f65ecbdbb5
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -663,10 +663,12 @@ func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
var balances = make(types.BalanceMap) var balances = make(types.BalanceMap)
for _, a := range userInfo.Accounts { for _, a := range userInfo.Accounts {
cur := toGlobalCurrency(a.Currency)
balances[toGlobalCurrency(a.Currency)] = types.Balance{ balances[toGlobalCurrency(a.Currency)] = types.Balance{
Currency: toGlobalCurrency(a.Currency), Currency: cur,
Available: a.Balance, Available: a.Balance,
Locked: a.Locked, Locked: a.Locked,
NetAsset: a.Balance.Add(a.Locked),
} }
} }
@ -861,10 +863,12 @@ func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap,
var balances = make(types.BalanceMap) var balances = make(types.BalanceMap)
for _, a := range accounts { for _, a := range accounts {
balances[toGlobalCurrency(a.Currency)] = types.Balance{ cur := toGlobalCurrency(a.Currency)
Currency: toGlobalCurrency(a.Currency), balances[cur] = types.Balance{
Currency: cur,
Available: a.Balance, Available: a.Balance,
Locked: a.Locked, Locked: a.Locked,
NetAsset: a.Balance.Add(a.Locked),
} }
} }