From 0083d3603cd9c537b86571e4d8caefed93bcb7be Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 30 Jul 2024 17:46:36 -0400 Subject: [PATCH] added send gas back to seller --- bot-buyer.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bot-buyer.py b/bot-buyer.py index 966f687..43f332b 100755 --- a/bot-buyer.py +++ b/bot-buyer.py @@ -7,6 +7,7 @@ buy_with_amount_pls = 30000 slippage_percent = 5 wallet_a_min_pls = 20000 wallet_b_min_pls = 100000 +wallet_c_min_pls = 20000 loop_delay = 3 rapid_gas_fee_limit = 650000 @@ -39,6 +40,20 @@ while True: else: logging.info("Not enough PLS to send right now") + # check if wallet c has a minimum amount of pls and send some back for selling + pls_balance_c = get_pls_balance(wallet_c_address) + if pls_balance_c - wallet_c_min_pls < 0: + send_to_wallet_c = math.ceil(wallet_c_min_pls - pls_balance_c) + logging.info("Seller needs {} PLS".format(send_to_wallet_c)) + # check if sending pls to wallet c leaves wallet a with enough left over + if send_to_wallet_c < (pls_balance_a - wallet_a_min_pls): + if send_pls(account, wallet_c_address, send_to_wallet_c): + logging.info("Sent {} PLS to {}".format(send_to_wallet_c, wallet_c_address)) + else: + logging.warning("Failed to send {} PLS to {}".format(send_to_wallet_c, wallet_c_address)) + else: + logging.info("Not enough PLS to send right now") + # check the current gas price if get_beacon_gas_prices('rapid', beacon_gasnow_cache_seconds) > rapid_gas_fee_limit: logging.warning("Gas fees are too high")