Create a .env file and add these variables POLYGON_RPC_URL = <your_rpc_url> , PRIVATE_KEY = <your_private_key>.
Note : If you don't have an RPC url then create one using this referal link of Alchemy. Also don't forget to add "0x" infront of your private key.
Now you can open a terminal in this directory and run this command to deploy:
npx hardhat run scripts/deploy.js --network polygon (You will get the contract address on the console, you can check the transaction here PolygonScan
Steps to Run the bot
npx hardhat run scripts/dualArb.js --network polygon (this script looks for arbitrage with only two assets for eg. X -> Y -> X)
npx hardhat run scripts/triArb.js --network polygon (this script looks for triangular arbitrage for eg. X -> Y -> Z -> X)
Customizing the settings
To change the pairs of tokens to find arbitrage in, you can go to the constants/polygon/tokens.js there you would find an array of name dualTokensList and triTokensList you can uncomment the pair of tokens you would like to get searched for arbitrage.
If you want to add new tokens, then add them to constants/polygon/addresses.js within the array with name KNOWN_TOKENS and also to the constants/polygon/tokens.js in the tokens object. Now after adding the token info at these two locations you can add the order of trading in the dualTokens or triTokensList in the same file.
If you want to change the amount used for arbitraging, then go the the utils/utilities.js file and change the amount in the toBorrow function it is currently set to 10000 USD and equivalent amounts for WMATIC, WETH, WBTC. Also after changing this you might want to update the profit percentage so change that inside the getBPS function (1 BPS is 0.01%, 10 BPS is 0.1%, 100BPS is 1%), you have to change the value of the amount which is passed as a parameter, you can also change the BPS value returned for that amount to any value you like.
Also you can increase/decrease the gas price by changing the gasPrice variable in the scripts/dualArb.js and scripts/triArb.js. Just search for gasPrice inside the file.