Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Nov 2, 2024
1 parent bbe677d commit ac2a926
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ Other optional arguments are:
- `--sleep`, Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables
- `--max-ratio`, Option to maximize maxIORatio, Will override the 'MAX_RATIO' in env variables
- `--timeout`, Optional seconds to wait for the transaction to mine before disregarding it, Will override the 'TIMEOUT' in env variables
- `--write-rpc`, Option to explicitly use for write transactions, such as flashbots or mev protect rpc to protect against mev attacks, Will override the 'WRITE_RPC' 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
- `--write-rpc`, Option to explicitly use for write transactions, such as flashbots or mev protect rpc to protect against mev attacks, Will override the 'WRITE_RPC' in env variables
- `--hops`, Option to specify how many hops the binary search should do, default is 0 if left unspecified, Will override the 'HOPS' in env variables
- `--retries`, Option to specify how many retries should be done for the same order, max value is 3, default is 1 if left unspecified, Will override the 'RETRIES' in env variables
- `--pool-update-interval`, Option to specify time (in minutes) between pools updates, default is 15 minutes, Will override the 'POOL_UPDATE_INTERVAL' in env variables
Expand Down Expand Up @@ -197,9 +196,6 @@ MAX_RATIO="true"
# Optional seconds to wait for the transaction to mine before disregarding it
TIMEOUT=""

# Flag for not bundling orders based on pairs and clear each order individually
NO_BUNDLE="false"

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

Expand Down Expand Up @@ -257,8 +253,7 @@ const RainArbBot = require("@rainprotocol/arb-bot");
const configOptions = {
maxRatio : true, // option to maximize the maxIORatio
flashbotRpc : "https://flashbot-rpc-url", // Optional Flashbot RPC URL
timeout : 300, // seconds to wait for tx to mine before disregarding it
bundle : true, // if orders should be bundled based on token pair or be handled individually
timeout : 300, // seconds to wait for tx to mine before disregarding it
hops : 6, // The amount of hops of binary search
retries : 1, // The amount of retries for the same order
liquidityProviders : [ // list of liquidity providers to get quotes from (optional)
Expand Down
3 changes: 0 additions & 3 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ MAX_RATIO="true"
# Optional seconds to wait for the transaction to mine before disregarding it
TIMEOUT=""

# Flag for not bundling orders based on pairs and clear each order individually
NO_BUNDLE="false"

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

Expand Down
8 changes: 1 addition & 7 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import {
diag,
trace,
context,
DiagLogLevel,
SpanStatusCode,
DiagConsoleLogger,
DiagLogLevel,
} from "@opentelemetry/api";
import {
BasicTracerProvider,
Expand All @@ -54,7 +54,6 @@ const ENV_OPTIONS = {
orderOwner: process?.env?.ORDER_OWNER,
sleep: process?.env?.SLEEP,
maxRatio: process?.env?.MAX_RATIO?.toLowerCase() === "true" ? true : false,
bundle: process?.env?.NO_BUNDLE?.toLowerCase() === "true" ? false : true,
publicRpc: process?.env?.PUBLIC_RPC?.toLowerCase() === "true" ? true : false,
timeout: process?.env?.TIMEOUT,
hops: process?.env?.HOPS,
Expand Down Expand Up @@ -148,10 +147,6 @@ const getOptions = async (argv: any, version?: string) => {
"--max-ratio",
"Option to maximize maxIORatio, Will override the 'MAX_RATIO' 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 do, default is 1 if left unspecified, Will override the 'HOPS' in env variables",
Expand Down Expand Up @@ -233,7 +228,6 @@ const getOptions = async (argv: any, version?: string) => {
cmdOptions.botMinBalance = cmdOptions.botMinBalance || getEnv(ENV_OPTIONS.botMinBalance);
cmdOptions.ownerProfile = cmdOptions.ownerProfile || getEnv(ENV_OPTIONS.ownerProfile);
cmdOptions.route = cmdOptions.route || getEnv(ENV_OPTIONS.route);
cmdOptions.bundle = cmdOptions.bundle ? getEnv(ENV_OPTIONS.bundle) : false;
cmdOptions.publicRpc = cmdOptions.publicRpc || getEnv(ENV_OPTIONS.publicRpc);
if (cmdOptions.ownerProfile) {
const profiles: Record<string, number> = {};
Expand Down
34 changes: 25 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { ChainId, ChainKey } from "sushi/chain";
import { DataFetcher, LiquidityProviders } from "sushi/router";
import { BotConfig, BotDataFetcher, ChainConfig, ViemClient } from "./types";
import {
createWalletClient,
http,
fallback,
HDAccount,
http,
PrivateKeyAccount,
publicActions,
webSocket,
PublicClient,
publicActions,
walletActions,
webSocket,
PrivateKeyAccount,
createWalletClient,
} from "viem";
import {
STABLES,
Expand Down Expand Up @@ -75,15 +75,31 @@ export async function createViemClient(
const urls = rpcs?.filter((v) => typeof v === "string") ?? [];
const topRpcs = urls.map((v) =>
v.startsWith("http")
? http(v, { timeout, onFetchRequest: config?.onFetchRequest, onFetchResponse: config?.onFetchResponse })
: webSocket(v, { timeout, keepAlive: true, reconnect: true, onFetchRequest: config?.onFetchRequest, onFetchResponse: config?.onFetchResponse }),
? http(v, {
timeout,
onFetchRequest: config?.onFetchRequest,
onFetchResponse: config?.onFetchResponse,
})
: webSocket(v, {
timeout,
keepAlive: true,
reconnect: true,
}),
);
const fallbacks = (fallbackRpcs[chainId] ?? [])
.filter((v) => !urls.includes(v))
.map((v) =>
v.startsWith("http")
? http(v, { timeout, onFetchRequest: config?.onFetchRequest, onFetchResponse: config?.onFetchResponse })
: webSocket(v, { timeout, keepAlive: true, reconnect: true, onFetchRequest: config?.onFetchRequest, onFetchResponse: config?.onFetchResponse }),
? http(v, {
timeout,
onFetchRequest: config?.onFetchRequest,
onFetchResponse: config?.onFetchResponse,
})
: webSocket(v, {
timeout,
keepAlive: true,
reconnect: true,
}),
);
const transport = !topRpcs.length
? fallback(fallbacks, configuration)
Expand Down
4 changes: 2 additions & 2 deletions test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ describe("Test cli", async function () {
route: "single",
rpcRecords: {
"https://rpc.ankr.com/polygon": {
req: 1,
success: 1,
req: 2,
success: 2,
failure: 0,
},
},
Expand Down

0 comments on commit ac2a926

Please sign in to comment.