Implement LBTC when getting wallet balances

This commit is contained in:
Mark Veidemanis 2022-04-15 14:26:30 +01:00
parent e751fcd39d
commit 0e4fa8a0bb
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 51 additions and 16 deletions

View File

@ -39,3 +39,8 @@ class Sources(util.Base):
"notify": self.notify,
}
util.xmerge_attrs(init_map)
def get_total_wallets(self):
"""
Get the total crypto in our wallets.
"""

View File

@ -618,8 +618,12 @@ class Transactions(util.Base):
agora_wallet_btc = self.agora.agora.wallet_balance()
if not agora_wallet_btc["success"]:
return False
lbtc_wallet_btc = self.lbtc.lbtc.wallet_balance()
if not lbtc_wallet_btc["success"]:
return False
total_xmr_agora = agora_wallet_xmr["response"]["data"]["total"]["balance"]
total_btc_agora = agora_wallet_btc["response"]["data"]["total"]["balance"]
total_btc_lbtc = lbtc_wallet_btc["response"]["data"]["total"]["balance"]
# Get the XMR -> USD exchange rate
xmr_usd = self.money.cg.get_price(ids="monero", vs_currencies=["USD"])
@ -629,11 +633,14 @@ class Transactions(util.Base):
# Convert the Agora BTC total to USD
total_usd_agora_btc = float(total_btc_agora) * btc_usd["bitcoin"]["usd"]
# Convert the LBTC BTC total to USD
total_usd_lbtc_btc = float(total_btc_lbtc) * btc_usd["bitcoin"]["usd"]
# Convert the Agora XMR total to USD
total_usd_agora_xmr = float(total_xmr_agora) * xmr_usd["monero"]["usd"]
# Add it all up
total_usd_agora = total_usd_agora_xmr + total_usd_agora_btc
total_usd_agora = total_usd_agora_xmr + total_usd_agora_btc + total_usd_lbtc_btc
total_usd = total_usd_agora + total_sinks_usd
cast_es = {
"price_usd": total_usd,
@ -666,8 +673,12 @@ class Transactions(util.Base):
if not agora_wallet_btc["success"]:
self.log.error("Could not get Agora BTC wallet total.")
return False
lbtc_wallet_btc = self.lbtc.lbtc.wallet_balance()
if not lbtc_wallet_btc["success"]:
return False
total_xmr_agora = agora_wallet_xmr["response"]["data"]["total"]["balance"]
total_btc_agora = agora_wallet_btc["response"]["data"]["total"]["balance"]
total_btc_lbtc = lbtc_wallet_btc["response"]["data"]["total"]["balance"]
# Get the XMR -> USD exchange rate
xmr_usd = self.money.cg.get_price(ids="monero", vs_currencies=["USD"])
@ -680,9 +691,13 @@ class Transactions(util.Base):
# Convert the Agora BTC total to USD
total_usd_agora_btc = float(total_btc_agora) * btc_usd["bitcoin"]["usd"]
# Convert the LBTC BTC total to USD
total_usd_lbtc_btc = float(total_btc_lbtc) * 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_sinks_usd
total_usd_lbtc = total_usd_lbtc_btc
total_usd = total_usd_agora + total_usd_lbtc + total_sinks_usd
# Convert the total USD price to GBP and SEK
rates = self.money.get_rates_all()

View File

@ -229,6 +229,23 @@ class GenericCommands(object):
rtrn = caller.nuke_ads()
msg(dumps(rtrn))
class wallet(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, xmr, caller):
if xmr:
rtrn_xmr = caller.wallet_balance_xmr()
if not rtrn_xmr["success"]:
msg("Error getting XMR wallet details.")
return
balance_xmr = rtrn_xmr["response"]["data"]["total"]["balance"]
msg(f"XMR wallet balance: {balance_xmr}")
rtrn_btc = caller.wallet_balance()
if not rtrn_btc["success"]:
msg("Error getting BTC wallet details.")
return
balance_btc = rtrn_btc["response"]["data"]["total"]["balance"]
msg(f"BTC wallet balance: {balance_btc}")
class IRCCommands(object):
class atrades(object):
@ -509,25 +526,23 @@ class IRCCommands(object):
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.nuke.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class wallet(object):
name = "wallet"
class awallet(object):
authed = True
name = "awallet"
helptext = "Get Agora wallet balances."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
rtrn_xmr = agora.agora.wallet_balance_xmr()
if not rtrn_xmr["success"]:
msg("Error getting XMR wallet details.")
return
rtrn_btc = agora.agora.wallet_balance()
if not rtrn_btc["success"]:
msg("Error getting BTC wallet details.")
return
balance_xmr = rtrn_xmr["response"]["data"]["total"]["balance"]
balance_btc = rtrn_btc["response"]["data"]["total"]["balance"]
msg(f"XMR wallet balance: {balance_xmr}")
msg(f"BTC wallet balance: {balance_btc}")
GenericCommands.wallet.run(cmd, spl, length, authed, msg, agora, tx, ux, True, agora.agora)
class lwallet(object):
authed = True
name = "lwallet"
helptext = "Get LBTC wallet balances."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.wallet.run(cmd, spl, length, authed, msg, agora, tx, ux, False, tx.lbtc.lbtc)
class apubads(object):
authed = True