Skip to content

Commit d1d4ee4

Browse files
committed
Added ability to monitor multiple tokens concurrently
1 parent 9bb2b4c commit d1d4ee4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- Project Setup :heavy_check_mark:
66
- Initial commit :heavy_check_mark:
77
- Add support for 1inch price aggregator :heavy_check_mark:
8-
- Add ability to monitor multiple tokens concurrently
8+
- Add ability to monitor multiple tokens concurrently :heavy_check_mark:
99
- Add ability to buy and sell tokens across various supported exchanges on different blockchains
1010
- Add support for ethereum blockchain :heavy_check_mark:
1111

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ const Main = async () => {
5959

6060
console.log(`---`.repeat(10));
6161

62-
let ethAmount = new BigNumber(config.ETH_IN_AMOUNT).shiftedBy(18).toString()
62+
let ethInAmount = new BigNumber(config.ETH_IN_AMOUNT).shiftedBy(18).toString()
6363
schedule(`*/${config.PRICE_CHECK_INTERVAL_IN_SECONDS} * * * * *`, async function () {
6464
console.log(`***`.repeat(10));
6565
MONITORED_TOKENS.forEach(async (token: any) => {
6666
try {
6767
const buy_quote: Quote = await oneInch.getQuote({
6868
srcToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
6969
toToken: token.address,
70-
srcAmount: ethAmount
70+
srcAmount: ethInAmount
7171
})
7272
let token_amount = buy_quote.toAmount
7373
const sell_quote: Quote = await oneInch.getQuote({
@@ -91,6 +91,7 @@ const Main = async () => {
9191
};
9292
const timestamp = new Date()
9393
let eth_out = parseFloat(new BigNumber(sell_quote.toAmount).shiftedBy(-sell_quote.toToken.decimals).toFixed(6))
94+
9495
const profit_pct = ((eth_out - config.ETH_IN_AMOUNT) / config.ETH_IN_AMOUNT) * 100
9596
let token_out = parseFloat(new BigNumber(token_amount).shiftedBy(-buy_quote.toToken.decimals).toFixed(6))
9697
let best_buy_protocols = (await flat(buy_quote.protocols)).map((quote: any) => quote.name).join(',')
@@ -107,7 +108,7 @@ const Main = async () => {
107108
rate: `${config.PRICE_CHECK_INTERVAL_IN_SECONDS}s`
108109
},
109110
]);
110-
if (!(JSON.stringify(best_buy_protocols) == JSON.stringify(best_sell_protocols))) {
111+
if (JSON.stringify(best_buy_protocols) != JSON.stringify(best_sell_protocols)) {
111112
console.log(table);
112113
}
113114

0 commit comments

Comments
 (0)