Код: Выделить всё
from web3 import Account, Web3
from abi import UNISWAP_V3_ROUTER2_ABI, WETH9_ABI, MIN_ERC20_ABI
import eth_abi.packed
private_key = "pppppppppppppppppppppppppppppppppppppppppp"
chain_id = 42161
rpc_endpoint = "https://arb1.arbitrum.io/rpc"
web3 = Web3(Web3.HTTPProvider(rpc_endpoint))
account = Account.from_key(private_key)
total_gas_used_buy = 0
amount_in = 0.00000004
weth_address = web3.to_checksum_address("0x35751007a407ca6feffe80b3cb397736d2cf4dbe")
usdc_address = web3.to_checksum_address("0xaf88d065e77c8cc2239327c5edb3a432268e5831")
swap_router02_address = web3.to_checksum_address("0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45")
# load contracts
swap_router_contract = web3.eth.contract(address=swap_router02_address, abi=UNISWAP_V3_ROUTER2_ABI)
weth_contract = web3.eth.contract(address=weth_address, abi=WETH9_ABI)
usdc_contract = web3.eth.contract(address=usdc_address, abi=MIN_ERC20_ABI)
# swap
path = eth_abi.packed.encode_packed(['address','uint24','address'], [weth_address,500,usdc_address])
tx_params = (
path,
account.address,
amount_in, # amount in
0 #min amount out
)
swap_buy_tx = swap_router_contract.functions.exactInput(tx_params).build_transaction(
{
'from': account.address,
'gas': 500000,
"maxPriorityFeePerGas": web3.eth.max_priority_fee,
"maxFeePerGas": 15000000,
'nonce': web3.eth.get_transaction_count(account.address),
})
web3.Exceptions.Web3ValidationError:
Код: Выделить всё
Could not identify the intended function with name \`exactInput\`, positional arguments with type(s) \`(bytes,address,float,int)\` and keyword arguments with type(s) \`{}\`.
Found 1 function(s) with the name \`exactInput\`: \['exactInput((bytes,address,uint256,uint256))'\]
Function invocation failed due to no matching argument types.
Подробнее здесь: https://stackoverflow.com/questions/786 ... n-failed-d