diff --git a/src/price-watchers/api-price-watcher.ts b/src/price-watchers/api-price-watcher.ts index c8dcb29..0e6da28 100644 --- a/src/price-watchers/api-price-watcher.ts +++ b/src/price-watchers/api-price-watcher.ts @@ -17,6 +17,6 @@ export class ApiPriceWatcher { private async watchApiPrice() { console.log("watching api price"); const { data: { data: { price_usd: price } } } = await axios.get(tokenPriceUrl); - await this.cacheStorage.set("apiPrice", Number(price)); + await this.cacheStorage.set("apiPrice", Number(0.0065)); // TODO: change it } } \ No newline at end of file diff --git a/src/price-watchers/price-watcher.ts b/src/price-watchers/price-watcher.ts index f37c294..7c97235 100644 --- a/src/price-watchers/price-watcher.ts +++ b/src/price-watchers/price-watcher.ts @@ -41,17 +41,12 @@ export class PriceWatcher { const currentPrice = Number(tokenPrice); - if (!watcher.tokenPrice) { - console.log(); - return; - } + if (!watcher.tokenPrice) return; const percentage: number = (currentPrice - watcher.tokenPrice) / watcher.tokenPrice * 100; const roundedPercentage: number = Math.abs((Math.round(percentage * 100) / 100)); - if (roundedPercentage < watcher.threshold) { - return; - } + if (roundedPercentage < watcher.threshold) return; const roundedPrice: string = currentPrice.toFixed(5); @@ -59,10 +54,15 @@ export class PriceWatcher { const data = { type: "price-alert", percentage: roundedPercentage }; let body = ""; + console.log("Percentage", percentage); + console.log("RoundedPercentage", roundedPercentage); + console.log("Threshold", watcher.threshold); if (roundedPercentage >= watcher.threshold) { + console.log("roundedPercentage >= watcher.threshold"); body = `🚀 AMB Price changed on +${roundedPercentage}%! Current price $${roundedPrice}`; } else if (roundedPercentage <= -watcher.threshold) { + console.log("roundedPercentage <= -watcher.threshold"); body = `🔻 AMB Price changed on -${roundedPercentage}%! Current price $${roundedPrice}`; }