瀏覽代碼

[important] 刪除流程中的提現部分。

skyfffire 5 月之前
父節點
當前提交
5cb04ae030
共有 1 個文件被更改,包括 1 次插入215 次删除
  1. 1 215
      erc20_to_mexc.py

+ 1 - 215
erc20_to_mexc.py

@@ -581,7 +581,7 @@ class ArbitrageProcess:
                 logger.info(msg)
                 add_state_flow_entry(self.process_item, self.current_state, msg, "success")
 
-                self._set_state(self.STATE_WAITING_TRANSFER_ARRIVE)
+                self._set_state(self.STATE_COMPLETED)
 
                 break
             
@@ -703,220 +703,6 @@ class ArbitrageProcess:
 
             traceback.print_exc()
 
-    def _wait_transfer_arrive(self):
-        """
-        等待资产在交易所内到账
-        """
-        msg = f"等待资产在交易所到账..."
-        logger.info(msg)
-        add_state_flow_entry(self.process_item, self.current_state, msg, "pending")
-
-        try:
-            is_arrived = False
-
-            # 先進行快速提現判斷,如果不滿足條件就走後面的等待充值模式,雙模,這個步驟最多等待10分鐘
-            waiting_times = 10
-            last_deposit_state = None
-            while waiting_times > 0:
-                time.sleep(60)
-                with self.mexc_lock:
-                    deposit_list = copy.deepcopy(self.mexc_data['deposit_list'])
-
-                # 是否已經在列表中了,抹茶識別充值會稍微有點慢,所以要耐心等
-                is_list = False
-                # pending中的數量
-                pending_amount = Decimal(0)
-                for deposit in deposit_list:
-                    # 不屬于該路徑需要監聽的代幣
-                    if deposit['coin'] != self.coin:
-                        continue
-
-                    # 處理pending數量
-                    if Decimal(deposit['confirmTimes']) < Decimal(deposit['unlockConfirm']):
-                        pending_amount = pending_amount + Decimal(deposit['amount'])
-
-                    # 檢查到沒到列表中
-                    if deposit['transHash'] != self.chain_tx_hash:
-                        continue
-                    last_deposit_state = deposit
-                    is_list = True
-                
-                # 檢查是否滿足快速提現的條件
-                if is_list:
-                    # 交易所代幣余额判断
-                    with self.mexc_lock:
-                        balances = copy.deepcopy(self.mexc_data['account_info']['balances'])
-                    asset_balance = 0
-                    for balance in balances:
-                        if balance['asset'] == self.coin:
-                            asset_balance = Decimal(balance['free'])
-
-                    # 交易所賣出餘額
-                    exchange_sell_amount = self.exchange_sell_amount
-                    
-                    # 最終判斷
-                    if exchange_sell_amount + asset_balance > pending_amount:
-                        last_deposit_state_formated = pformat(last_deposit_state, indent=2)
-                        msg = f"【flash】资产可以進行快速提現。\n{last_deposit_state_formated}"
-                        logger.info(msg)
-                        add_state_flow_entry(self.process_item, self.current_state, msg, "success")
-
-                        self._set_state(self.STATE_TRANSFERRING_TO_CHAIN)
-                        return
-                    else:
-                        logger.info(f"exchange_sell_amount{exchange_sell_amount}, asset_balance{asset_balance}, pending_amount{pending_amount}")
-                
-                logger.info(f"正在檢查快速提現條件...({waiting_times}/10)")
-                waiting_times = waiting_times - 1
-
-            # 最多等待30分钟
-            waiting_times = 30
-            last_deposit_state = None
-            last_deposit_state_formated = None
-            while waiting_times > 0:
-                with self.mexc_lock:
-                    deposit_list = copy.deepcopy(self.mexc_data['deposit_list'])
-                for deposit in deposit_list:
-                    if deposit['transHash'] != self.chain_tx_hash:
-                        continue
-
-                    last_deposit_state = deposit
-                    last_deposit_state_formated = pformat(last_deposit_state, indent=2)
-
-                    logger.info(f"等待资产在交易所到账...({deposit['confirmTimes']}/{deposit['unlockConfirm']})")
-                    if Decimal(deposit['confirmTimes']) >= Decimal(deposit['unlockConfirm']):
-                        is_arrived = True
-
-                if is_arrived:
-                    
-                    msg = f"资产已在交易所到账。\n{last_deposit_state_formated}"
-                    logger.info(msg)
-                    add_state_flow_entry(self.process_item, self.current_state, msg, "success")
-
-                    self._set_state(self.STATE_TRANSFERRING_TO_CHAIN)
-                    return
-                
-                time.sleep(60)
-                waiting_times = waiting_times - 1
-
-            msg = f"等待充值到账超时(超过30分钟)。\n{last_deposit_state_formated}"
-            logger.error(msg)
-            add_state_flow_entry(self.process_item, self.current_state, msg, "fail")
-
-            self._set_state(self.STATE_FAILED)
-        except Exception as e:
-            msg = f"查询交易所到账状态时发生错误:{e}"
-            logger.error(msg)
-            add_state_flow_entry(self.process_item, self.current_state, msg, "fail")
-
-            self._set_state(self.STATE_FAILED)
-
-            traceback.print_exc()
-
-    def _execute_transfer_to_chain(self):
-        """
-        将交易后获得的计价资产(例如USDT)转账回链上
-        """
-        msg = "执行:交易所计价资产转账回链上..."
-        logger.info(msg)
-        add_state_flow_entry(self.process_item, self.current_state, msg, "pending")
-
-        try:
-            pseudo_withdrawal_amount = str(int(float(self.exchange_withdrawal_amount)))
-
-            withdrawal_params = {
-                'coin': 'USDT',
-                'netWork': 'ETH',
-                'address': self.user_wallet,
-                'amount': pseudo_withdrawal_amount
-            }
-            withdrawal_params_formated = pformat(withdrawal_params, indent=2)
-            withdrawal_rst = mexc.wallet.post_withdraw(withdrawal_params)
-            withdrawal_rst_formated = pformat(withdrawal_rst, indent=2)
-            if "id" not in withdrawal_rst:
-                msg = f"交易所提现失败\n參數: {withdrawal_params_formated}\n響應: {withdrawal_rst_formated}"
-                logger.error(msg)
-                add_state_flow_entry(self.process_item, self.current_state, msg, "fail")
-
-                self._set_state(self.STATE_FAILED)
-            else:
-                self.exchange_withdrawal_id = withdrawal_rst["id"]
-                msg = f"交易所提现已发送\n{withdrawal_rst_formated}"
-                logger.info(msg)
-                add_state_flow_entry(self.process_item, self.current_state, msg, "success")
-
-                self._set_state(self.STATE_WAITING_WITHDRAWAL_CONFIRM)
-        except Exception as e:
-            msg = f"转账回链上失败: {e}"
-            logger.error(msg)
-            add_state_flow_entry(self.process_item, self.current_state, msg, "fail")
-
-            self._set_state(self.STATE_FAILED)
-
-            traceback.print_exc()
-
-    def _wait_withdrawal_confirm(self):
-        """
-        等待交易所提现到链上确认
-        """
-        exchange_withdrawal_id = self.exchange_withdrawal_id
-
-        msg = f"等待交易所提现确认:{exchange_withdrawal_id}"
-        logger.info(msg)
-        add_state_flow_entry(self.process_item, self.current_state, msg, "pending")
-        try:
-            is_arrived = False
-
-            # 最多等待30分钟
-            waiting_times = 60
-            last_deposit_state = None
-            last_deposit_state_formated = None
-            while waiting_times > 0:
-                with self.mexc_lock:
-                    withdraw_list = copy.deepcopy(self.mexc_data['withdraw_list'])
-
-                if not isinstance(withdraw_list, list):
-                    msg = f"查询交易所提现状态时发生错误:{withdraw_list}"
-                    logger.error(msg)
-                    add_state_flow_entry(self.process_item, self.current_state, msg, "fail")
-
-                    self._set_state("FAILED")
-                    return
-
-                for withdrawal in withdraw_list:
-                    if withdrawal['id'] != exchange_withdrawal_id:
-                        continue
-
-                    last_deposit_state = withdrawal
-                    last_deposit_state_formated = pformat(last_deposit_state, indent=2)
-
-                    if withdrawal['status'] == 7:
-                        is_arrived = True
-
-                if is_arrived:
-                    msg = f"提现请求已上链:\n{last_deposit_state_formated}"
-                    logger.info(msg)
-                    add_state_flow_entry(self.process_item, self.current_state, msg, "success")
-
-                    self._set_state(self.STATE_COMPLETED)
-                    return
-                
-                time.sleep(30)
-                waiting_times = waiting_times - 1
-
-            msg = f"等待提现到账超时(超过30分钟):\n{last_deposit_state_formated}"
-            logger.error(msg)
-            add_state_flow_entry(self.process_item, self.current_state, msg, "fail")
-
-            self._set_state(self.STATE_FAILED)
-        except Exception as e:
-            msg = f"查询交易所提现状态时发生错误:{e}"
-            logger.error(msg)
-            add_state_flow_entry(self.process_item, self.current_state, msg, "fail")
-            self._set_state(self.STATE_FAILED)
-
-            traceback.print_exc()
-
 # 伪代码示例:如何使用这个类
 if __name__ == "__main__":
     import ok_chain_client