From e9ecd5fb304c81a49bc78903c34335c2025d089a Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 23 Jan 2022 17:08:01 +0000 Subject: [PATCH] Fix posting BTC ads --- handler/agora.py | 56 +++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/handler/agora.py b/handler/agora.py index 1fd6596..38f2728 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -464,33 +464,42 @@ class Agora(object): paymentdetailstext = paymentdetails.replace("$PAYMENT$", settings.Agora.DefaultDetailsPayment) ad = ad.replace("$ASSET$", asset) rates = self.get_rates_all() + if asset == "XMR": + min_usd = float(settings.Agora.MinUSDXMR) + max_usd = float(settings.Agora.MaxUSDXMR) + elif asset == "BTC": + min_usd = float(settings.Agora.MinUSDBTC) + max_usd = float(settings.Agora.MaxUSDBTC) if currency == "USD": - min_amount = float(settings.Agora.MinUSD) - max_amount = float(settings.Agora.MaxUSD) + min_amount = min_usd + max_amount = max_usd else: - min_amount = rates[currency] * float(settings.Agora.MinUSD) - max_amount = rates[currency] * float(settings.Agora.MaxUSD) - price_formula = f"coingeckoxmrusd*usd{currency.lower()}*{settings.Agora.Margin}" + min_amount = rates[currency] * min_usd + max_amount = rates[currency] * max_usd + price_formula = f"coingecko{asset.lower()}usd*usd{currency.lower()}*{settings.Agora.Margin}" # price_formula = f"coingeckoxmrusd*{settings.Agora.Margin}" ad = settings.Agora.Ad ad = ad.replace("\\t", "\t") - ad = self.agora.ad_create( - country_code=countrycode, - currency=currency, - trade_type="ONLINE_SELL", - asset=asset, - price_equation=price_formula, - track_max_amount=False, - require_trusted_by_advertiser=False, - # verified_email_required = False, - online_provider="REVOLUT", - msg=adtext, - min_amount=min_amount, - max_amount=max_amount, - payment_method_details=settings.Agora.PaymentMethodDetails, - # require_feedback_score = 0, - account_info=paymentdetailstext, - ) + + form = {"country_code": countrycode, + "currency": currency, + "trade_type": "ONLINE_SELL", + "asset": asset, + "price_equation": price_formula, + "track_max_amount": False, + "require_trusted_by_advertiser": False, + "online_provider": "REVOLUT", + "msg": adtext, + "min_amount": min_amount, + "max_amount": max_amount, + "payment_method_details": settings.Agora.PaymentMethodDetails, + "account_info": paymentdetailstext, + } + + # Dirty hack to test + #if asset == "BTC": + # del form["min_amount"] + ad = self.agora.ad_create(**form) return ad def dist_countries(self): @@ -501,8 +510,11 @@ class Agora(object): :rtype: bool or dict """ for asset in loads(settings.Agora.AssetList): + print("DIST ASSET", asset) for currency, countrycode in loads(settings.Agora.DistList): + print("DIST C/CC", currency, countrycode) rtrn = self.create_ad(asset, countrycode, currency) + print("RTRN", rtrn) if not rtrn: return False yield rtrn