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