Cairo implementation of the Shortest Path Faster algorithm.
The best way to understand the algorithm is to understand Bellman-Ford as a prerequisit:
https://www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/
and from there have a look at the improvements made to create the SPF algorithm:
https://www.geeksforgeeks.org/shortest-path-faster-algorithm/
The code is not actually a pure implementation of the SPF-algorithm as it has been adjusted to simulate it's usage as a solver within a DEX aggregator.
An assumption is being made that the highest liquidity pairing for every shitcoin is with one of 4 different tokens. On Ethereum mainnet these would be:
- ETH
- USDC
- DAI
- USDT
Therefore we only search for a route from Shitcoin1 via ETH/USDC/DAI/USDT to Shitcoin2
Install protostar:
curl -L https://raw.githubusercontent.com/software-mansion/protostar/master/install.sh | bash
then run:
prototstar test ./tests