To perform an automated 1 inch transaction I use these two functions. It works well at first. Unfortunately, in the last few days I have always had the same errors:
Fail with error 'Return amount is not enough'
Warning! Error encountered during contract execution [Reverted]
def get_api_call_data(_from_coin,_to_coin): global api_data try: call_data = requests.get( f'https://api.1inch.exchange/v1.1/swap?fromTokenSymbol={_from_coin}&toTokenSymbol={_to_coin}&amount={_amount_to_exchange}&fromAddress={base_account}&slippage={slippage}&disableEstimate=true') api_data = call_data.json() except: logging.exception("get_api_call_data") return api_data def one_inch_token_swap(_from_coin,_to_coin): global tx_hash web3 = Web3(Web3.HTTPProvider(eth_provider_url)) nonce = web3.eth.getTransactionCount(base_account) json_data = get_api_call_data(_from_coin,_to_coin) data = json_data['data'] to = json_data['to'] value = _amount_to_exchange url_fees = 'https://ethgasstation.info/api/ethgasAPI.json?' r_fees = requests.get(url_fees) js_fees = json.loads(r_fees.content) Fastest = js_fees['fastest'] tx = { 'nonce': nonce, 'to': to, 'value': _amount_to_exchange, 'gasPrice':(Fastest+100)*(100000000), 'from': base_account, 'data': data, } gas = web3.eth.estimateGas(tx) tx["gas"] = gas signed_tx = web3.eth.account.signTransaction(tx, private_key) tx_hash = web3.eth.sendRawTransaction(signed_tx.rawTransaction)
what could be the cause of this error?