Skip to content

Commit

Permalink
add block number to logs
Browse files Browse the repository at this point in the history
- shorten repeatative large data
  • Loading branch information
rouzwelt committed Aug 24, 2023
1 parent a90a905 commit 173bf35
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 55 deletions.
4 changes: 3 additions & 1 deletion docs/html/curve.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ <h1 class="page-title">Source: curve.js</h1>
);
if (ethPrice === undefined) console.log("can not get ETH price, skipping...", "\n");
else {
console.log("Block Number: " + await signer.provider.getBlockNumber());
const gasLimit = await arb.estimateGas.arb(
takeOrdersConfigStruct,
// set to zero for estimation
Expand Down Expand Up @@ -520,6 +521,7 @@ <h1 class="page-title">Source: curve.js</h1>
36 - bundledOrders[i].buyTokenDecimals
)
);
console.log("Block Number: " + await signer.provider.getBlockNumber());
const tx = await arb.arb(
takeOrdersConfigStruct,
// set to zero because only profitable transactions are submitted
Expand Down Expand Up @@ -657,7 +659,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:38:57 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:57:16 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 2 additions & 2 deletions docs/html/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -5622,7 +5622,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line1007">line 1007</a>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line1006">line 1006</a>
</li></ul></dd>


Expand Down Expand Up @@ -6606,7 +6606,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:38:57 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:57:16 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:38:57 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:57:16 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:38:57 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:57:16 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/query.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:38:57 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:57:16 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 3 additions & 1 deletion docs/html/router.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ <h1 class="page-title">Source: router.js</h1>
);
if (ethPrice === undefined) console.log("can not get ETH price, skipping...", "\n");
else {
console.log("Block Number: " + await signer.provider.getBlockNumber());
const gasLimit = await arb.estimateGas.arb(
takeOrdersConfigStruct,
// set to zero because only profitable transactions are submitted
Expand Down Expand Up @@ -449,6 +450,7 @@ <h1 class="page-title">Source: router.js</h1>
36 - bundledOrders[i].buyTokenDecimals
)
);
console.log("Block Number: " + await signer.provider.getBlockNumber());
const tx = await arb.arb(
takeOrdersConfigStruct,
// set to zero because only profitable transactions are submitted
Expand Down Expand Up @@ -588,7 +590,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:38:57 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:57:16 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
47 changes: 23 additions & 24 deletions docs/html/utils.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ <h1 class="page-title">Source: utils.js</h1>
const orgConsole = console[methodName];
console[methodName] = function (...params) {
const modifiedParams = [];
const shortenedLogs = [];
for (let i = 0; i &lt; params.length; i++) {
let logItem = params[i];
if (
Expand All @@ -985,35 +986,33 @@ <h1 class="page-title">Source: utils.js</h1>
"**********"
);
}
// let _skipFirst = true;
// logItem = logItem.replace(
// largeDataPattern,
// largeData => {
// if (_skipFirst) {
// _skipFirst = false;
// return largeData;
// }
// else return largeData.slice(0, 67) + "...";
// }
// );
logItem = logItem.replace(
largeDataPattern,
largeData => {
if (!shortenedLogs.includes(largeData)) {
shortenedLogs.push(largeData);
return largeData;
}
else return largeData.slice(0, 67) + "...";
}
);
}
else if (typeof logItem === "object" &amp;&amp; logItem !== null) {
logItem = objStringify(logItem);
if (scrub) for (let j = 0; j &lt; _data.length; j++) {
logItem = objStrReplacer(logItem, _data[j], "**********");
}
// let _skipFirst = true;
// logItem = objStrReplacer(
// logItem,
// largeDataPattern,
// largeData => {
// if (_skipFirst) {
// _skipFirst = false;
// return largeData;
// }
// else return largeData.slice(0, 67) + "...";
// }
// );
logItem = objStrReplacer(
logItem,
largeDataPattern,
largeData => {
if (!shortenedLogs.includes(largeData)) {
shortenedLogs.push(largeData);
return largeData;
}
else return largeData.slice(0, 67) + "...";
}
);
}
modifiedParams.push(logItem);
}
Expand Down Expand Up @@ -1082,7 +1081,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:38:57 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:57:16 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 3 additions & 1 deletion docs/html/zeroex.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ <h1 class="page-title">Source: zeroex.js</h1>
);
console.log(">>> Estimating the profit for this token pair...", "\n");
let gasLimit;
console.log("Block Number: " + await signer.provider.getBlockNumber());
if (mode) gasLimit = await arb.estimateGas.arb(
takeOrdersConfigStruct,
0,
Expand Down Expand Up @@ -471,6 +472,7 @@ <h1 class="page-title">Source: zeroex.js</h1>
)
);
let tx;
console.log("Block Number: " + await signer.provider.getBlockNumber());
if (mode) tx = await arb.arb(
takeOrdersConfigStruct,
gasCostInToken.mul(gasCoveragePercentage).div(100),
Expand Down Expand Up @@ -633,7 +635,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:38:57 GMT+0000 (Coordinated Universal Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Aug 24 2023 17:57:16 GMT+0000 (Coordinated Universal Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 2 additions & 0 deletions src/curve.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ const curveClear = async(
);
if (ethPrice === undefined) console.log("can not get ETH price, skipping...", "\n");
else {
console.log("Block Number: " + await signer.provider.getBlockNumber());
const gasLimit = await arb.estimateGas.arb(
takeOrdersConfigStruct,
// set to zero for estimation
Expand Down Expand Up @@ -492,6 +493,7 @@ const curveClear = async(
36 - bundledOrders[i].buyTokenDecimals
)
);
console.log("Block Number: " + await signer.provider.getBlockNumber());
const tx = await arb.arb(
takeOrdersConfigStruct,
// set to zero because only profitable transactions are submitted
Expand Down
2 changes: 2 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ const routerClear = async(
);
if (ethPrice === undefined) console.log("can not get ETH price, skipping...", "\n");
else {
console.log("Block Number: " + await signer.provider.getBlockNumber());
const gasLimit = await arb.estimateGas.arb(
takeOrdersConfigStruct,
// set to zero because only profitable transactions are submitted
Expand Down Expand Up @@ -421,6 +422,7 @@ const routerClear = async(
36 - bundledOrders[i].buyTokenDecimals
)
);
console.log("Block Number: " + await signer.provider.getBlockNumber());
const tx = await arb.arb(
takeOrdersConfigStruct,
// set to zero because only profitable transactions are submitted
Expand Down
45 changes: 22 additions & 23 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ const appGlobalLogger = (scrub, ...data) => {
const orgConsole = console[methodName];
console[methodName] = function (...params) {
const modifiedParams = [];
const shortenedLogs = [];
for (let i = 0; i < params.length; i++) {
let logItem = params[i];
if (
Expand All @@ -957,35 +958,33 @@ const appGlobalLogger = (scrub, ...data) => {
"**********"
);
}
// let _skipFirst = true;
// logItem = logItem.replace(
// largeDataPattern,
// largeData => {
// if (_skipFirst) {
// _skipFirst = false;
// return largeData;
// }
// else return largeData.slice(0, 67) + "...";
// }
// );
logItem = logItem.replace(
largeDataPattern,
largeData => {
if (!shortenedLogs.includes(largeData)) {
shortenedLogs.push(largeData);
return largeData;
}
else return largeData.slice(0, 67) + "...";
}
);
}
else if (typeof logItem === "object" && logItem !== null) {
logItem = objStringify(logItem);
if (scrub) for (let j = 0; j < _data.length; j++) {
logItem = objStrReplacer(logItem, _data[j], "**********");
}
// let _skipFirst = true;
// logItem = objStrReplacer(
// logItem,
// largeDataPattern,
// largeData => {
// if (_skipFirst) {
// _skipFirst = false;
// return largeData;
// }
// else return largeData.slice(0, 67) + "...";
// }
// );
logItem = objStrReplacer(
logItem,
largeDataPattern,
largeData => {
if (!shortenedLogs.includes(largeData)) {
shortenedLogs.push(largeData);
return largeData;
}
else return largeData.slice(0, 67) + "...";
}
);
}
modifiedParams.push(logItem);
}
Expand Down
2 changes: 2 additions & 0 deletions src/zeroex.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ const zeroExClear = async(
);
console.log(">>> Estimating the profit for this token pair...", "\n");
let gasLimit;
console.log("Block Number: " + await signer.provider.getBlockNumber());
if (mode) gasLimit = await arb.estimateGas.arb(
takeOrdersConfigStruct,
0,
Expand Down Expand Up @@ -443,6 +444,7 @@ const zeroExClear = async(
)
);
let tx;
console.log("Block Number: " + await signer.provider.getBlockNumber());
if (mode) tx = await arb.arb(
takeOrdersConfigStruct,
gasCostInToken.mul(gasCoveragePercentage).div(100),
Expand Down

0 comments on commit 173bf35

Please sign in to comment.