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

update to RP v3.2 #36

Merged
merged 32 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7674b7c
init
rouzwelt Mar 5, 2024
79d4e8c
Update utils.js
rouzwelt Mar 5, 2024
8c01838
increase gasPrice
Siddharth2207 Mar 7, 2024
6b81662
init
rouzwelt Mar 8, 2024
eb1b233
Update srouter.test.js
rouzwelt Mar 8, 2024
9681f0d
Update srouter.js
rouzwelt Mar 8, 2024
0aa86a8
Update srouter.js
rouzwelt Mar 8, 2024
effafdc
Update srouter.js
rouzwelt Mar 8, 2024
11be45e
Merge branch '2024-03-05-rp3-2' into 2024-03-07-multi-same-order
rouzwelt Mar 8, 2024
4158e08
Update srouter.js
rouzwelt Mar 8, 2024
23519ca
Update srouter.js
rouzwelt Mar 8, 2024
384fb26
Update srouter.js
rouzwelt Mar 8, 2024
26a7142
fix
rouzwelt Mar 8, 2024
9c8de7f
Update srouter.js
rouzwelt Mar 8, 2024
2e37845
Update srouter.js
rouzwelt Mar 8, 2024
32f65de
Update index.js
rouzwelt Mar 9, 2024
714df0e
update headroom/gas overhead
rouzwelt Mar 18, 2024
a2214a3
Update utils.js
rouzwelt Mar 18, 2024
91090d1
Update utils.js
rouzwelt Mar 18, 2024
d41a844
Update srouter.js
rouzwelt Mar 18, 2024
274eb43
fix use of flashbot signer
rouzwelt Mar 18, 2024
77539f7
update
rouzwelt Mar 27, 2024
4147486
update
rouzwelt Mar 27, 2024
ae1c2bf
fix flashbot read
rouzwelt Mar 27, 2024
4c6a25a
add suniv2 mode
rouzwelt Mar 27, 2024
07189a8
uncommit docs
rouzwelt Mar 27, 2024
fcfbb81
Update .gitignore
rouzwelt Mar 27, 2024
e00d68d
apply timeout on send tx
rouzwelt Mar 27, 2024
8897f38
log tx
rouzwelt Mar 27, 2024
e621f24
fix use public rpcs
rouzwelt Mar 27, 2024
8a23e32
Merge pull request #37 from rainlanguage/2024-03-07-multi-same-order
rouzwelt Mar 28, 2024
9f7f0e7
update
rouzwelt Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
## Deps
node_modules

## Private
.env

## That one annoying file
.DS_Store

## Generated
cache
/contracts
artifacts
logs.txt
logs

## Private
.env

## That one annoying file
.DS_Store
docs
mem-cache
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ node arb-bot -k 12ab... -r https://... --orderbook-address 0x1a2b... --arb-addre
The app requires these arguments (all arguments can be set in env variables alternatively, more details below):
- `-k` or `--key`, Private key of wallet that performs the transactions. Will override the 'BOT_WALLET_PRIVATEKEY' in env variables
- `-r` or `--rpc`, RPC URL(s) that will be provider for interacting with evm, use different providers if more than 1 is specified to prevent banning. Will override the 'RPC_URL' in env variables
- `-m` or `--mode`, Running mode of the bot, must be one of: `0x` or `curve` or `router` or `crouter` or `srouter`, Will override the 'MODE' in env variables
- `-m` or `--mode`, Running mode of the bot, must be one of: `0x` or `curve` or `router` or `crouter` or `srouter` or `suniv2`, Will override the 'MODE' in env variables
- `--orderbook-address`, Address of the deployed orderbook contract, Will override the 'ORDERBOOK_ADDRESS' in env variables
- `--arb-address`, Address of the deployed arb contract, Will override the 'ARB_ADDRESS' in env variables
- `--arb-contract-type`, Type of the Arb contract, can be either of `flash-loan-v2` or `flash-loan-v3` or `order-taker`, not availabe for `srouter` mode since it is a specialized mode, Will override the 'ARB_TYPE' in env variables
Expand All @@ -61,6 +61,8 @@ Other optional arguments are:
- `--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
- `--hops`, Option to specify how many hops the binary search should do in srouter mode, default is 11 if left unspecified, Will override the 'HOPS' in env variables
- `--rp32`, Option to use sushi RouteProcessor v3.2, defaults to v3 if not passed, Will override the 'RP3_2' in env variables
- `-V` or `--version`, output the version number
- `-h` or `--help`, output usage information

Expand Down Expand Up @@ -107,7 +109,7 @@ which will show:
Options:
-k, --key <private-key> Private key of wallet that performs the transactions. Will override the 'BOT_WALLET_PRIVATEKEY' in env variables
-r, --rpc <url...> RPC URL(s) that will be provider for interacting with evm, use different providers if more than 1 is specified to prevent banning. Will override the 'RPC_URL' in env variables
-m, --mode <string> Running mode of the bot, must be one of: `0x` or `curve` or `router` or `crouter` or `srouter`, Will override the 'MODE' in env variables
-m, --mode <string> Running mode of the bot, must be one of: `0x` or `curve` or `router` or `crouter` or `srouter` or `suniv2`, Will override the 'MODE' in env variables
-o, --orders <path> The path to a local json file containing the orders details, can be used in combination with --subgraph, Will override the 'ORDERS' in env variables
-s, --subgraph <url...> Subgraph URL(s) to read orders details from, can be used in combination with --orders, Will override the 'SUBGRAPH' in env variables
--orderbook-address <address> Address of the deployed orderbook contract, Will override the 'ORDERBOOK_ADDRESS' in env variables
Expand All @@ -129,6 +131,8 @@ which will show:
--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
--hops <integer> Option to specify how many hops the binary search should do in srouter mode, default is 11 if left unspecified, Will override the 'HOPS' in env variables
--rp32 Option to use sushi RouteProcessor v3.2, defaults to v3 if not passed, Will override the 'RP3_2' in env variables
-V, --version output the version number
-h, --help display help for command
<br>
Expand All @@ -145,7 +149,7 @@ RPC_URL="https://polygon-mainnet.g.alchemy.com/v2/{API_KEY}, https://rpc.ankr.co
# Option to submit transactions using the flashbot RPC.
FLASHBOT_RPC=""

# bot running mode, one of "router", "0x", "curve", "crouter", "srouter"
# bot running mode, one of "router", "0x", "curve", "crouter", "srouter", "suniv2"
MODE="router"

# arb contract address
Expand Down Expand Up @@ -213,6 +217,9 @@ NO_BUNDLE="false"

# number of hops of binary search in srouter mode, if left unspecified will be 11 by default
HOPS=11

# Option to use sushi RouteProcessorv3.2, default is v3
RP3_2="true"
```
If both env variables and CLI argument are set, the CLI arguments will be prioritized and override the env variables.

Expand Down Expand Up @@ -241,6 +248,8 @@ const configOptions = {
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
hops : 6, // The amount of hops of binary search for sorouter mode
rp32 : true, // Option to use sushi RouteProcessorv3.2, default is v3
liquidityProviders : [ // list of liquidity providers for "router" mode to get quotes from (optional)
"sushiswapv2",
"uniswapv2"
Expand All @@ -266,7 +275,7 @@ const sgFilters = { // fil
const orderDetails = await RainArbBot.getOrderDetails(subgraphs, ordersJson, config.signer, sgFilters);

// to run the clearing process and get the report object which holds the report of cleared orders
const mode = "srouter" // mode can be one of "router" or "0x" or "curve" or "crouter" or "srouter"
const mode = "srouter" // mode can be one of "router" or "0x" or "curve" or "crouter" or "srouter" or "suniv2"
const reports = await RainArbBot.clear(mode, config, orderDetails, ...[clearOptions])
```
<br>
Expand Down
10 changes: 7 additions & 3 deletions arb-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const ENV_OPTIONS = {
timeout : process?.env?.TIMEOUT,
flashbotRpc : process?.env?.FLASHBOT_RPC,
hops : process?.env?.HOPS,
rp32 : process?.env?.RP3_2?.toLowerCase() === "true" ? true : false,
rpc : process?.env?.RPC_URL
? Array.from(process?.env?.RPC_URL.matchAll(/[^,\s]+/g)).map(v => v[0])
: undefined,
Expand All @@ -46,7 +47,7 @@ const getOptions = async argv => {
const cmdOptions = new Command("node arb-bot")
.option("-k, --key <private-key>", "Private key of wallet that performs the transactions. Will override the 'BOT_WALLET_PRIVATEKEY' in env variables")
.option("-r, --rpc <url...>", "RPC URL(s) that will be provider for interacting with evm, use different providers if more than 1 is specified to prevent banning. Will override the 'RPC_URL' in env variables")
.option("-m, --mode <string>", "Running mode of the bot, must be one of: `0x` or `curve` or `router` or `crouter` or `srouter`, Will override the 'MODE' in env variables")
.option("-m, --mode <string>", "Running mode of the bot, must be one of: `0x` or `curve` or `router` or `crouter` or `srouter` or `suniv2`, Will override the 'MODE' in env variables")
.option("-o, --orders <path>", "The path to a local json file containing the orders details, can be used in combination with --subgraph, Will override the 'ORDERS' in env variables")
.option("-s, --subgraph <url...>", "Subgraph URL(s) to read orders details from, can be used in combination with --orders, Will override the 'SUBGRAPH' in env variables")
.option("--orderbook-address <address>", "Address of the deployed orderbook contract, Will override the 'ORDERBOOK_ADDRESS' in env variables")
Expand All @@ -68,7 +69,8 @@ const getOptions = async argv => {
.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")
.option("--hops <integer>", "Option to specify how many hops the binary search should o in srouter mode, default is 11 is left unspecified, Will override the 'HOPS' in env variables")
.option("--hops <integer>", "Option to specify how many hops the binary search should do in srouter mode, default is 11 if left unspecified, Will override the 'HOPS' in env variables")
.option("--rp32", "Option to use sushi RouteProcessor v3.2, defaults to v3 if not passed, Will override the 'RP3_2' 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 @@ -104,6 +106,7 @@ const getOptions = async argv => {
cmdOptions.timeout = cmdOptions.timeout || ENV_OPTIONS.timeout;
cmdOptions.interpreterv2 = cmdOptions.interpreterv2 || ENV_OPTIONS.interpreterv2;
cmdOptions.hops = cmdOptions.hops || ENV_OPTIONS.hops;
cmdOptions.rp32 = cmdOptions.rp32 || ENV_OPTIONS.rp32;
cmdOptions.bundle = cmdOptions.bundle ? ENV_OPTIONS.bundle : false;

return cmdOptions;
Expand Down Expand Up @@ -136,6 +139,7 @@ const arbRound = async options => {
interpreterv2 : options.interpreterv2,
bundle : options.bundle,
hops : options.hops,
rp32 : options.rp32,
liquidityProviders : options.lps
? Array.from(options.lps.matchAll(/[^,\s]+/g)).map(v => v[0])
: undefined,
Expand Down Expand Up @@ -180,7 +184,7 @@ const main = async argv => {

appGlobalLogger(
true,
...rpcs,
// ...rpcs,
options.key,
options.apiKey
);
Expand Down
45 changes: 45 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"chainId": 137,
"explorer": "https://polygonscan.com/",
"routeProcessor3Address": "0x0a6e511Fe663827b9cA7e2D2542b20B37fC217A6",
"routeProcessor3_2Address": "0xE7eb31f23A5BefEEFf76dbD2ED6AdC822568a5d2",
"uniV2Router02Address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
"zeroEx": {
"apiUrl": "https://polygon.api.0x.org/",
Expand Down Expand Up @@ -214,6 +215,7 @@
"chainId": 1,
"explorer": "https://etherscan.io/",
"routeProcessor3Address": "0x827179dD56d07A7eeA32e3873493835da2866976",
"routeProcessor3_2Address": "0x5550D13389bB70F45fCeF58f19f6b6e87F6e747d",
"uniV2Router02Address": "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F",
"zeroEx": {
"apiUrl": "https://api.0x.org/",
Expand Down Expand Up @@ -551,6 +553,7 @@
"chainId": 43114,
"explorer": "https://snowtrace.io/",
"routeProcessor3Address": "0x717b7948AA264DeCf4D780aa6914482e5F46Da3e",
"routeProcessor3_2Address": "0x8f54301F315C56c112D492D9443047D4745dbe9e",
"uniV2Router02Address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
"zeroEx": {
"apiUrl": "https://avalanche.api.0x.org/",
Expand Down Expand Up @@ -643,6 +646,7 @@
"chainId": 42161,
"explorer": "https://arbiscan.io/",
"routeProcessor3Address": "0xfc506AaA1340b4dedFfd88bE278bEe058952D674",
"routeProcessor3_2Address": "0x09bD2A33c47746fF03b86BCe4E885D03C74a8E8C",
"uniV2Router02Address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
"zeroEx": {
"apiUrl": "https://arbitrum.api.0x.org/",
Expand Down Expand Up @@ -721,6 +725,7 @@
"chainId": 250,
"explorer": "https://ftmscan.com/",
"routeProcessor3Address": "0x2214A42d8e2A1d20635c2cb0664422c528B6A432",
"routeProcessor3_2Address": "0xFB70AD5a200d784E7901230E6875d91d5Fa6B68c",
"uniV2Router02Address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
"zeroEx": {
"apiUrl": "https://fantom.api.0x.org/",
Expand Down Expand Up @@ -810,6 +815,7 @@
"chainId": 56,
"explorer": "https://bscscan.com/",
"routeProcessor3Address": "0x400d75dAb26bBc18D163AEA3e83D9Ea68F6c1804",
"routeProcessor3_2Address": "0xd36990D74b947eC4Ad9f52Fe3D49d14AdDB51E44",
"uniV2Router02Address": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
"zeroEx": {
"apiUrl": "https://bsc.api.0x.org/",
Expand Down Expand Up @@ -901,6 +907,7 @@
"chainId": 42220,
"explorer": "https://celoscan.io/",
"routeProcessor3Address": "0x2f686751b19a9d91cc3d57d90150Bc767f050066",
"routeProcessor3_2Address": "0xaB235da7f52d35fb4551AfBa11BFB56e18774A65",
"uniV2Router02Address": "0x1421bDe4B10e8dd459b3BCb598810B1337D56842",
"zeroEx": {
"apiUrl": "https://celo.api.0x.org/",
Expand Down Expand Up @@ -936,6 +943,7 @@
"chainId": 10,
"explorer": "https://optimistic.etherscan.io/",
"routeProcessor3Address": "0x4C5D5234f232BD2D76B96aA33F5AE4FCF0E4BFAb",
"routeProcessor3_2Address": "0xEb94EcA012eC0bbB254722FdDa2CE7475875A52B",
"uniV2Router02Address": "",
"zeroEx": {
"apiUrl": "https://optimism.api.0x.org/",
Expand Down Expand Up @@ -1007,5 +1015,42 @@
"address": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"decimals": 18
}
},
{
"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": {

}
}
]
Binary file removed docs/html/fonts/OpenSans-Bold-webfont.eot
Binary file not shown.
Loading
Loading