This bot will move over certain decentralized exchanges and mark the price of each pair of tokens. If the bot finds any profitable trading pair between two decentralized exchanges, it will trade for it and make the profit, only if the profit is above threshold value, otherwise it will continue to search for another trading pair.
git clone https://github.com/knackroot-technolabs-llp/DEX-Arbitrage.git
cd DEX-Arbitrage
mv .env-example.txt .env
rm .env-example.txt
npm install
npx hardhat run --network <your-network> scripts/deploy.js
These configurations should be in the json file under the config folder. This configuration file will contain the details of your trading contract, the dex’s you want to trade on, the tokens you want to trade on, and also the routes you want to follow while trading.
Deployed Contract address of Arb.sol solidity smart contract. This contract will be our trading contract or ARB contract.
Eg:
"arbContract": "0x64066c4DA5953B282508c6b620243b6Cc3cfC66C",
The minimum amount of profit you want to make on each trade. (Remember to use less value to perform more trade and earn higher profits. Can be greate than or equal to zero or less than or equal to 10000).
Here, 10000 means - 100% profit. 5000 means - 50% profit. 1000 means - 10% profit.
Keep the value accordingly.
Eg:
"minBasisPointsPerTrade": 0,
An array of decentralized exchanges router addresses on which you want to perform the trade. It takes an object with two values at each index of the array named “dex” - name of the dex and “address” - address of its router.
Eg:
"routers": [
{ "dex": "uniswap", "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" },
{ "dex": "sushiswap", "address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" }
],
Token address which you want to use to start and end the trade with. These tokens generally are stable tokens like WETH, USDC, etc. It contains an array with “sym” (symbol) and “address” (address of the token).
Eg:
"baseAssets": [
{ "sym": "WETH","address": "0xa4f08fcC97b3f41F9163667021AcfD73De982514" }
],
Token addresses on which you want to trade. These tokens are the tokens that can give you profit during the difference of prices in dexes. It contains an array with “sym” (symbol) and “address” (address of the token)
Eg:
"tokens": [
{"sym": "DAI", "address": "0xA94bE554Aa488a1aAA37C650bBB2d1170ED7F7c0" },
{"sym": "BTC", "address": "0xf7de2503483D227e724F48d6c3757e53A8baaF20" }
],
These are the array of paths that the bot can use to make the trade. It is an array of arrays with 4 parameters.
Eg:
"routes":[ ["0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506","0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D","0xa4f08fcC97b3f41F9163667021AcfD73De982514","0xA94bE554Aa488a1aAA37C650bBB2d1170ED7F7c0"],
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D","0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506","0xa4f08fcC97b3f41F9163667021AcfD73De982514","0xA94bE554Aa488a1aAA37C650bBB2d1170ED7F7c0"]
],
{
"arbContract": "0x64066c4DA5953B282508c6b620243b6Cc3cfC66C",
"minBasisPointsPerTrade": 0,
"routers": [
{ "dex": "uniswap", "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" },
{ "dex": "sushiswap", "address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" }
],
"baseAssets": [
{ "sym": "TK1","address": "0xa4f08fcC97b3f41F9163667021AcfD73De982514" }
],
"tokens": [
{"sym": "TK2", "address": "0xA94bE554Aa488a1aAA37C650bBB2d1170ED7F7c0" },
{"sym": "TK3", "address": "0xf7de2503483D227e724F48d6c3757e53A8baaF20" }
],
"routes": [
["0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506","0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D","0xa4f08fcC97b3f41F9163667021AcfD73De982514","0xA94bE554Aa488a1aAA37C650bBB2d1170ED7F7c0"],
["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D","0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506","0xa4f08fcC97b3f41F9163667021AcfD73De982514","0xA94bE554Aa488a1aAA37C650bBB2d1170ED7F7c0"]
]
}
npx hardhat run --network goerli ./scripts/fund.js
npx hardhat run --network goerli ./scripts/balances.js
npx hardhat run --network goerli ./scripts/trade.js
npx hardhat run --network goerli ./scripts/recover.js
Instatrade feature trades in the same interface between different tokens. It follows a triangular arbitrage bot method. Triangular arbitrage bot method makes the profit in the balance of BaseAsset by trading between two different tokens using one Stable coin.
Suppose you trade from ETH to DAI, DAI to USDT, USDT to SUSHI, and SUSHI to ETH again and you make a profit with this trading. Then the method is the Triangular Arbitrage Trading Method.
Transaction Flow is :
a. BaseAsset > Trading Token 1 (eg: ETH > DAI)
b. Trading Token1 > Stable Coin (eg: DAI > USDT)
c. Stable Coin > Trading Token 2 (eg: USDT > SUSHI)
d. Trading Token 2 > Base Asset (eg: SUSHI > ETH)
npx hardhat run --network <your-network> scripts/instadeploy.js
These configurations should be in the json file under the config folder. This configuration file will contain the details of your trading contract, the dex’s you want to trade on, the tokens you want to trade on, and also the routes you want to follow while trading.
Deployed Contract address of Arb.sol solidity smart contract. This contract will be our trading contract or ARB contract.
Eg:
"arbContract": "0x64066c4DA5953B282508c6b620243b6Cc3cfC66C",
The minimum amount of profit you want to make on each trade. (Remember to use less value to perform more trade and earn higher profits. Can be greate than or equal to zero or less than or equal to 10000).
Here, 10000 means - 100% profit. 5000 means - 50% profit. 1000 means - 10% profit.
Keep the value accordingly.
Eg:
"minBasisPointsPerTrade": 0,
An array of decentralized exchanges router addresses on which you want to perform the trade. It takes an object with two values at each index of the array named “dex” - name of the dex and “address” - address of its router.
Eg:
"routers": [
{ "dex": "uniswap", "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" },
{ "dex": "sushiswap", "address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" }
],
Token address which you want to use to start and end the trade with. These tokens generally are stable tokens like WETH, USDC, etc. It contains an array with “sym” (symbol) and “address” (address of the token).
Eg:
"baseAssets": [
{ "sym": "WETH","address": "0xa4f08fcC97b3f41F9163667021AcfD73De982514" }
],
Token address which you want to use as a mediator. These tokens generally are stable tokens like WETH, USDC, etc. It contains an array with “sym” (symbol) and “address” (address of the token).
Eg:
"stables": [
{ "sym": "WETH","address": "0xa4f08fcC97b3f41F9163667021AcfD73De982514" }
],
Token addresses on which you want to trade. These tokens are the tokens that can give you profit during the difference of liquidity in same dex. It contains an array with “sym” (symbol) and “address” (address of the token)
Eg:
"tokens": [
{"sym": "DAI", "address": "0xA94bE554Aa488a1aAA37C650bBB2d1170ED7F7c0" },
{"sym": "BTC", "address": "0xf7de2503483D227e724F48d6c3757e53A8baaF20" }
],
{
"arbContract": "0x64066c4DA5953B282508c6b620243b6Cc3cfC66C",
"minBasisPointsPerTrade": 0,
"routers": [
{ "dex": "uniswap", "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" },
{ "dex": "sushiswap", "address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" }
],
"baseAssets": [
{ "sym": "TK1","address": "0xa4f08fcC97b3f41F9163667021AcfD73De982514" }
],
"tokens": [
{"sym": "TK2", "address": "0xA94bE554Aa488a1aAA37C650bBB2d1170ED7F7c0" },
{"sym": "TK3", "address": "0xf7de2503483D227e724F48d6c3757e53A8baaF20" }
]
}
npx hardhat run --network goerli ./scripts/instatrade.js