I'm trying to programically use RouteProcessor smart contract by Sushi Swap. Here you can see contract https://etherscan.io/address/0xF70c086618dcf2b1A461311275e00D6B722ef914. I gathered information about all parameters but could not find any description about how to determine route parameter. So how do you generate route?
Thanks for any help.
This is a code that i try to run to swap ETH -> ARB in Arbitrum Nova chain.
from eth_abi import encode
from web3 import Web3
arbitrum_nova_rpc_url = 'https://nova.arbitrum.io/rpc'
wallet_address = '<your address here>'
route_processor_abi = '[{"inputs":[{"internalType":"address","name":"_bentoBox","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"bentoBox","outputs":[{"internalType":"contract IBentoBoxMinimal","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"route","type":"bytes"}],"name":"processRoute","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address payable","name":"transferValueTo","type":"address"},{"internalType":"uint256","name":"amountValueTransfer","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"route","type":"bytes"}],"name":"transferValueAndprocessRoute","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]'
route_processor_arbitrum_nova_address = '0xaB235da7f52d35fb4551AfBa11BFB56e18774A65'
# Generate route here
arbitrum_nova_ether_address = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
arbitrum_nova_weth_address = '0x722E8BdD2ce80A4422E880164f2079488e115365'
arbitrum_nova_arbitrum_address = '0xf823C3cD3CeBE0a1fA952ba88Dc9EEf8e0Bf46AD'
byte_ether_address = encode(['address'], [web3.to_checksum_address(arbitrum_nova_ether_address)])
byte_weth_address = encode(['address'], [web3.to_checksum_address(arbitrum_nova_weth_address)])
byte_arb_address = encode(['address'], [web3.to_checksum_address(arbitrum_nova_arbitrum_address)])
route = byte_ether_address + byte_weth_address + byte_arb_address
web3 = Web3(Web3.HTTPProvider(arbitrum_nova_rpc_url))
contract = web3.eth.contract(
address=route_processor_arbitrum_nova_address,
abi=route_processor_abi
)
tx = contract.functions.processRoute(
web3.to_checksum_address(arbitrum_nova_ether_address), # token in
web3.to_wei(0.0001, 'ether'), # amount in
web3.to_checksum_address(arbitrum_nova_arbitrum_address), # token out
0, # amount out min
web3.to_checksum_address(address), # to address
route # route
)
tx.build_transaction({
"nonce": web3.eth.get_transaction_count(address),
"value": 0
})