Trying to sell more than available
Closed this issue · 3 comments
Currently testing with a wallet that has 2949.984xxxx MTV in it. The issue may be in the floor function of a number.
Trying to sell all of it results in:
Selling 2,950.0 MTV...
⛔️ Exception while handling an update
{'code': -32000, 'message': 'insufficient funds for gas * price + value'}
Also entering smaller amount not working. Seems like the bot can't sell anymore I wonder if it's because of the UDST path:
Selling 2,950.0 MTV...
⛔️ Exception while handling an update
{'code': -32000, 'message': 'insufficient funds for gas * price + value'}
Selling 2,850.0 MTV...
⛔️ Exception while handling an update
{'code': -32000, 'message': 'insufficient funds for gas * price + value'}
OK, I will sell 2,800.0 MTV (~$64.38).
Confirm the order below!
✅ Order #1 was added successfully!
🔸 Trying to sell 2,800.0 MTV...
Not it hangs here and does nothing
/status bring this for orders:
💰 #1: MTV = market price - limit sell 2,800.0 MTV
This is the stack trace:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/app/pancaketrade/watchers/order.py", line 240, in sell
res, bnb_out, txhash_or_error = self.net.sell_tokens(
File "/app/pancaketrade/network/bsc.py", line 546, in sell_tokens
receipt = self.sell_tokens_with_params(
File "/app/pancaketrade/network/bsc.py", line 603, in sell_tokens_with_params
tx = self.build_and_send_tx(func=func, tx_params=params)
File "/app/pancaketrade/network/bsc.py", line 722, in build_and_send_tx
return self.w3.eth.send_raw_transaction(signed_tx.rawTransaction)
File "/app/.venv/lib/python3.9/site-packages/web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str, params, error_formatters)
File "/app/.venv/lib/python3.9/site-packages/web3/manager.py", line 160, in request_blocking
raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'insufficient funds for gas * price + value'}
How much BNB do you have for gas? It says right there "insufficient funds for gas * price + value". Gas is always paid in BNB.
I had around $2-5 for gas, but that was not the issue. I think there were too many threads created at some point. I deleted the pancake.db remove the container/image and set up all over again. It worked.
So, probably you can disregard this. It may be me misusing the bot somehow.
If you ever encounter such an issue again, it's never needed to delete the database file. Simply restarting the container should be fine. Removing the offending orders with the /removeorder
command should also help.
The message clearly indicated a problem with BNB balance for gas. My tests used $1.75 for transactions with this particular token using 15-25 gwei (default for "buy/sell now" and "sell all" commands respectively). But you need more to have some margin since the gas limit is higher than the actual used gas.