Browse Source

修复一些问题

skyfffire 4 months ago
parent
commit
89c3193346
4 changed files with 16 additions and 18 deletions
  1. 4 5
      as.py
  2. 7 6
      checker/mexc_to_erc20_checker.py
  3. 0 4
      s_mexc_to_erc20.py
  4. 5 3
      toto.readme

+ 4 - 5
as.py

@@ -169,6 +169,9 @@ def strategy_builder(process_item):
     global mexc_data
     global mexc_lock
 
+    process_item_formated = pformat(process_item, indent=2)
+    logger.info(f'策略原始参数:\n{process_item_formated}')
+
     if strategy == 'erc20_to_mexc':
         return s_erc20_to_mexc.ArbitrageProcess(gas_limit_multiplier, gas_price_multiplier, process_item, 
         core_data, core_lock,
@@ -182,8 +185,7 @@ def strategy_builder(process_item):
         mexc_data, mexc_lock
         )
     else:
-        process_item_formated = pformat(process_item, indent=2)
-        logger.error(f'不存在的策略:{strategy}\n{process_item_formated}')
+        logger.error(f'不存在的策略:{strategy}')
 
 # 實際套利邏輯
 def arbitrage_process_flow(process_item):
@@ -202,9 +204,6 @@ def arbitrage_process_flow(process_item):
     while ap.current_state != ap.STATE_COMPLETED and ap.current_state != ap.STATE_FAILED and ap.current_state != ap.STATE_REJECT:
         ap.run_arbitrage_step()
 
-        if ap.current_state == ap.STATE_WAITING_TRANSFER_ARRIVE or ap.current_state == ap.STATE_WAITING_WITHDRAWAL_CONFIRM:
-            time.sleep(10)
-
     ap.run_arbitrage_step()
 
     move_completed_process_to_history(process_id)

+ 7 - 6
checker/mexc_to_erc20_checker.py

@@ -172,7 +172,7 @@ def calculate_percentage_diff(sell_price, buy_price):
         return rst
     return None
 
-def send_arb_msg(profit_amount, chain_swap_data, human_out_base, chain_price, cex_price):
+def send_arb_msg(profit_amount, chain_swap_data, human_in_base, human_out_base, chain_price, cex_price):
     # chain_swap_data 是从 get_chain_price_vs_target_currency 返回的第二个值
     if not (chain_swap_data and chain_swap_data.get('data') and chain_swap_data['data']):
         logger.error(f"套利消息发送失败:链上交易数据不完整 {chain_swap_data}")
@@ -192,17 +192,17 @@ def send_arb_msg(profit_amount, chain_swap_data, human_out_base, chain_price, ce
 
     arbitrage_data = {
         "tx": tx, # 预签名交易
-        "profit": str(profit_amount.quantize(decimal.Decimal('0.001'))),
+        "profit": 5,
         "profitLimit": str(PROFIT_LIMIT.quantize(decimal.Decimal('0.001'))),
         "symbol": MEXC_TARGET_PAIR_USDT,
         "fromToken": IN_TOKEN_ADDRESS,
-        "fromTokenAmountHuman": str(human_out_base.quantize(decimal.Decimal(f'1e-{in_dec}'))),
+        "fromTokenAmountHuman": str(human_in_base.quantize(decimal.Decimal(f'1e-{in_dec}'))),
         "fromTokenDecimal": str(in_dec),
         "toToken": OUT_TOKEN_ADDRESS,
         "toTokenAmountHuman": str(human_out_base.quantize(decimal.Decimal(f'1e-{out_dec}'))),
         "toTokenDecimal": str(out_dec),
-        "chainPrice", str(chain_price),
-        "cexPrice", str(cex_price),
+        "chainPrice": str(chain_price),
+        "cexPrice": str(cex_price),
         "strategy": STRATEGY,
     }
 
@@ -269,7 +269,8 @@ def update_data_for_plotly_and_table():
         global mode
         if actual_profit_usdt is not None and actual_profit_usdt > PROFIT_LIMIT + 3 and mode == 'trade':
             if chain_swap_full_response: # 确保有完整的链上数据
-                send_arb_msg(actual_profit_usdt, chain_swap_full_response, human_out_base, chain_price, cex_price)
+                human_in_base = IN_AMOUNT_TO_QUERY
+                send_arb_msg(actual_profit_usdt, chain_swap_full_response, human_in_base, human_out_base, chain_price, cex_price)
             else:
                 logger.warning("利润满足但链上数据不完整,无法发送套利消息。")
 

+ 0 - 4
s_mexc_to_erc20.py

@@ -106,7 +106,6 @@ class ArbitrageProcess:
             "SELLING_ON_CHAIN",             # 正在链上卖出
             "WAITING_CHAIN_CONFIRM",        # 等待链上交易确认
             "WAITING_EXCHANGE_ROLLBACK",    # 等待交易所回滚
-            # "WAITING_TRANSFER_ARRIVE",      # 等待交易所充值到账
             "TRANSFERRING_TO_CHAIN",        # 正在向链上转账
             "WAITING_WITHDRAWAL_CONFIRM",   # 等待链上提现确认
             "COMPLETED",                    # 套利流程完成
@@ -164,9 +163,6 @@ class ArbitrageProcess:
         elif self.current_state == self.STATE_WAITING_EXCHANGE_ROLLBACK:
             self._wait_exchange_rollback()
 
-        elif self.current_state == self.STATE_WAITING_TRANSFER_ARRIVE:
-            self._wait_transfer_arrive()
-
         elif self.current_state == self.STATE_TRANSFERRING_TO_CHAIN:
              self._execute_transfer_to_chain()
 

+ 5 - 3
toto.readme

@@ -50,9 +50,11 @@
 [-] 备用节点广播
 
 2025-06-26
-[ ] 另一個方向
+[-] 另一個方向
 
-有時間再做
-[-] zeus昨晚上有一个状态识别bug,导致单边(因为精度问题导致)
+2025-06-27
 [ ] approve自動
 [ ] 交易所价格、数量精度
+
+有時間再做
+[-] zeus昨晚上有一个状态识别bug,导致单边(因为精度问题导致)