From 6ad5880ba4464849b1e95a745744e20d5cdf91b1 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Wed, 17 Jan 2024 20:25:28 +0200 Subject: [PATCH] Remove bittrex.com rate source. --- basicswap/basicswap.py | 92 ------------------------------------- tests/basicswap/test_run.py | 3 +- 2 files changed, 1 insertion(+), 94 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 8e9eb85..7a62cbe 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -7132,83 +7132,6 @@ class BasicSwap(BaseApp): js[name_to] = js[exchange_name_to] js.pop(exchange_name_to) - if rate_sources.get('bittrex.com', True): - bittrex_api_v3 = 'https://api.bittrex.com/v3' - try: - exchange_ticker_to = ci_to.getExchangeTicker('bittrex.com') - exchange_ticker_from = ci_from.getExchangeTicker('bittrex.com') - - USDT_coins = (Coins.FIRO,) - # TODO: How to compare USDT pairs with BTC pairs - if ci_from.coin_type() in USDT_coins: - raise ValueError('No BTC pair') - if ci_to.coin_type() in USDT_coins: - raise ValueError('No BTC pair') - - if ci_from.coin_type() == Coins.BTC: - pair = f'{exchange_ticker_to}-{exchange_ticker_from}' - url = f'{bittrex_api_v3}/markets/{pair}/ticker' - self.log.debug(f'lookupRates: {url}') - start = time.time() - js = json.loads(self.readURL(url, timeout=10, headers=headers)) - js['time_taken'] = time.time() - start - js['pair'] = pair - try: - rate_inverted = ci_from.make_int(1.0 / float(js['lastTradeRate']), r=1) - js['rate_inferred'] = ci_to.format_amount(rate_inverted) - except Exception as e: - self.log.warning('lookupRates error: %s', str(e)) - js['rate_inferred'] = 'error' - js['from_btc'] = 1.0 - js['to_btc'] = js['lastTradeRate'] - rv['bittrex'] = js - elif ci_to.coin_type() == Coins.BTC: - pair = f'{exchange_ticker_from}-{exchange_ticker_to}' - url = f'{bittrex_api_v3}/markets/{pair}/ticker' - self.log.debug(f'lookupRates: {url}') - start = time.time() - js = json.loads(self.readURL(url, timeout=10, headers=headers)) - js['time_taken'] = time.time() - start - js['pair'] = pair - js['rate_last'] = js['lastTradeRate'] - js['from_btc'] = js['lastTradeRate'] - js['to_btc'] = 1.0 - rv['bittrex'] = js - else: - pair = f'{exchange_ticker_from}-BTC' - url = f'{bittrex_api_v3}/markets/{pair}/ticker' - self.log.debug(f'lookupRates: {url}') - start = time.time() - js_from = json.loads(self.readURL(url, timeout=10, headers=headers)) - js_from['time_taken'] = time.time() - start - js_from['pair'] = pair - - pair = f'{exchange_ticker_to}-BTC' - url = f'{bittrex_api_v3}/markets/{pair}/ticker' - self.log.debug(f'lookupRates: {url}') - start = time.time() - js_to = json.loads(self.readURL(url, timeout=10, headers=headers)) - js_to['time_taken'] = time.time() - start - js_to['pair'] = pair - - try: - rate_inferred = float(js_from['lastTradeRate']) / float(js_to['lastTradeRate']) - rate_inferred = ci_to.format_amount(rate, conv_int=True, r=1) - except Exception as e: - rate_inferred = 'error' - - rv['bittrex'] = { - 'from': js_from, - 'to': js_to, - 'rate_inferred': rate_inferred, - 'from_btc': js_from['lastTradeRate'], - 'to_btc': js_to['lastTradeRate'] - } - except Exception as e: - rv['bittrex_error'] = str(e) - if self.debug: - self.log.error(traceback.format_exc()) - if output_array: def format_float(f): @@ -7229,21 +7152,6 @@ class BasicSwap(BaseApp): format_float(float(js[name_to]['btc'])), format_float(float(js['rate_inferred'])), )) - if 'bittrex_error' in rv: - rv_array.append(('bittrex.com', 'error', rv['bittrex_error'])) - if 'bittrex' in rv: - js = rv['bittrex'] - rate = js['rate_last'] if 'rate_last' in js else js['rate_inferred'] - rv_array.append(( - 'bittrex.com', - ticker_from, - ticker_to, - '', - '', - format_float(float(js['from_btc'])), - format_float(float(js['to_btc'])), - format_float(float(rate)) - )) return rv_array return rv diff --git a/tests/basicswap/test_run.py b/tests/basicswap/test_run.py index b19937e..cbc65ca 100644 --- a/tests/basicswap/test_run.py +++ b/tests/basicswap/test_run.py @@ -125,11 +125,10 @@ class Test(BaseTest): def test_002_lookup_rates(self): rv = self.swap_clients[0].lookupRates(Coins.BTC, Coins.PART) assert ('coingecko' in rv) - assert ('bittrex' in rv) rv = self.swap_clients[0].lookupRates(Coins.LTC, Coins.BTC) assert ('coingecko' in rv) - assert ('bittrex' in rv) + rv = read_json_api(1800, 'rateslist?from=PART&to=BTC') assert len(rv) == 2