Polygon Arbitrage Bot
A bot that identifies arbitrage opportunities on Polygon using custom arithmetic algorithms.
Screenshots



Problem Statement
Arbitrage improves market efficiency and therefore increases the stability of AMMs. The project detects arbitrage opportunities by constantly monitoring on-chain transactions and calculating the best profitable trade from the information queried in the LP contracts.We calculate the best action to take based on the number of liquidities present in QuickSwap and SushiSwap on Polygon.Additionally, in order to not carry the risk of holding the underlying asset, which could pose a counterparty risk, we use AAVE's Flash Loans to provide the liquidity we need to fulfill the arbitrage opportunity.We have successfully written the first iteration of our monitoring platform and our v1 arbitrage algorithm. We have tested it on Polygon Mumbai and showed some success.
Solution
We used node.js to configure a list of token pairs that are shared between QuickSwap and SushiSwap.The arbitrage bot monitors each pair swap event in order to identify opportunities.When a pair is swapped, the software queries the pair's liquidity and price difference on the other exchange. If the price difference is large enough, an arithmetic algorithm executes and identifieswhether an opportunity has been found. If the profit margin estimate looks favorable, the bot will execute our custom smart contract to carry out a flash loan and swaps between exchanges.Ethers.js allows us to connect to a wallet with MATIC gas funds, and it also allows us to call functions on the Polygon/Mumbai networks. The smart contract created in Solidity and deployed with Remix/Hardhatallows us to take an uncollateralized loan with minimal monetary risk.
Hackathon
HackMoney 2021
2021