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

bundle router #35

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 16 additions & 11 deletions src/modes/srouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
if (!bundledOrders.length) {
console.log("Could not find any order to clear for current market price, exiting...", "\n");
return;
}

}

Check failure on line 90 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Trailing spaces not allowed

Check failure on line 91 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Trailing spaces not allowed
const report = [];
for (let i = 0; i < bundledOrders.length; i++) {
try {
Expand Down Expand Up @@ -219,12 +219,13 @@
config.routeProcessor3Address,
// permits
// "0.005"
);
);

Check failure on line 222 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Trailing spaces not allowed
const order = bundledOrders[i].takeOrders.map(v => v.takeOrder)[0]

Check failure on line 223 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Missing semicolon
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]
Expand All @@ -236,15 +237,16 @@
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)

Check failure on line 248 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Missing semicolon
throw "nomatch";

Check failure on line 249 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Expected indentation of 28 spaces but found 29
}
gasLimit = gasLimit.mul("112").div("100");
rawtx.gasLimit = gasLimit;
Expand All @@ -270,9 +272,11 @@
]
);
try {
console.log("minimumSenderOuput : ",gasCostInToken.mul(headroom).div("100"))

Check failure on line 275 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Missing semicolon
await signer.estimateGas(rawtx);
}
catch {
catch(error) {

Check failure on line 278 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Trailing spaces not allowed
console.log("dryrun failed : ", error)

Check failure on line 279 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Missing semicolon
throw "dryrun";
}
}
Expand Down Expand Up @@ -304,8 +308,8 @@
config.timeout,
`Transaction failed to mine after ${config.timeout}ms`
)
: await tx.wait();
if (receipt.status === 1) {
: await tx.wait();

Check failure on line 311 in src/modes/srouter.js

View workflow job for this annotation

GitHub Actions / Build, lint, test

Trailing spaces not allowed
if (receipt.status === 1) {
const clearActualAmount = getActualClearAmount(
arbAddress,
orderbookAddress,
Expand Down Expand Up @@ -406,7 +410,8 @@
}
}
}
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:");
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading