Skip to content

Commit

Permalink
Merge pull request #28 from rainprotocol/2023-09-15-fix-tx-submitting
Browse files Browse the repository at this point in the history
fix tx submitting handling
  • Loading branch information
Siddharth2207 authored Sep 16, 2023
2 parents e1cb1fa + f0f3623 commit edd5155
Show file tree
Hide file tree
Showing 23 changed files with 2,437 additions and 3,417 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Rain Orderbook Arbitrage Bot
NodeJS app that clears Rain orderbook orders against major DeFi platforms liquidity by finding arbitrage trades for token pairs of orders details queried from a subgraph or from file containing array of `Order Struct`, bundling them as `takeOrders` and submitting them to [Rain GenericPoolOrderBookFlashBorrower contract](https://github.com/rainprotocol/rain.orderbook.flashborrower.zeroex).
NodeJS app that clears Rain orderbook orders against major DeFi platforms liquidity by finding arbitrage trades for token pairs of orders details queried from a subgraph or from file containing array of `Order Struct`, bundling them as `takeOrders` and submitting them to one of [Rain Arb Contracts](https://github.com/rainprotocol/rain.orderbook/tree/main/src/concrete).

This app requires NodeJS v18 or higher to run and is docker ready.
This app can also be run in Github Actions with a cron job, please read below for more details.
Expand Down Expand Up @@ -211,15 +211,14 @@ const configOptions = {
monthlyRatelimit : 1000000, // 0x monthly rate limit, only used for 0x mode
hideSensitiveData : true, // set to true to hide sensitive data such as wallet private key or rpc url from apearing in logs
maxProfit : true, // option to maximize profit for 'srouter' mode
maxRatio : true // option to maximize the maxIORatio in "srouter" mode
usePublicRpcs : false // option to fallback to public rpcs
maxRatio : true, // option to maximize the maxIORatio in "srouter" mode
usePublicRpcs : false, // option to fallback to public rpcs
liquidityProviders : [ // list of liquidity providers for "router" mode to get quotes from (optional)
"sushiswapv2",
"uniswapv2"
]
}
const clearOptions = {
prioritization : true, // clear better deals first
const clearOptions = {s
gasCoveragePercentage : "500" // percentage of the transaction gas cost denominated in receiving ERC20 to be earned from the transaction in order for it to be successfull, as an example a value of 500 means atleast 5x the amount of transaction gas cost needs to be earned for the transaction to be successfull
}

Expand Down
10 changes: 9 additions & 1 deletion arb-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ const arbRound = async options => {
{
orderHash : options.orderHash,
orderOwner : options.orderOwner,
orderInterpreter: options.orderInterpreter
orderInterpreter: options.orderInterpreter,
shuffle : options.shuffle
}
);
await clear(
Expand All @@ -147,6 +148,7 @@ const main = async argv => {
const rpcs = [...options.rpc];
let roundGap = 10000;
let rpcTurn = 0;
let shuffle = 0;

if (options.repetitions) {
if (/^\d+$/.test(options.repetitions)) repetitions = Number(options.repetitions);
Expand All @@ -167,6 +169,7 @@ const main = async argv => {
// eslint-disable-next-line no-constant-condition
if (repetitions === -1) while (true) {
options.rpc = rpcs[rpcTurn];
options.shuffle = shuffle;
try {
await arbRound(options);
console.log("\x1b[32m%s\x1b[0m", "Round finished successfully!");
Expand All @@ -178,10 +181,13 @@ const main = async argv => {
}
if (rpcTurn === rpcs.length - 1) rpcTurn = 0;
else rpcTurn++;
if (shuffle === 3) shuffle = 0;
else shuffle++;
await sleep(roundGap);
}
else for (let i = 1; i <= repetitions; i++) {
options.rpc = rpcs[rpcTurn];
options.shuffle = shuffle;
try {
await arbRound(options);
console.log("\x1b[32m%s\x1b[0m", `Round ${i} finished successfully!`);
Expand All @@ -195,6 +201,8 @@ const main = async argv => {
}
if (rpcTurn === rpcs.length - 1) rpcTurn = 0;
else rpcTurn++;
if (shuffle === 3) shuffle = 0;
else shuffle++;
await sleep(roundGap);
}
};
Expand Down
104 changes: 82 additions & 22 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@
"address": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
"decimals": 18
},
"liquidityProviders": [
"apeswap",
"dfyn",
"elk",
"jetswap",
"quickswap",
"sushiswapv3",
"sushiswapv2",
"uniswapv3"
],
"stableTokens": [
{
"symbol": "USDT",
Expand Down Expand Up @@ -222,6 +232,16 @@
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"decimals": 18
},
"liquidityProviders": [
"apeswap",
"curveswap",
"elk",
"pancakeswap",
"sushiswapv3",
"sushiswapv2",
"uniswapv2",
"uniswapv3"
],
"stableTokens": [
{
"symbol": "USDT",
Expand Down Expand Up @@ -305,28 +325,6 @@
}
]
},
{
"network": "goerli",
"chainId": 5,
"explorer": "https://goerli.etherscan.io/",
"zeroEx": {
"apiUrl": "https://goerli.api.0x.org/",
"proxyAddress": "0xf91bb752490473b8342a3e964e855b9f9a2a668e"
},
"curve": {
"pools": []
},
"nativeToken": {
"symbol": "ETH",
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"decimals": 18
},
"nativeWrappedToken": {
"symbol": "WETH",
"address": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"decimals": 18
}
},
{
"network": "avalanche",
"chainId": 43114,
Expand All @@ -350,6 +348,12 @@
"address": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
"decimals": 18
},
"liquidityProviders": [
"elk",
"traderjoe",
"sushiswapv3",
"sushiswapv2"
],
"stableTokens": [
{
"symbol": "USDT.e",
Expand Down Expand Up @@ -436,6 +440,13 @@
"address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"decimals": 18
},
"liquidityProviders": [
"dfyn",
"elk",
"sushiswapv3",
"uniswapv3",
"sushiswapv2"
],
"stableTokens": [
{
"symbol": "USDT",
Expand Down Expand Up @@ -507,6 +518,14 @@
"address": "0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83",
"decimals": 18
},
"liquidityProviders": [
"dfyn",
"elk",
"jetswap",
"spookyswap",
"sushiswapv3",
"sushiswapv2"
],
"stableTokens": [
{
"symbol": "fUSDT",
Expand Down Expand Up @@ -588,6 +607,16 @@
"address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
"decimals": 18
},
"liquidityProviders": [
"apeswap",
"biswap",
"elk",
"jetswap",
"pancakeswap",
"sushiswapv3",
"sushiswapv2",
"uniswapv3"
],
"stableTokens": [
{
"symbol": "USDT",
Expand Down Expand Up @@ -669,6 +698,10 @@
"address": "0x471EcE3750Da237f93B8E339c536989b8978a438",
"decimals": 18
},
"liquidityProviders": [
"ubeswap",
"sushiswapv2"
],
"stableTokens": [
{
"symbol": "MAI",
Expand Down Expand Up @@ -700,6 +733,11 @@
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18
},
"liquidityProviders": [
"elk",
"sushiswapv3",
"uniswapv3"
],
"stableTokens": {

}
Expand All @@ -726,5 +764,27 @@
"address": "0x5B67676a984807a212b1c59eBFc9B3568a474F0a",
"decimals": 18
}
},
{
"network": "goerli",
"chainId": 5,
"explorer": "https://goerli.etherscan.io/",
"zeroEx": {
"apiUrl": "https://goerli.api.0x.org/",
"proxyAddress": "0xf91bb752490473b8342a3e964e855b9f9a2a668e"
},
"curve": {
"pools": []
},
"nativeToken": {
"symbol": "ETH",
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"decimals": 18
},
"nativeWrappedToken": {
"symbol": "WETH",
"address": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"decimals": 18
}
}
]
Loading

0 comments on commit edd5155

Please sign in to comment.