Finish implementation and tests for the cheat system #3

Closed
m wants to merge 67 commits from cheat-refactor into master
3 changed files with 23 additions and 36 deletions
Showing only changes of commit 469eb762f0 - Show all commits

View File

@ -621,3 +621,10 @@ class Agora(object):
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)
return rtrn return rtrn
def withdraw_funds(self):
"""
Withdraw excess funds to our XMR/BTC wallets.
"""
# wallet_xmr =
pass

View File

@ -76,6 +76,7 @@ if __name__ == "__main__":
# Pass Agora and IRC to Transactions and Transactions to IRC # Pass Agora and IRC to Transactions and Transactions to IRC
tx.set_agora(agora) tx.set_agora(agora)
tx.set_irc(irc) tx.set_irc(irc)
tx.set_revolut(revolut)
irc.set_tx(tx) irc.set_tx(tx)
agora.set_tx(tx) agora.set_tx(tx)

View File

@ -193,42 +193,11 @@ class IRCCommands(object):
@staticmethod @staticmethod
def run(cmd, spl, length, authed, msg, agora, revolut, tx): def run(cmd, spl, length, authed, msg, agora, revolut, tx):
total_usd_revolut = revolut.get_total_usd() totals_all = tx.get_total()
if total_usd_revolut is False: totals = totals_all[0]
msg("Error getting Revolut balance.") wallets = totals_all[1]
return msg(f"Totals: SEK: {totals[0]} | USD: {totals[1]} | GBP: {totals[2]}")
agora_wallet_xmr = agora.agora.wallet_balance_xmr() msg(f"Wallets: XMR USD: {wallets[0]} | BTC USD: {wallets[1]}")
if not agora_wallet_xmr["success"]:
msg("Error getting Agora XMR balance.")
return
agora_wallet_btc = agora.agora.wallet_balance()
if not agora_wallet_btc["success"]:
msg("Error getting Agora BTC balance.")
return
total_xmr_agora = agora_wallet_xmr["response"]["data"]["total"]["balance"]
total_btc_agora = agora_wallet_btc["response"]["data"]["total"]["balance"]
# Get the XMR -> USD exchange rate
xmr_usd = agora.cg.get_price(ids="monero", vs_currencies=["USD"])
# Get the BTC -> USD exchange rate
btc_usd = agora.cg.get_price(ids="bitcoin", vs_currencies=["USD"])
# Convert the Agora XMR total to USD
total_usd_agora_xmr = float(total_xmr_agora) * xmr_usd["monero"]["usd"]
# Convert the Agora BTC total to USD
total_usd_agora_btc = float(total_btc_agora) * btc_usd["bitcoin"]["usd"]
# Add it all up
total_usd_agora = total_usd_agora_xmr + total_usd_agora_btc
total_usd = total_usd_agora + total_usd_revolut
# Convert the total USD price to GBP and SEK
rates = agora.get_rates_all()
price_sek = rates["SEK"] * total_usd
price_usd = total_usd
price_gbp = rates["GBP"] * total_usd
msg(f"SEK: {price_sek} | USD: {price_usd} | GBP: {price_gbp}")
class ping(object): class ping(object):
name = "ping" name = "ping"
@ -430,3 +399,13 @@ class IRCCommands(object):
price_usd = xmr_prices["bitcoin"]["usd"] price_usd = xmr_prices["bitcoin"]["usd"]
price_gbp = xmr_prices["bitcoin"]["gbp"] price_gbp = xmr_prices["bitcoin"]["gbp"]
msg(f"SEK: {price_sek} | USD: {price_usd} | GBP: {price_gbp}") msg(f"SEK: {price_sek} | USD: {price_usd} | GBP: {price_gbp}")
class withdraw(object):
name = "withdraw"
authed = True
helptext = "Take profit."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, revolut, tx):
rtrn = agora.withdraw_funds()
msg(dumps(rtrn))