Skip to content

Commit

Permalink
Merge pull request #25 from rainprotocol/2023-08-29-sleep-cli
Browse files Browse the repository at this point in the history
sleep cli option [minor]
  • Loading branch information
rouzwelt authored Aug 29, 2023
2 parents ec203c3 + 6e78aa2 commit 6023609
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Other optional arguments are:
- `--order-owner`, Option to filter the subgraph query results with a specific order owner address, Will override the 'ORDER_OWNER' in env variables
- `--order-interpreter`, Option to filter the subgraph query results with a specific order's interpreter address, Will override the 'ORDER_INTERPRETER' in env variables
- `--monthly-ratelimit`, 0x monthly rate limit, if not specified will not respect any 0x monthly ratelimit, Will override the 'MONTHLY_RATELIMIT' in env variables
- `--sleep`, Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables
- `--use-zeroex-arb`, Option to use old version of Arb contract for `0x` mode, i.e dedicated 0x Arb contract, ONLY available for `0x` mode
- `-V` or `--version`, output the version number
- `-h` or `--help`, output usage information
Expand Down Expand Up @@ -112,6 +113,7 @@ which will show:
--order-owner <address> Option to filter the subgraph query results with a specific order owner address, Will override the 'ORDER_OWNER' in env variables
--order-interpreter <address> Option to filter the subgraph query results with a specific order's interpreter address, Will override the 'ORDER_INTERPRETER' in env variables
--monthly-ratelimit <integer> 0x monthly rate limit, if not specified will not respect any 0x monthly ratelimit, Will override the 'MONTHLY_RATELIMIT' in env variables
--sleep <integer> Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables
--use-zeroex-arb Option to use old version of Arb contract for `0x` mode, i.e dedicated 0x Arb contract, ONLY available for `0x` mode
-V, --version output the version number
-h, --help display help for command
Expand Down Expand Up @@ -168,6 +170,9 @@ ORDER_OWNER=""

# Option to filter the subgraph query results with a specific order interpreter address
ORDER_INTERPRETER=""

# Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables
SLEEP=10
```
If both env variables and CLI argument are set, the CLI arguments will be prioritized and override the env variables.

Expand Down
9 changes: 8 additions & 1 deletion arb-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const DEFAULT_OPTIONS = {
orderOwner : process?.env?.ORDER_OWNER,
orderInterpreter : process?.env?.ORDER_INTERPRETER,
monthlyRatelimit : process?.env?.MONTHLY_RATELIMIT,
sleep : process?.env?.SLEEP,
subgraph : process?.env?.SUBGRAPH
? Array.from(process?.env?.SUBGRAPH.matchAll(/[^,\s]+/g)).map(v => v[0])
: undefined,
Expand All @@ -50,6 +51,7 @@ const getOptions = async argv => {
.option("--order-owner <address>", "Option to filter the subgraph query results with a specific order owner address, Will override the 'ORDER_OWNER' in env variables")
.option("--order-interpreter <address>", "Option to filter the subgraph query results with a specific order's interpreter address, Will override the 'ORDER_INTERPRETER' in env variables")
.option("--monthly-ratelimit <integer>", "0x monthly rate limit, if not specified will not respect any 0x monthly ratelimit, Will override the 'MONTHLY_RATELIMIT' in env variables")
.option("--sleep <integer>", "Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables")
.option("--use-zeroex-arb", "Option to use old version of Arb contract for `0x` mode, i.e dedicated 0x Arb contract, ONLY available for `0x` mode")
.description([
"A NodeJS app to find and take arbitrage trades for Rain Orderbook orders against some DeFi liquidity providers, requires NodeJS v18 or higher.",
Expand All @@ -75,6 +77,7 @@ const getOptions = async argv => {
cmdOptions.useZeroexArb = cmdOptions.useZeroexArb || DEFAULT_OPTIONS.useZeroexArb;
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;

Expand Down Expand Up @@ -127,13 +130,17 @@ const arbRound = async options => {

const main = async argv => {
let repetitions = -1;
const roundGap = 10000;
const options = await getOptions(argv);
let roundGap = 10000;

if (options.repetitions) {
if (/^\d+$/.test(options.repetitions)) repetitions = Number(options.repetitions);
else throw "invalid repetitions, must be an integer greater than equal 0";
}
if (options.sleep) {
if (/^\d+$/.test(options.sleep)) roundGap = Number(options.sleep) * 1000;
else throw "invalid sleep value, must be an integer greater than equal 0";
}

appGlobalLogger(
true,
Expand Down
2 changes: 1 addition & 1 deletion docs/html/curve.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,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 Thu Aug 24 2023 18:07:06 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Aug 29 2023 14:52:44 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -6606,7 +6606,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 Thu Aug 24 2023 18:07:06 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Aug 29 2023 14:52:44 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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 Thu Aug 24 2023 18:07:06 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Aug 29 2023 14:52:44 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,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 Thu Aug 24 2023 18:07:06 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Aug 29 2023 14:52:44 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/query.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,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 Thu Aug 24 2023 18:07:06 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Aug 29 2023 14:52:44 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/router.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,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 Thu Aug 24 2023 18:07:06 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Aug 29 2023 14:52:44 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/utils.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,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 Thu Aug 24 2023 18:07:06 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Aug 29 2023 14:52:44 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/zeroex.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,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 Thu Aug 24 2023 18:07:06 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Aug 29 2023 14:52:44 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
5 changes: 4 additions & 1 deletion example.env
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ ORDER_HASH=""
ORDER_OWNER=""

# Option to filter the subgraph query results with a specific order interpreter address
ORDER_INTERPRETER=""
ORDER_INTERPRETER=""

# Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables
SLEEP=10

0 comments on commit 6023609

Please sign in to comment.