Notify of irreconcilable trades

This commit is contained in:
Mark Veidemanis 2022-04-04 17:41:51 +01:00
parent 5588d016f2
commit d36bf2a048
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 12 additions and 0 deletions

View File

@ -118,6 +118,7 @@ class Transactions(util.Base):
if len(stored_trade_reference) > 1: if len(stored_trade_reference) > 1:
self.log.error(f"Multiple references valid for TXID {txid}: {reference}") self.log.error(f"Multiple references valid for TXID {txid}: {reference}")
self.irc.sendmsg(f"Multiple references valid for TXID {txid}: {reference}") self.irc.sendmsg(f"Multiple references valid for TXID {txid}: {reference}")
self.ux.notify.notify_tx_lookup_failed(currency, amount, reference, "MULTIPLE_REFS_MATCH")
return return
stored_trade = False stored_trade = False
@ -136,6 +137,7 @@ class Transactions(util.Base):
if not stored_trade: if not stored_trade:
self.log.info(f"Failed to get reference by amount and currency: {txid} {currency} {amount}") self.log.info(f"Failed to get reference by amount and currency: {txid} {currency} {amount}")
self.irc.sendmsg(f"Failed to get reference by amount and currency: {txid} {currency} {amount}") self.irc.sendmsg(f"Failed to get reference by amount and currency: {txid} {currency} {amount}")
self.ux.notify.notify_tx_lookup_failed(currency, amount, reference, "ALT_LOOKUP_FAILED")
return return
if currency == "USD": if currency == "USD":
amount_usd = amount amount_usd = amount
@ -147,6 +149,10 @@ class Transactions(util.Base):
self.log.info("Not checking against amount and currency as amount exceeds MAX") self.log.info("Not checking against amount and currency as amount exceeds MAX")
self.irc.sendmsg(f"Not checking against amount and currency as amount exceeds MAX") self.irc.sendmsg(f"Not checking against amount and currency as amount exceeds MAX")
# Close here if the amount exceeds the allowable limit for no reference # Close here if the amount exceeds the allowable limit for no reference
if len(stored_trade_reference) == 1: # better safe than sorry
self.ux.notify.notify_tx_lookup_failed(currency, amount, reference, "EXCEEDS_MAX", stored_trade_reference[0])
else:
self.ux.notify.notify_tx_lookup_failed(currency, amount, reference, "EXCEEDS_MAX")
return return
# Note that we have looked it up without reference so we don't use +- below # Note that we have looked it up without reference so we don't use +- below
# This might be redundant given the amount checks in find_trade, but better safe than sorry! # This might be redundant given the amount checks in find_trade, but better safe than sorry!
@ -156,6 +162,7 @@ class Transactions(util.Base):
if not stored_trade: if not stored_trade:
self.log.info(f"No reference in DB for {reference}") self.log.info(f"No reference in DB for {reference}")
self.irc.sendmsg(f"No reference in DB for {reference}") self.irc.sendmsg(f"No reference in DB for {reference}")
self.ux.notify.notify_tx_lookup_failed(currency, amount, reference, "NOREF", stored_trade["id"])
return return
amount = float(amount) amount = float(amount)
@ -165,6 +172,7 @@ class Transactions(util.Base):
if not stored_trade["currency"] == currency: if not stored_trade["currency"] == currency:
self.log.info(f"Currency mismatch, Agora: {stored_trade['currency']} / Sink: {currency}") self.log.info(f"Currency mismatch, Agora: {stored_trade['currency']} / Sink: {currency}")
self.irc.sendmsg(f"Currency mismatch, Agora: {stored_trade['currency']} / Sink: {currency}") self.irc.sendmsg(f"Currency mismatch, Agora: {stored_trade['currency']} / Sink: {currency}")
self.ux.notify.notify_tx_lookup_failed(currency, amount, reference, "CURRENCY_MISMATCH", stored_trade["id"])
return return
# Make sure the expected amount was sent # Make sure the expected amount was sent
@ -178,6 +186,7 @@ class Transactions(util.Base):
if not min_amount < amount < max_amount: if not min_amount < amount < max_amount:
self.log.info("Amount mismatch - not in margins: {stored_trade['amount']} (min: {min_amount} / max: {max_amount}") self.log.info("Amount mismatch - not in margins: {stored_trade['amount']} (min: {min_amount} / max: {max_amount}")
self.irc.sendmsg(f"Amount mismatch - not in margins: {stored_trade['amount']} (min: {min_amount} / max: {max_amount}") self.irc.sendmsg(f"Amount mismatch - not in margins: {stored_trade['amount']} (min: {min_amount} / max: {max_amount}")
self.ux.notify.notify_tx_lookup_failed(currency, amount, reference, "AMOUNT_MARGIN_MISMATCH", stored_trade["id"])
return return
r.hmset(f"tx.{txid}", to_store) r.hmset(f"tx.{txid}", to_store)

View File

@ -38,3 +38,6 @@ class Notify(util.Base):
def notify_need_topup(self, amount_usd_xmr, amount_usd_btc): def notify_need_topup(self, amount_usd_xmr, amount_usd_btc):
self.sendmsg(f"XMR: {amount_usd_xmr} | BTC: {amount_usd_btc}", title="Topup needed", tags="admin", priority="5") self.sendmsg(f"XMR: {amount_usd_xmr} | BTC: {amount_usd_btc}", title="Topup needed", tags="admin", priority="5")
def notify_tx_lookup_failed(self, currency, amount, reference, code, trade_id=None):
self.sendmsg(f"Unknown TX [{code}]: {amount}{currency} ({reference}) for {trade_id}")