fixed buyer/seller empty estimated swap result

This commit is contained in:
Alexander 2024-07-12 06:53:51 -04:00
parent 679ad53691
commit e9db8565cc
2 changed files with 41 additions and 31 deletions

View file

@ -3,11 +3,11 @@ from core import *
# set config variables # set config variables
buy_percent_diff_pdai = 20 buy_percent_diff_pdai = 20
buy_percent_diff_pusdc = 30 buy_percent_diff_pusdc = 30
buy_with_amount_pls = 10000 buy_with_amount_pls = 30000
slippage_percent = 5 slippage_percent = 5
wallet_min_pls = 20000 wallet_min_pls = 20000
loop_delay = 3 loop_delay = 3
rapid_gas_fee_limit = 650000 rapid_gas_fee_limit = 777777
# load wallet A and set address for logging # load wallet A and set address for logging
set_logging(wallet_a_address, 'INFO') set_logging(wallet_a_address, 'INFO')
@ -74,15 +74,18 @@ while True:
pdai_address, pdai_address,
buy_with_amount_pls buy_with_amount_pls
) )
# broadcast swap pls for pdai if estimated_swap_result:
if swap_tokens( # broadcast swap pls for pdai
account, if swap_tokens(
'PulseX_v2', account,
[wpls_address, pdai_address], 'PulseX_v2',
estimated_swap_result, [wpls_address, pdai_address],
slippage_percent estimated_swap_result,
): slippage_percent
logging.info("Swapped {} PLS to pDAI".format(buy_with_amount_pls)) ):
logging.info("Swapped {} PLS to pDAI".format(buy_with_amount_pls))
else:
logging.warning("No estimated swap result data")
else: else:
logging.info("pDAI is not within range to buy yet ({}%)".format(buy_percent_diff_pdai)) logging.info("pDAI is not within range to buy yet ({}%)".format(buy_percent_diff_pdai))
else: else:
@ -102,15 +105,18 @@ while True:
pusdc_address, pusdc_address,
buy_with_amount_pls buy_with_amount_pls
) )
# broadcast swap pls for pusdc if estimated_swap_result:
if swap_tokens( # broadcast swap pls for pusdc
account, if swap_tokens(
'PulseX_v2', account,
[wpls_address, pusdc_address], 'PulseX_v2',
estimated_swap_result, [wpls_address, pusdc_address],
slippage_percent estimated_swap_result,
): slippage_percent
logging.info("Swapped {} PLS to pUSDC".format(buy_with_amount_pls)) ):
logging.info("Swapped {} PLS to pUSDC".format(buy_with_amount_pls))
else:
logging.warning("No estimated swap result data")
else: else:
logging.info("pUSDC is not within range to buy yet ({}%)".format(buy_percent_diff_pusdc)) logging.info("pUSDC is not within range to buy yet ({}%)".format(buy_percent_diff_pusdc))
else: else:

View file

@ -2,12 +2,12 @@ from core import *
# set config variables # set config variables
sell_percent_diff_affection = 0 sell_percent_diff_affection = 0
sell_with_amount_affection = 200 sell_with_amount_affection = 500
slippage_percent = 5 slippage_percent = 5
wallet_min_pls = 20000 wallet_min_pls = 20000
loop_delay = 3 loop_delay = 3
loop_sell_delay = 10 loop_sell_delay = 10
rapid_gas_fee_limit = 650000 rapid_gas_fee_limit = 777777
# load wallet C and set address for logging # load wallet C and set address for logging
set_logging(wallet_c_address, 'INFO') set_logging(wallet_c_address, 'INFO')
@ -31,7 +31,7 @@ while True:
# send pls back to wallet a for buying # send pls back to wallet a for buying
pls_balance = get_pls_balance(account.address, False) pls_balance = get_pls_balance(account.address, False)
pls_balance -= wallet_min_pls pls_balance -= wallet_min_pls
# send the minter 1/4 # send the minter 1/3
send_to_wallet_b = float(round(pls_balance / 4, 2)) send_to_wallet_b = float(round(pls_balance / 4, 2))
# send the rest to buyer # send the rest to buyer
send_to_wallet_a = float(round(pls_balance - send_to_wallet_b, 2)) send_to_wallet_a = float(round(pls_balance - send_to_wallet_b, 2))
@ -82,14 +82,18 @@ while True:
wpls_address, wpls_address,
amount amount
) )
if swap_tokens( if estimated_swap_result:
account, if swap_tokens(
'PulseX_v2', account,
[affection_address, wpls_address], 'PulseX_v2',
estimated_swap_result, [affection_address, wpls_address],
slippage_percent estimated_swap_result,
): slippage_percent
logging.info("Swapped {} AFFECTION™ to PLS".format(amount)) ):
logging.info("Swapped {} AFFECTION™ to PLS".format(amount))
else:
logging.warning("No estimated swap result from RPC")
break
# delay if amounts remain in the list # delay if amounts remain in the list
if i + 1 != len(selling_amounts): if i + 1 != len(selling_amounts):
logging.info("Waiting for {} seconds...".format(loop_sell_delay)) logging.info("Waiting for {} seconds...".format(loop_sell_delay))