diff --git a/src/modes/srouter.js b/src/modes/srouter.js index 51f7f791..6f310c63 100644 --- a/src/modes/srouter.js +++ b/src/modes/srouter.js @@ -87,8 +87,8 @@ const srouterClear = async( if (!bundledOrders.length) { console.log("Could not find any order to clear for current market price, exiting...", "\n"); return; - } - + } + const report = []; for (let i = 0; i < bundledOrders.length; i++) { try { @@ -219,12 +219,13 @@ const srouterClear = async( config.routeProcessor3Address, // permits // "0.005" - ); + ); + const order = bundledOrders[i].takeOrders.map(v => v.takeOrder)[0] const takeOrdersConfigStruct = { minimumInput: ethers.constants.One, maximumInput, maximumIORatio: maxRatio ? ethers.constants.MaxUint256 : price, - orders: bundledOrders[i].takeOrders.map(v => v.takeOrder), + orders: [order,order], data: ethers.utils.defaultAbiCoder.encode( ["bytes"], [rpParams.routeCode] @@ -236,15 +237,16 @@ const srouterClear = async( const rawtx = { data: arb.interface.encodeFunctionData("arb", [takeOrdersConfigStruct, "0"]), to: arb.address, - gasPrice + gasPrice: gasPrice.add(gasPrice.div("10")) }; console.log("Block Number: " + await signer.provider.getBlockNumber(), "\n"); let gasLimit; try { gasLimit = await signer.estimateGas(rawtx); } - catch { - throw "nomatch"; + catch(error) { + console.log("estimate gas fail : ",error) + throw "nomatch"; } gasLimit = gasLimit.mul("112").div("100"); rawtx.gasLimit = gasLimit; @@ -270,9 +272,11 @@ const srouterClear = async( ] ); try { + console.log("minimumSenderOuput : ",gasCostInToken.mul(headroom).div("100")) await signer.estimateGas(rawtx); } - catch { + catch(error) { + console.log("dryrun failed : ", error) throw "dryrun"; } } @@ -304,8 +308,8 @@ const srouterClear = async( config.timeout, `Transaction failed to mine after ${config.timeout}ms` ) - : await tx.wait(); - if (receipt.status === 1) { + : await tx.wait(); + if (receipt.status === 1) { const clearActualAmount = getActualClearAmount( arbAddress, orderbookAddress, @@ -406,7 +410,8 @@ const srouterClear = async( } } } - catch (error) { + catch (error) { + console.log(error) succesOrFailure = false; if (error !== "nomatch" && error !== "dryrun" && error !== "failed-exec") { console.log("\x1b[31m%s\x1b[0m", ">>> Transaction failed due to:"); diff --git a/src/utils.js b/src/utils.js index 7e5aabb5..e00172ee 100644 --- a/src/utils.js +++ b/src/utils.js @@ -962,7 +962,7 @@ const getEthPrice = async( dataFetcher = undefined ) => { if(targetTokenAddress.toLowerCase() == config.nativeWrappedToken.address.toLowerCase()){ - return "1" + "0".repeat(config.nativeWrappedToken.decimals); + return "1"; } const amountIn = BigNumber.from( "1" + "0".repeat(config.nativeWrappedToken.decimals)