added send gas back to seller

This commit is contained in:
Alexander 2024-07-30 17:46:36 -04:00
parent 30caa02e65
commit 0083d3603c

View file

@ -7,6 +7,7 @@ buy_with_amount_pls = 30000
slippage_percent = 5 slippage_percent = 5
wallet_a_min_pls = 20000 wallet_a_min_pls = 20000
wallet_b_min_pls = 100000 wallet_b_min_pls = 100000
wallet_c_min_pls = 20000
loop_delay = 3 loop_delay = 3
rapid_gas_fee_limit = 650000 rapid_gas_fee_limit = 650000
@ -39,6 +40,20 @@ while True:
else: else:
logging.info("Not enough PLS to send right now") 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 # check the current gas price
if get_beacon_gas_prices('rapid', beacon_gasnow_cache_seconds) > rapid_gas_fee_limit: if get_beacon_gas_prices('rapid', beacon_gasnow_cache_seconds) > rapid_gas_fee_limit:
logging.warning("Gas fees are too high") logging.warning("Gas fees are too high")