Arbitrage path detection in js