From 0dcfaa2f343b3e844297c4bc8e60fce7a68b29b3 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 19 May 2025 09:23:55 +0000 Subject: [PATCH] swap: variable, method renames --- mmgen/swap/proto/thorchain/thornode.py | 12 ++++++------ mmgen/tx/bump.py | 2 +- mmgen/tx/new.py | 2 +- mmgen/tx/new_swap.py | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mmgen/swap/proto/thorchain/thornode.py b/mmgen/swap/proto/thorchain/thornode.py index 210e60bc..7490e08d 100755 --- a/mmgen/swap/proto/thorchain/thornode.py +++ b/mmgen/swap/proto/thorchain/thornode.py @@ -117,20 +117,20 @@ class Thornode: if trade_limit: from . import ExpInt4 - e = ExpInt4(trade_limit.to_unit('satoshi')) - tl_rounded = UniAmt(e.trunc, from_unit='satoshi') - ratio = usr_trade_limit if type(usr_trade_limit) is float else float(tl_rounded / out_amt) + tl_int = ExpInt4(trade_limit.to_unit('satoshi')) + tl_uniamt = UniAmt(tl_int.trunc, from_unit='satoshi') + ratio = usr_trade_limit if type(usr_trade_limit) is float else float(tl_uniamt / out_amt) direction = 'ABOVE' if ratio > 1 else 'below' mcolor, lblcolor = ( (redbg, redbg) if (ratio < 0.93 or ratio > 0.999) else (yelbg, yelbg) if ratio < 0.97 else (green, grnbg)) trade_limit_disp = f""" - {lblcolor('Trade limit:')} {tl_rounded.hl()} {out_coin} """ + mcolor( + {lblcolor('Trade limit:')} {tl_uniamt.hl()} {out_coin} """ + mcolor( f'({abs(1 - ratio) * 100:0.2f}% {direction} expected amount)') - tx_size_adj = len(e.enc) - 1 + tx_size_adj = len(tl_int.enc) - 1 if tx.proto.is_evm: - tx.adj_gas_with_extra_data_len(len(e.enc) - 1) # one-shot method, no-op if repeated + tx.adj_gas_with_extra_data_len(len(tl_int.enc) - 1) # one-shot method, no-op if repeated else: trade_limit_disp = '' tx_size_adj = 0 diff --git a/mmgen/tx/bump.py b/mmgen/tx/bump.py index a914e727..6553a313 100755 --- a/mmgen/tx/bump.py +++ b/mmgen/tx/bump.py @@ -87,7 +87,7 @@ class Bump(Completed, NewSwap): if self.is_swap: self.recv_proto = self.check_swap_memo().proto - self.process_swap_options() + self.init_swap_cfg() fee_hint = await self.update_vault_output(self.send_amt) else: fee_hint = None diff --git a/mmgen/tx/new.py b/mmgen/tx/new.py index 7838565c..ebdad932 100755 --- a/mmgen/tx/new.py +++ b/mmgen/tx/new.py @@ -453,7 +453,7 @@ class New(Base): cmd_args, addrfile_args = self.get_addrfiles_from_cmdline(cmd_args) if self.is_swap: cmd_args = await self.process_swap_cmdline_args(cmd_args, addrfile_args) - self.process_swap_options() + self.init_swap_cfg() from ..rpc import rpc_init self.rpc = await rpc_init(self.cfg, self.proto) from ..addrdata import TwAddrData diff --git a/mmgen/tx/new_swap.py b/mmgen/tx/new_swap.py index 5b7e10fb..a02f33d4 100755 --- a/mmgen/tx/new_swap.py +++ b/mmgen/tx/new_swap.py @@ -166,7 +166,7 @@ class NewSwap(New): [f'vault,{args.send_amt}', chg_output.mmid, f'data:{memo}'] if args.send_amt else ['vault', f'data:{memo}']) - def process_swap_options(self): + def init_swap_cfg(self): if s := self.cfg.trade_limit: self.usr_trade_limit = ( 1 - float(s[:-1]) / 100 if s.endswith('%') else @@ -199,10 +199,10 @@ class NewSwap(New): while True: self.cfg._util.qmsg(f'Retrieving data from {c.rpc.host}...') c.get_quote() - await self.set_gas(to_addr=c.router if self.is_token else None) - self.swap_quote_refresh_time = time.time() - trade_limit = get_trade_limit() self.cfg._util.qmsg('OK') + self.swap_quote_refresh_time = time.time() + await self.set_gas(to_addr=c.router if self.is_token else None) + trade_limit = get_trade_limit() msg(await c.format_quote(trade_limit, self.usr_trade_limit, deduct_est_fee=deduct_est_fee)) ch = get_char('Press ‘r’ to refresh quote, any other key to continue: ') msg('')