Move common ad details to dedicated config section

master
Mark Veidemanis 3 years ago
parent 32d4a9d0bd
commit 1827bf5fff
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -458,7 +458,7 @@ class Agora(util.Base):
""" """
Format the ad. Format the ad.
""" """
ad = settings.Agora.Ad ad = settings.Platform.Ad
# Substitute the currency # Substitute the currency
ad = ad.replace("$CURRENCY$", currency) ad = ad.replace("$CURRENCY$", currency)
@ -477,7 +477,7 @@ class Agora(util.Base):
""" """
Format the payment details. Format the payment details.
""" """
payment = settings.Agora.PaymentDetails payment = settings.Platform.PaymentDetails
payment_text = "" payment_text = ""
for field, value in payment_details.items(): for field, value in payment_details.items():
@ -545,7 +545,7 @@ class Agora(util.Base):
"track_max_amount": False, "track_max_amount": False,
"require_trusted_by_advertiser": False, "require_trusted_by_advertiser": False,
"online_provider": provider, "online_provider": provider,
"payment_method_details": settings.Agora.PaymentMethodDetails, "payment_method_details": settings.Platform.PaymentMethodDetails,
} }
if visible is False: if visible is False:
form["visible"] = False form["visible"] = False
@ -637,6 +637,9 @@ class Agora(util.Base):
:return: response dict :return: response dict
:rtype: dict :rtype: dict
""" """
if settings.Agora.Dummy == "1":
self.log.error(f"Running in dummy mode, not releasing funds for {contact_id}")
return
payload = {"tradeId": contact_id, "password": settings.Agora.Pass} payload = {"tradeId": contact_id, "password": settings.Agora.Pass}
rtrn = self.agora._api_call(api_method=f"contact_release/{contact_id}", http_method="POST", query_values=payload) rtrn = self.agora._api_call(api_method=f"contact_release/{contact_id}", http_method="POST", query_values=payload)
@ -652,33 +655,26 @@ class Agora(util.Base):
Withdraw excess funds to our XMR wallets. Withdraw excess funds to our XMR wallets.
""" """
totals_all = self.tx.get_total() totals_all = self.tx.get_total()
print("totals_all", totals_all)
if totals_all is False: if totals_all is False:
return False return False
wallet_xmr, _ = totals_all[2] wallet_xmr, _ = totals_all[2]
print("wallet_xmr", wallet_xmr)
# Get the wallet balances in USD # Get the wallet balances in USD
total_usd = totals_all[0][1] total_usd = totals_all[0][1]
print("total_usd", total_usd)
total_trades_usd = self.tx.get_open_trades_usd() # total_trades_usd = self.tx.get_open_trades_usd()
print("UNUSED total_trades_usd", total_trades_usd)
if not total_usd: if not total_usd:
return False return False
# total_usd += total_trades_usd # total_usd += total_trades_usd
# print("total_usd after trades add", total_usd) # print("total_usd after trades add", total_usd)
profit_usd = total_usd - float(settings.Money.BaseUSD) profit_usd = total_usd - float(settings.Money.BaseUSD)
print("profit_usd", profit_usd)
# Get the XMR -> USD exchange rate # Get the XMR -> USD exchange rate
xmr_usd = self.cg.get_price(ids="monero", vs_currencies=["USD"]) xmr_usd = self.cg.get_price(ids="monero", vs_currencies=["USD"])
print("xmr_usd", xmr_usd)
# Convert the USD total to XMR # Convert the USD total to XMR
profit_usd_in_xmr = float(profit_usd) / xmr_usd["monero"]["usd"] profit_usd_in_xmr = float(profit_usd) / xmr_usd["monero"]["usd"]
print("profit_usd_in_xmr", profit_usd_in_xmr)
# Check profit is above zero # Check profit is above zero
if not profit_usd >= 0: if not profit_usd >= 0:
@ -696,10 +692,8 @@ class Agora(util.Base):
return return
half = profit_usd_in_xmr / 2 half = profit_usd_in_xmr / 2
print("half", half)
half_rounded = round(half, 8) half_rounded = round(half, 8)
print("half_rounded", half_rounded)
# Read OTP secret # Read OTP secret
with open("otp.key", "r") as f: with open("otp.key", "r") as f:

Loading…
Cancel
Save