Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024 01 28 flare mode #34

Closed
wants to merge 17 commits into from
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ logs

## That one annoying file
.DS_Store
.mem-cache
mem-cache
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Other optional arguments are:
- `--use-public-rpcs`, Option to use public rpcs as fallback option for 'srouter' and 'router' mode, Will override the 'USE_PUBLIC_RPCS' in env variables
- `--timeout`, Optional seconds to wait for the transaction to mine before disregarding it, Will override the 'TIMEOUT' in env variables
- `--flashbot-rpc`, Optional flashbot rpc url to submit transaction to, Will override the 'FLASHBOT_RPC' in env variables
- `--interpreter-v2`, Flag for operating with interpreter V2, note that 'flash-loan-v2' is NOT compatible with interpreter v2. Will override the 'INTERPRETERV2' in env variables
- `--no-bundle`, Flag for not bundling orders based on pairs and clear each order individually. Will override the 'NO_BUNDLE' in env variables
- `-V` or `--version`, output the version number
- `-h` or `--help`, output usage information

Expand Down Expand Up @@ -125,6 +127,8 @@ which will show:
--max-profit Option to maximize profit for 'srouter' mode, comes at the cost of more RPC calls, Will override the 'MAX_PROFIT' in env variables
--max-ratio Option to maximize maxIORatio for 'srouter' mode, Will override the 'MAX_RATIO' in env variables
--use-public-rpcs Option to use public rpcs as fallback option for 'srouter' and 'router' mode, Will override the 'USE_PUBLIC_RPCS' in env variables
--interpreter-v2 Flag for operating with interpreter V2, note that 'flash-loan-v2' is NOT compatible with interpreter v2. Will override the 'INTERPRETERV2' in env variables
--no-bundle Flag for not bundling orders based on pairs and clear each order individually. Will override the 'NO_BUNDLE' in env variables
-V, --version output the version number
-h, --help display help for command
<br>
Expand Down Expand Up @@ -199,6 +203,13 @@ USE_PUBLIC_RPCS="true"

# Optional seconds to wait for the transaction to mine before disregarding it
TIMEOUT=""

# Flag for operating with with interpreter V2. false will result in operating under interpreter v1
# note that 'flash-loan-v2' is NOT compatible with interpreter v2
INTERPRETERV2="true"

# Flag for not bundling orders based on pairs and clear each order individually
NO_BUNDLE="false"
```
If both env variables and CLI argument are set, the CLI arguments will be prioritized and override the env variables.

Expand All @@ -225,6 +236,8 @@ const configOptions = {
usePublicRpcs : false, // option to fallback to public rpcs
flashbotRpc : "https://flashbot-rpc-url", // Optional Flashbot RPC URL
timeout : 300, // seconds to wait for tx to mine before disregarding it
interpreterv2 : true, // if interpreter v2 should be used, not compatible with flash-loan-v2 arb contract
bundle : true, // if orders should be bundled based on token pair or be handled individually
liquidityProviders : [ // list of liquidity providers for "router" mode to get quotes from (optional)
"sushiswapv2",
"uniswapv2"
Expand Down
58 changes: 33 additions & 25 deletions arb-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const { getOrderDetails, clear, getConfig } = require("./src");


/**
* Default CLI arguments
* Options specified in env variables
*/
const DEFAULT_OPTIONS = {
const ENV_OPTIONS = {
key : process?.env?.BOT_WALLET_PRIVATEKEY,
mode : process?.env?.MODE,
arbAddress : process?.env?.ARB_ADDRESS,
Expand All @@ -29,6 +29,8 @@ const DEFAULT_OPTIONS = {
maxProfit : process?.env?.MAX_PROFIT?.toLowerCase() === "true" ? true : false,
maxRatio : process?.env?.MAX_RATIO?.toLowerCase() === "true" ? true : false,
usePublicRpcs : process?.env?.USE_PUBLIC_RPCS?.toLowerCase() === "true" ? true : false,
interpreterv2 : process?.env?.INTERPRETERV2?.toLowerCase() === "true" ? true : false,
bundle : process?.env?.NO_BUNDLE?.toLowerCase() === "true" ? false : true,
timeout : process?.env?.TIMEOUT,
flashbotRpc : process?.env?.FLASHBOT_RPC,
rpc : process?.env?.RPC_URL
Expand Down Expand Up @@ -63,6 +65,8 @@ const getOptions = async argv => {
.option("--max-profit", "Option to maximize profit for 'srouter' mode, comes at the cost of more RPC calls, Will override the 'MAX_PROFIT' in env variables")
.option("--max-ratio", "Option to maximize maxIORatio for 'srouter' mode, Will override the 'MAX_RATIO' in env variables")
.option("--use-public-rpcs", "Option to use public rpcs as fallback option for 'srouter' and 'router' mode, Will override the 'USE_PUBLIC_RPCS' in env variables")
.option("--interpreter-v2", "Flag for operating with interpreter V2, note that 'flash-loan-v2' is NOT compatible with interpreter v2. Will override the 'INTERPRETERV2' in env variables")
.option("--no-bundle", "Flag for not bundling orders based on pairs and clear each order individually. Will override the 'NO_BUNDLE' in env variables")
.description([
"A NodeJS app to find and take arbitrage trades for Rain Orderbook orders against some DeFi liquidity providers, requires NodeJS v18 or higher.",
"- Use \"node arb-bot [options]\" command alias for running the app from its repository workspace",
Expand All @@ -73,29 +77,31 @@ const getOptions = async argv => {
.parse(argv)
.opts();

cmdOptions.key = cmdOptions.key || DEFAULT_OPTIONS.key;
cmdOptions.rpc = cmdOptions.rpc || DEFAULT_OPTIONS.rpc;
cmdOptions.mode = cmdOptions.mode || DEFAULT_OPTIONS.mode;
cmdOptions.arbAddress = cmdOptions.arbAddress || DEFAULT_OPTIONS.arbAddress;
cmdOptions.arbType = cmdOptions.arbType || DEFAULT_OPTIONS.arbType;
cmdOptions.orderbookAddress = cmdOptions.orderbookAddress || DEFAULT_OPTIONS.orderbookAddress;
cmdOptions.orders = cmdOptions.orders || DEFAULT_OPTIONS.orders;
cmdOptions.subgraph = cmdOptions.subgraph || DEFAULT_OPTIONS.subgraph;
cmdOptions.apiKey = cmdOptions.apiKey || DEFAULT_OPTIONS.apiKey;
cmdOptions.lps = cmdOptions.lps || DEFAULT_OPTIONS.lps;
cmdOptions.gasCoverage = cmdOptions.gasCoverage || DEFAULT_OPTIONS.gasCoverage;
cmdOptions.repetitions = cmdOptions.repetitions || DEFAULT_OPTIONS.repetitions;
cmdOptions.orderHash = cmdOptions.orderHash || DEFAULT_OPTIONS.orderHash;
cmdOptions.orderOwner = cmdOptions.orderOwner || DEFAULT_OPTIONS.orderOwner;
cmdOptions.sleep = cmdOptions.sleep || DEFAULT_OPTIONS.sleep;
cmdOptions.orderInterpreter = cmdOptions.orderInterpreter || DEFAULT_OPTIONS.orderInterpreter;
cmdOptions.monthlyRatelimit = cmdOptions.monthlyRatelimit || DEFAULT_OPTIONS.monthlyRatelimit;
cmdOptions.maxProfit = cmdOptions.maxProfit || DEFAULT_OPTIONS.maxProfit;
cmdOptions.maxRatio = cmdOptions.maxRatio || DEFAULT_OPTIONS.maxRatio;
cmdOptions.usePublicRpcs = cmdOptions.usePublicRpcs || DEFAULT_OPTIONS.usePublicRpcs;
cmdOptions.flashbotRpc = cmdOptions.flashbotRpc || DEFAULT_OPTIONS.flashbotRpc;
cmdOptions.timeout = cmdOptions.timeout || DEFAULT_OPTIONS.timeout;

// assigning specified options from cli/env
cmdOptions.key = cmdOptions.key || ENV_OPTIONS.key;
cmdOptions.rpc = cmdOptions.rpc || ENV_OPTIONS.rpc;
cmdOptions.mode = cmdOptions.mode || ENV_OPTIONS.mode;
cmdOptions.arbAddress = cmdOptions.arbAddress || ENV_OPTIONS.arbAddress;
cmdOptions.arbType = cmdOptions.arbType || ENV_OPTIONS.arbType;
cmdOptions.orderbookAddress = cmdOptions.orderbookAddress || ENV_OPTIONS.orderbookAddress;
cmdOptions.orders = cmdOptions.orders || ENV_OPTIONS.orders;
cmdOptions.subgraph = cmdOptions.subgraph || ENV_OPTIONS.subgraph;
cmdOptions.apiKey = cmdOptions.apiKey || ENV_OPTIONS.apiKey;
cmdOptions.lps = cmdOptions.lps || ENV_OPTIONS.lps;
cmdOptions.gasCoverage = cmdOptions.gasCoverage || ENV_OPTIONS.gasCoverage;
cmdOptions.repetitions = cmdOptions.repetitions || ENV_OPTIONS.repetitions;
cmdOptions.orderHash = cmdOptions.orderHash || ENV_OPTIONS.orderHash;
cmdOptions.orderOwner = cmdOptions.orderOwner || ENV_OPTIONS.orderOwner;
cmdOptions.sleep = cmdOptions.sleep || ENV_OPTIONS.sleep;
cmdOptions.orderInterpreter = cmdOptions.orderInterpreter || ENV_OPTIONS.orderInterpreter;
cmdOptions.monthlyRatelimit = cmdOptions.monthlyRatelimit || ENV_OPTIONS.monthlyRatelimit;
cmdOptions.maxProfit = cmdOptions.maxProfit || ENV_OPTIONS.maxProfit;
cmdOptions.maxRatio = cmdOptions.maxRatio || ENV_OPTIONS.maxRatio;
cmdOptions.usePublicRpcs = cmdOptions.usePublicRpcs || ENV_OPTIONS.usePublicRpcs;
cmdOptions.flashbotRpc = cmdOptions.flashbotRpc || ENV_OPTIONS.flashbotRpc;
cmdOptions.timeout = cmdOptions.timeout || ENV_OPTIONS.timeout;
cmdOptions.interpreterv2 = cmdOptions.interpreterv2 || ENV_OPTIONS.interpreterv2;
cmdOptions.bundle = cmdOptions.bundle ? ENV_OPTIONS.bundle : false;

return cmdOptions;
};
Expand Down Expand Up @@ -124,6 +130,8 @@ const arbRound = async options => {
hideSensitiveData : false,
shortenLargeLogs : false,
timeout : options.timeout,
interpreterv2 : options.interpreterv2,
bundle : options.bundle,
liquidityProviders : options.lps
? Array.from(options.lps.matchAll(/[^,\s]+/g)).map(v => v[0])
: undefined,
Expand Down
37 changes: 37 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,43 @@
}
]
},
{
"network": "flare mainnet",
"chainId": 14,
"explorer": "https://flarescan.com/",
"routeProcessor3Address": "0x9B3F1D56D9004e6C69d8247d402F38DE5F87A27c",
"uniV2Router02Address": "0x088EeCB467B3968Da36c71F05023A1d3133B2B83",
"zeroEx": {
},
"curve": {
"pools": []
},
"enosys":{
"pools": [
{
"address": "0x7520005032F43229F606d3ACeae97045b9D6F7ea",
"token0": "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",
"token1": "0x96B41289D90444B8adD57e6F265DB5aE8651DF29"
}
]
},
"nativeToken": {
"symbol": "FLR",
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"decimals": 18
},
"nativeWrappedToken": {
"symbol": "WFLR",
"address": "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",
"decimals": 18
},
"liquidityProviders": [

],
"stableTokens": {

}
},
{
"network": "homestead",
"chainId": 1,
Expand Down
Loading
Loading