Browse Source

swap: variable, method renames

The MMGen Project 6 months ago
parent
commit
0dcfaa2f34
4 changed files with 11 additions and 11 deletions
  1. 6 6
      mmgen/swap/proto/thorchain/thornode.py
  2. 1 1
      mmgen/tx/bump.py
  3. 1 1
      mmgen/tx/new.py
  4. 3 3
      mmgen/tx/new_swap.py

+ 6 - 6
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

+ 1 - 1
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

+ 1 - 1
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

+ 3 - 3
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.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()
-			self.cfg._util.qmsg('OK')
 			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('')