Finish implementation and tests for the cheat system #3

Closed
m wants to merge 67 commits from cheat-refactor into master
1 changed files with 34 additions and 22 deletions
Showing only changes of commit 7e42bbebf3 - Show all commits

View File

@ -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