Skip to content

Commit

Permalink
feat: add logs for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
serezhaolshan committed Aug 28, 2024
1 parent 3905c4c commit c0bb034
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/price-watchers/api-price-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
14 changes: 7 additions & 7 deletions src/price-watchers/price-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ 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);

const title = notificationsTitleConfig[appEnv].priceAlert;
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}`;
}

Expand Down

0 comments on commit c0bb034

Please sign in to comment.