tradingstrategy-ai/web3-ethereum-defi

BSC and "the method eth_feeHistory does not exist/is not available"

miohtama opened this issue · 0 comments

web3.py does not get BSC fee automatically

Full traceback:

root                                               ERROR    {'code': -32601, 'message': 'the method eth_feeHistory does not exist/is not available'}
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/eth.py", line 631, in max_priority_fee
    return self._max_priority_fee()
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/manager.py", line 198, in request_blocking
    return self.formatted_response(response,
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/manager.py", line 171, in formatted_response
    raise ValueError(response["error"])
ValueError: {'code': -32601, 'message': 'the method eth_maxPriorityFeePerGas does not exist/is not available'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/trade-executor/trade-executor/tradeexecutor/cli/main.py", line 168, in start
    run_main_loop(
  File "/root/trade-executor/trade-executor/tradeexecutor/cli/loop.py", line 141, in run_main_loop
    runner.tick(ts, universe, state, debug_details)
  File "/root/trade-executor/trade-executor/tradeexecutor/strategy/runner.py", line 116, in tick
    self.execution_model.execute_trades(clock, state, approved_trades)
  File "/root/trade-executor/trade-executor/tradeexecutor/ethereum/uniswap_v2_execution.py", line 73, in execute_trades
    approvals = approve_tokens(
  File "/root/trade-executor/trade-executor/tradeexecutor/ethereum/execution.py", line 180, in approve_tokens
    tx = token.functions.approve(
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/contract.py", line 1079, in buildTransaction
    return build_transaction_for_function(
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/contract.py", line 1648, in build_transaction_for_function
    prepared_transaction = fill_transaction_defaults(web3, prepared_transaction)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/_utils/transactions.py", line 114, in fill_transaction_defaults
    default_val = default_getter(web3, transaction)
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/_utils/transactions.py", line 64, in <lambda>
    web3.eth.max_priority_fee + (2 * web3.eth.get_block('latest')['baseFeePerGas'])
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/eth.py", line 637, in max_priority_fee
    return fee_history_priority_fee(self)
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/_utils/fee_utils.py", line 45, in fee_history_priority_fee
    fee_history = eth.fee_history(*PRIORITY_FEE_HISTORY_PARAMS)  # type: ignore
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/eth.py", line 863, in fee_history
    return self._fee_history(block_count, newest_block, reward_percentiles)
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/manager.py", line 198, in request_blocking
    return self.formatted_response(response,
  File "/root/.cache/pypoetry/virtualenvs/tradeexecutor-B9xoSur2-py3.9/lib/python3.9/site-packages/web3/manager.py", line 171, in formatted_response
    raise ValueError(response["error"])
ValueError: {'code': -32601, 'message': 'the method eth_feeHistory does not exist/is not available'}