Refactor and add base USD and withdrawal triggers

This commit is contained in:
2023-03-10 15:34:46 +00:00
parent 7f088d15c2
commit 96858da88a
8 changed files with 54 additions and 25 deletions

View File

@@ -763,7 +763,7 @@ class LocalPlatformClient(ABC):
return all(actioned)
async def release_funds(self, trade_id, reference):
stored_trade = await db.get_ref(reference)
# stored_trade = await db.get_ref(reference)
logmessage = f"All checks passed, releasing funds for {trade_id} {reference}"
log.info(logmessage)
title = "Releasing escrow"
@@ -782,10 +782,10 @@ class LocalPlatformClient(ABC):
await notify.sendmsg(self.instance.user, logmessage, title=title)
return
# Parse the escrow release response
message = rtrn["message"]
# message_long = rtrn["response"]["data"]["message"]
self.irc.sendmsg(f"{dumps(message)}")
# # Parse the escrow release response
# message = rtrn["message"]
# # message_long = rtrn["response"]["data"]["message"]
# self.irc.sendmsg(f"{dumps(message)}")
async def update_trade_tx(self, reference, txid):
"""
@@ -1180,7 +1180,8 @@ class LocalPlatformClient(ABC):
return False
return currency_account_info_map[currency]
# def _distribute_account_details(self, platform, currencies=None, account_info=None):
# def _distribute_account_details(self, platform, currencies=
# None, account_info=None):
# """
# Distribute account details for ads.
# We will disable ads we can't support.
@@ -1200,9 +1201,11 @@ class LocalPlatformClient(ABC):
# our_ads = self.enum_ads()
# supported_ads = [ad for ad in our_ads if ad[3] in supported_currencies]
# supported_ads = [ad for ad in our_ads if ad[3] in supported_curr
# encies]
# not_supported_ads = [ad for ad in our_ads if ad[3] not in supported_currencies]
# not_supported_ads = [ad for ad in our_ads if ad[3] not in supporte
# d_currencies]
# for ad in supported_ads:
# asset = ad[0]

View File

@@ -3,7 +3,6 @@ from pyotp import TOTP
from core.clients.base import BaseClient
from core.clients.platform import LocalPlatformClient
from core.lib.money import Money
class AgoraClient(LocalPlatformClient, BaseClient):
@@ -57,7 +56,7 @@ class AgoraClient(LocalPlatformClient, BaseClient):
return False
# total_usd += total_trades_usd
profit_usd = total_usd - float(settings.Money.BaseUSD)
profit_usd = total_usd - self.instance.base_usd
# Get the XMR -> USD exchange rate
xmr_usd = self.money.cg.get_price(ids="monero", vs_currencies=["USD"])
@@ -85,7 +84,7 @@ class AgoraClient(LocalPlatformClient, BaseClient):
self.ux.notify.notify_need_topup(profit_usd_in_xmr)
return
if not profit_usd >= float(settings.Money.WithdrawLimit):
if not profit_usd >= self.instance.withdrawal_trigger:
# Not enough profit to withdraw
return
@@ -106,15 +105,16 @@ class AgoraClient(LocalPlatformClient, BaseClient):
send_cast = {
"address": None,
"amount": half_rounded,
"password": settings.Agora.Pass,
"password": self.instance.password,
"otp": otp_code.now(),
}
send_cast["address"] = settings.XMR.Wallet1
rtrn1 = await self.api.wallet_send_xmr(**send_cast)
return # TODO
# send_cast["address"] = settings.XMR.Wallet1
# rtrn1 = await self.api.wallet_send_xmr(**send_cast)
send_cast["address"] = settings.XMR.Wallet2
rtrn2 = await self.api.wallet_send_xmr(**send_cast)
# send_cast["address"] = settings.XMR.Wallet2
# rtrn2 = await self.api.wallet_send_xmr(**send_cast)
self.irc.sendmsg(f"Withdrawal: {rtrn1['success']} | {rtrn2['success']}")
self.ux.notify.notify_withdrawal(half_rounded)
# self.irc.sendmsg(f"Withdrawal: {rtrn1['success']} | {rtrn2['success']}")
# self.ux.notify.notify_withdrawal(half_rounded)