Răsfoiți Sursa

改用名詞

skyfffire 5 luni în urmă
părinte
comite
9a9778afa5
1 a modificat fișierele cu 24 adăugiri și 24 ștergeri
  1. 24 24
      erc20_to_mexc_first_sell.py

+ 24 - 24
erc20_to_mexc_first_sell.py

@@ -53,8 +53,8 @@ class ArbitrageProcess:
         self.chain_buy_amount = Decimal(0)                                      # 链上币增加量(购入量), todo, 暂用即时余额代替
         self.exchange_sell_amount = Decimal(process_item['exchangeOutAmount']), # 交易所卖出量
         self.exchange_sell_order_id = None                                      # 交易所卖出id
-        self.exchange_withdraw_id = None                                        # 交易所提现id
-        self.exchange_withdraw_amount = None                                    # 交易所提现数量
+        self.exchange_withdrawal_id = None                                        # 交易所提现id
+        self.exchange_withdrawal_amount = None                                    # 交易所提现数量
 
         # 定义可能的状态
         self.STATES = [
@@ -139,7 +139,7 @@ class ArbitrageProcess:
              self._execute_transfer_to_chain()
 
         elif self.current_state == self.STATE_WAITING_WITHDRAWAL_CONFIRM:
-             self._wait_withdraw_confirm()
+             self._wait_withdrawal_confirm()
 
         elif self.current_state == self.STATE_COMPLETED:
             msg = "套利流程成功完成!"
@@ -305,7 +305,7 @@ class ArbitrageProcess:
                     logging.info(msg)
                     add_state_flow_entry(self.process_item, self.current_state, msg, "success")
 
-                    self.exchange_withdraw_amount = order['cummulativeQuoteQty']
+                    self.exchange_withdrawal_amount = order['cummulativeQuoteQty']
 
                     self._set_state(self.STATE_BUYING_ON_CHAIN)
                     return
@@ -412,7 +412,7 @@ class ArbitrageProcess:
         add_state_flow_entry(self.process_item, self.current_state, msg, "pending")
         try:
             # 使用预提现数量进行回滚
-            pseudo_amount_to_buy = Decimal(self.exchange_withdraw_amount)
+            pseudo_amount_to_buy = Decimal(self.exchange_withdrawal_amount)
             # 处理精度
             pseudo_amount_to_buy = pseudo_amount_to_buy.quantize(Decimal('1'), rounding=ROUND_DOWN)
 
@@ -611,23 +611,23 @@ class ArbitrageProcess:
                 # balances = mexc.trade.get_account_info()['balances']
                 # for balance in balances:
                 #     if balance['asset'] == 'USDT':
-            pseudo_withdraw_amount = str(int(float(self.exchange_withdraw_amount)))
+            pseudo_withdrawal_amount = str(int(float(self.exchange_withdrawal_amount)))
 
-            withdraw_params = {
+            withdrawal_params = {
                 'coin': 'USDT',
                 'netWork': 'ETH',
                 'address': self.user_wallet,
-                'amount': pseudo_withdraw_amount
+                'amount': pseudo_withdrawal_amount
             }
-            withdraw_rst = mexc.wallet.post_withdraw(withdraw_params)
-            if "id" not in withdraw_rst:
+            withdrawal_rst = mexc.wallet.post_withdrawal(withdrawal_params)
+            if "id" not in withdrawal_rst:
                 logging.error(f"提现失败")
-                logging.error(withdraw_params)
-                logging.error(withdraw_rst)
+                logging.error(withdrawal_params)
+                logging.error(withdrawal_rst)
 
-            self.exchange_withdraw_id = withdraw_rst["id"]
+            self.exchange_withdrawal_id = withdrawal_rst["id"]
 
-            msg = f"交易所提现已发送, 提现ID: {self.exchange_withdraw_id}"
+            msg = f"交易所提现已发送, 提现ID: {self.exchange_withdrawal_id}"
             logging.info(msg)
             add_state_flow_entry(self.process_item, self.current_state, msg, "success")
 
@@ -640,13 +640,13 @@ class ArbitrageProcess:
 
             self._set_state("FAILED")
 
-    def _wait_withdraw_confirm(self):
+    def _wait_withdrawal_confirm(self):
         """
         等待交易所提现到链上确认
         """
-        exchange_withdraw_id = self.exchange_withdraw_id
+        exchange_withdrawal_id = self.exchange_withdrawal_id
 
-        msg = f"等待交易所提现确认:{exchange_withdraw_id}"
+        msg = f"等待交易所提现确认:{exchange_withdrawal_id}"
         logging.info(msg)
         add_state_flow_entry(self.process_item, self.current_state, msg, "pending")
         try:
@@ -656,23 +656,23 @@ class ArbitrageProcess:
             waiting_times = 60
             last_deposit_state = None
             while waiting_times > 0:
-                withdraw_list = mexc.wallet.get_withdraw_list()
+                withdrawal_list = mexc.wallet.get_withdrawal_list()
 
-                if not isinstance(withdraw_list, list):
-                    msg = f"查询交易所提现状态时发生错误:{withdraw_list}"
+                if not isinstance(withdrawal_list, list):
+                    msg = f"查询交易所提现状态时发生错误:{withdrawal_list}"
                     logging.error(msg)
                     add_state_flow_entry(self.process_item, self.current_state, msg, "fail")
 
                     self._set_state("FAILED")
                     return
 
-                for withdraw in withdraw_list:
-                    if withdraw['id'] != exchange_withdraw_id:
+                for withdrawal in withdrawal_list:
+                    if withdrawal['id'] != exchange_withdrawal_id:
                         continue
 
-                    last_deposit_state = withdraw
+                    last_deposit_state = withdrawal
 
-                    if withdraw['status'] == 7:
+                    if withdrawal['status'] == 7:
                         is_arrived = True
 
                 if is_arrived: