diff --git a/exchanges/gateio/gateio_types.go b/exchanges/gateio/gateio_types.go index 84bc7375..a51aa0bd 100644 --- a/exchanges/gateio/gateio_types.go +++ b/exchanges/gateio/gateio_types.go @@ -54,9 +54,9 @@ type MarketInfoPairsResponse struct { // BalancesResponse holds the user balances type BalancesResponse struct { - Result string `json:"result"` - Available []map[string]string `json:"available"` - Locked []map[string]string `json:"locked"` + Result string `json:"result"` + Available map[string]string `json:"available"` + Locked map[string]string `json:"locked"` } // KlinesRequestParams represents Klines request data. diff --git a/exchanges/gateio/gateio_wrapper.go b/exchanges/gateio/gateio_wrapper.go index e292ee1a..503a69ae 100644 --- a/exchanges/gateio/gateio_wrapper.go +++ b/exchanges/gateio/gateio_wrapper.go @@ -125,42 +125,39 @@ func (g *Gateio) GetAccountInfo() (exchange.AccountInfo, error) { var balances []exchange.AccountCurrencyInfo - for _, data := range balance.Locked { - for key, amountStr := range data { - lockedF, err := strconv.ParseFloat(amountStr, 64) - if err != nil { - return info, err - } + for key, amountStr := range balance.Locked { - balances = append(balances, exchange.AccountCurrencyInfo{ - CurrencyName: key, - Hold: lockedF, - }) + lockedF, err := strconv.ParseFloat(amountStr, 64) + if err != nil { + return info, err } + + balances = append(balances, exchange.AccountCurrencyInfo{ + CurrencyName: key, + Hold: lockedF, + }) } - for _, data := range balance.Available { - for key, amountStr := range data { - availAmount, err := strconv.ParseFloat(amountStr, 64) - if err != nil { - return info, err - } + for key, amountStr := range balance.Available { + availAmount, err := strconv.ParseFloat(amountStr, 64) + if err != nil { + return info, err + } - var updated bool - for i := range balances { - if balances[i].CurrencyName == key { - balances[i].TotalValue = balances[i].Hold + availAmount - updated = true - break - } + var updated bool + for i := range balances { + if balances[i].CurrencyName == key { + balances[i].TotalValue = balances[i].Hold + availAmount + updated = true + break } + } - if !updated { - balances = append(balances, exchange.AccountCurrencyInfo{ - CurrencyName: key, - TotalValue: availAmount, - }) - } + if !updated { + balances = append(balances, exchange.AccountCurrencyInfo{ + CurrencyName: key, + TotalValue: availAmount, + }) } }