I have seen many bots perform multi-hop swaps to get the best arbitrage opportunity. So how do they find a such best path & exchange for their multi-hop swaps which gives the best returns? For eg Pancakeswap achieves multihop using Uniswap v3 router. So how does it do that?
For the most part it's likely private, proprietary code that finds deep (multi-hop) arbitrage opportunities in efficient ways. There is probably also a bit of people leeching from services like Matcha and 1inch which are good at finding efficient ways between assets, sometimes showing arbitrage opportunities