Skip to content

Commit

Permalink
Merge pull request #27 from rainprotocol/2023-09-14-fix-datafetcher-i…
Browse files Browse the repository at this point in the history
…mplementation

fix sushiswap router data fetcher implementation [minor]
  • Loading branch information
rouzwelt authored Sep 14, 2023
2 parents d372fea + 650478f commit b075e24
Show file tree
Hide file tree
Showing 20 changed files with 745 additions and 1,300 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Other optional arguments are:
- `--sleep`, Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables
- `--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
- `-V` or `--version`, output the version number
- `-h` or `--help`, output usage information

Expand Down Expand Up @@ -119,6 +120,7 @@ which will show:
--sleep <integer> Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables
--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
-V, --version output the version number
-h, --help display help for command
<br>
Expand Down Expand Up @@ -184,6 +186,9 @@ SLEEP=10

# Option to maximize maxIORatio for 'srouter' mode
MAX_RATIO="true"

# Option to use public rpcs as fallback option for 'srouter' and 'router' mode
USE_PUBLIC_RPCS="true"
```
If both env variables and CLI argument are set, the CLI arguments will be prioritized and override the env variables.

Expand All @@ -207,6 +212,7 @@ const configOptions = {
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
liquidityProviders : [ // list of liquidity providers for "router" mode to get quotes from (optional)
"sushiswapv2",
"uniswapv2"
Expand Down
4 changes: 4 additions & 0 deletions arb-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DEFAULT_OPTIONS = {
sleep : process?.env?.SLEEP,
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,
rpc : process?.env?.RPC_URL
? Array.from(process?.env?.RPC_URL.matchAll(/[^,\s]+/g)).map(v => v[0])
: undefined,
Expand Down Expand Up @@ -57,6 +58,7 @@ const getOptions = async argv => {
.option("--sleep <integer>", "Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables")
.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")
.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 Down Expand Up @@ -86,6 +88,7 @@ const getOptions = async argv => {
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;

return cmdOptions;
};
Expand All @@ -109,6 +112,7 @@ const arbRound = async options => {
monthlyRatelimit : options.monthlyRatelimit,
maxProfit : options.maxProfit,
maxRatio : options.maxRatio,
usePublicRpcs : options.usePublicRpcs,
hideSensitiveData : false,
shortenLargeLogs : false,
liquidityProviders : options.lps
Expand Down
5 changes: 2 additions & 3 deletions docs/html/curve.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ <h1 class="page-title">Source: curve.js</h1>
);

const report = [];
const dataFetcher = getDataFetcher(config, processLps(config.lps));
const dataFetcher = getDataFetcher(config, processLps(config.lps), !!config.usePublicRpc);
for (let i = 0; i &lt; bundledOrders.length; i++) {
try {
gasPrice = await signer.provider.getGasPrice();
Expand Down Expand Up @@ -693,7 +693,6 @@ <h1 class="page-title">Source: curve.js</h1>
console.log(error);
}
}
dataFetcher.stopDataFetching();
return report;
};

Expand All @@ -715,7 +714,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Fri Sep 08 2023 16:43:44 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Sep 14 2023 13:47:17 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading

0 comments on commit b075e24

Please sign in to comment.