From 8c77574109d503b7a07917997b3d096f165c1331 Mon Sep 17 00:00:00 2001 From: Stephane Janel Date: Sat, 4 Nov 2023 17:13:37 +0100 Subject: [PATCH] [Upbit] Consider only main networks for currencies, fix deposit-info command --- src/api/exchanges/include/binancepublicapi.hpp | 1 - src/api/exchanges/include/bithumbpublicapi.hpp | 3 ++- src/api/exchanges/include/upbitprivateapi.hpp | 4 ---- src/api/exchanges/src/upbitprivateapi.cpp | 6 +++++- src/api/exchanges/test/commonapi_test.hpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api/exchanges/include/binancepublicapi.hpp b/src/api/exchanges/include/binancepublicapi.hpp index 19fe4e0c..605190be 100644 --- a/src/api/exchanges/include/binancepublicapi.hpp +++ b/src/api/exchanges/include/binancepublicapi.hpp @@ -15,7 +15,6 @@ #include "monetaryamount.hpp" #include "permanentcurloptions.hpp" #include "runmodes.hpp" -#include "timedef.hpp" namespace cct { diff --git a/src/api/exchanges/include/bithumbpublicapi.hpp b/src/api/exchanges/include/bithumbpublicapi.hpp index 5df1e785..1eda4917 100644 --- a/src/api/exchanges/include/bithumbpublicapi.hpp +++ b/src/api/exchanges/include/bithumbpublicapi.hpp @@ -1,10 +1,11 @@ #pragma once +#include + #include "cachedresult.hpp" #include "curlhandle.hpp" #include "exchangepublicapi.hpp" #include "exchangepublicapitypes.hpp" -#include "timedef.hpp" namespace cct { diff --git a/src/api/exchanges/include/upbitprivateapi.hpp b/src/api/exchanges/include/upbitprivateapi.hpp index a0caa43d..c7978e57 100644 --- a/src/api/exchanges/include/upbitprivateapi.hpp +++ b/src/api/exchanges/include/upbitprivateapi.hpp @@ -1,10 +1,6 @@ #pragma once -#include -#include - #include "cachedresult.hpp" -#include "cct_json.hpp" #include "curlhandle.hpp" #include "exchangeprivateapi.hpp" #include "exchangeprivateapitypes.hpp" diff --git a/src/api/exchanges/src/upbitprivateapi.cpp b/src/api/exchanges/src/upbitprivateapi.cpp index 64653f60..dc589945 100644 --- a/src/api/exchanges/src/upbitprivateapi.cpp +++ b/src/api/exchanges/src/upbitprivateapi.cpp @@ -136,9 +136,13 @@ CurrencyExchangeFlatSet UpbitPrivate::TradableCurrenciesFunc::operator()() { const CurrencyCodeSet& excludedCurrencies = _exchangeInfo.excludedCurrenciesAll(); CurrencyExchangeVector currencies; json result = PrivateQuery(_curlHandle, _apiKey, HttpRequestType::kGet, "/v1/status/wallet"); - currencies.reserve(static_cast(result.size() - excludedCurrencies.size())); for (const json& curDetails : result) { CurrencyCode cur(curDetails["currency"].get()); + CurrencyCode networkName(curDetails["net_type"].get()); + if (cur != networkName) { + log::debug("Forgive about {}-{} as net type is not the main one", cur, networkName); + continue; + } if (UpbitPublic::CheckCurrencyCode(cur, excludedCurrencies)) { std::string_view walletState = curDetails["wallet_state"].get(); CurrencyExchange::Withdraw withdrawStatus = CurrencyExchange::Withdraw::kUnavailable; diff --git a/src/api/exchanges/test/commonapi_test.hpp b/src/api/exchanges/test/commonapi_test.hpp index f6f1e169..b5f3a386 100644 --- a/src/api/exchanges/test/commonapi_test.hpp +++ b/src/api/exchanges/test/commonapi_test.hpp @@ -190,7 +190,7 @@ class TestAPI { }); if (!depositableCryptos.empty()) { CurrencyExchangeFlatSet sample; - int nbSamples = exchangePrivateOpt->canGenerateDepositAddress() ? 1 : 5; + const int nbSamples = exchangePrivateOpt->canGenerateDepositAddress() ? 1 : 5; std::ranges::sample(depositableCryptos, std::inserter(sample, sample.end()), nbSamples, std::mt19937{std::random_device{}()});