diff --git a/README.md b/README.md index 6babe59b..af8a990c 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,11 @@ This app requires NodeJS v18 or higher to run and is docker ready. This app can also be run in Github Actions with a cron job, please read below for more details. ## The Case for Profitability -Profitablity can be adjusted by using an integer ≥0 for `--gas-coverage` as the percentage of the gas cost of the transaction, denominated in receiving ERC20 token, the cost of the transaction is calculated in the receiving ERC20 token unit with current market best price. +Profitablity can be adjusted by using an integer ≥0 for `--gas-coverage` arg as the percentage of the gas cost of the transaction, denominated in receiving ERC20 token, the cost of the transaction is calculated in the receiving ERC20 token unit with current market price of that token against chain's native token. -- If set to 100, the receiving profit must be at least equal or greater than gas cost. -- If set above 100, the receiving profit must be more than the amount of gas cost, for example a transaction costs 0.01 USDT (calculated from network's gas token i.e. ETH to receiving ERC20 token i.e. USDT or USDC or ...) and a value of 500 means the profit must be at least 5x the amount of gas used i.e. ≥0.05 USDT for the transaction to be successfull. +for example: +- If set to 100, the receiving profit must be at least equal or greater than tx gas cost. +- If set above 100, the receiving profit must be more than the amount of gas cost, for example a transaction costs 0.01 USDT (calculated by current market price of ETH/USDT) and a value of 500 means the profit must be at least 5x the amount of gas used i.e. ≥0.05 USDT for the transaction to be successfull, so at least 0.04 USDT profit will be guaranteed. - If set to 0, profitablity becomes irrevelant meaning any match will be submitted irrespective of whether or not the transaction will be profitable. ## Tutorial @@ -71,7 +72,6 @@ Other optional arguments are: - `--repetitions`, Option to run `number` of times, if unset will run for infinte number of times - `--order-hash`, Option to filter the subgraph query results with a specific order hash, Will override the 'ORDER_HASH' in env variables - `--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 - `--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 @@ -180,9 +180,6 @@ ORDER_HASH="" # Option to filter the subgraph query results with a specific order owner address 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 @@ -249,7 +246,7 @@ const subgraphs = ["https://api.thegraph.com/subgraphs/name/xxx/yyy"] // arr const sgFilters = { // filters for subgraph query (each filter is optional) orderHash : "0x1234...", orderOwner : "0x1234...", - orderInterpreter : "0x1234..." + orderbook : "0x1234..." } // get the order details from the sources diff --git a/cli.js b/cli.js index 1783a59d..7108adc3 100755 --- a/cli.js +++ b/cli.js @@ -25,7 +25,6 @@ const ENV_OPTIONS = { repetitions : process?.env?.REPETITIONS, orderHash : process?.env?.ORDER_HASH, orderOwner : process?.env?.ORDER_OWNER, - orderInterpreter : process?.env?.ORDER_INTERPRETER, sleep : process?.env?.SLEEP, maxRatio : process?.env?.MAX_RATIO?.toLowerCase() === "true" ? true : false, bundle : process?.env?.NO_BUNDLE?.toLowerCase() === "true" ? false : true, @@ -55,7 +54,6 @@ const getOptions = async argv => { .option("--repetitions ", "Option to run `number` of times, if unset will run for infinte number of times") .option("--order-hash ", "Option to filter the subgraph query results with a specific order hash, Will override the 'ORDER_HASH' in env variables") .option("--order-owner
", "Option to filter the subgraph query results with a specific order owner address, Will override the 'ORDER_OWNER' in env variables") - .option("--order-interpreter
", "Option to filter the subgraph query results with a specific order's interpreter address, Will override the 'ORDER_INTERPRETER' in env variables") .option("--sleep ", "Seconds to wait between each arb round, default is 10, Will override the 'SLEPP' in env variables") .option("--flashbot-rpc ", "Optional flashbot rpc url to submit transaction to, Will override the 'FLASHBOT_RPC' in env variables") .option("--timeout ", "Optional seconds to wait for the transaction to mine before disregarding it, Will override the 'TIMEOUT' in env variables") @@ -87,7 +85,6 @@ const getOptions = async argv => { 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.maxRatio = cmdOptions.maxRatio || ENV_OPTIONS.maxRatio; cmdOptions.flashbotRpc = cmdOptions.flashbotRpc || ENV_OPTIONS.flashbotRpc; cmdOptions.timeout = cmdOptions.timeout || ENV_OPTIONS.timeout; @@ -139,9 +136,9 @@ const arbRound = async (tracer, roundCtx, options) => { options.orders, config.signer, { - orderHash : options.orderHash, - orderOwner : options.orderOwner, - orderInterpreter: options.orderInterpreter + orderHash: options.orderHash, + orderOwner: options.orderOwner, + orderbook: options.orderbookAddress, }, span ); diff --git a/example.env b/example.env index 08ee327a..bed1491f 100644 --- a/example.env +++ b/example.env @@ -40,9 +40,6 @@ ORDER_HASH="" # Option to filter the subgraph query results with a specific order owner address 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 diff --git a/src/index.js b/src/index.js index 0bf20b55..8beae3ef 100644 --- a/src/index.js +++ b/src/index.js @@ -108,7 +108,7 @@ const getOrderDetails = async(sgs, json, signer, sgFilters, span) => { query: getQuery( sgFilters?.orderHash, sgFilters?.orderOwner, - sgFilters?.orderInterpreter + sgFilters?.orderbook ) }, { headers: { "Content-Type": "application/json" } } diff --git a/src/query.js b/src/query.js index 6897f79f..c0e09df0 100644 --- a/src/query.js +++ b/src/query.js @@ -1,50 +1,15 @@ -/** - * The default query used in the matchmaker bot to fetch the orders from subgraph - */ -const DefaultQuery = `{ - orders(where: {active: true}) { - id - owner - orderHash - orderBytes - active - nonce - inputs { - id - balance - vaultId - token { - address - decimals - name - symbol - } - } - outputs { - id - balance - vaultId - token { - address - decimals - name - symbol - } - } - } -}`; - /** * Method to get the subgraph query body with optional filters * @param {string} orderHash - The order hash to apply as filter * @param {string} owner - The order owner to apply as filter + * @param {string} orderbook - The orderbook address * @returns the query string */ -const getQuery = (orderHash, owner) => { +const getQuery = (orderHash, owner, orderbook) => { const ownerFilter = owner ? `, owner :"${owner.toLowerCase()}"` : ""; const orderHashFilter = orderHash ? `, orderHash :"${orderHash.toLowerCase()}"` : ""; return `{ - orders(where: {active: true${orderHashFilter}${ownerFilter}}) { + orders(where: {active: true, orderbook: "${orderbook.toLowerCase()}"${orderHashFilter}${ownerFilter}}) { id owner orderHash @@ -82,7 +47,6 @@ const statusCheckQuery = `{ }`; module.exports = { - DefaultQuery, getQuery, statusCheckQuery -}; \ No newline at end of file +};