Skip to content

Commit

Permalink
Merge pull request #420 from hummingbot/metrics
Browse files Browse the repository at this point in the history
(fix) js metrics
  • Loading branch information
fengtality authored Nov 30, 2024
2 parents 32d6a0e + bc799c8 commit 725a3fd
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 39 deletions.
8 changes: 4 additions & 4 deletions docs/about/hbot.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Learn more about the HBOT token in the [original launch post](../blog/posts/intr
| Symbol | HBOT |
| Name | Hummingbot Governance Token |
| Total Supply (fixed at genesis) | 1,000,000,000 HBOT |
| Circulating Supply | {{ circulating_supply() }} HBOT |
| Current Price (CoinGecko) | ${{ hbot_price() }} |
| Market Capitalization | ${{ market_cap() }} |
| Fully Diluted Valuation | ${{ fully_diluted_value() }} |
| Circulating Supply | <span id="circulating-supply">...</span> HBOT |
| Current Price (CoinGecko) | $<span id="hbot-price">...</span> |
| Market Capitalization | $<span id="market-cap">...</span> |
| Fully Diluted Valuation | $<span id="fdv">...</span> |

## HBOT Data Sites

Expand Down
40 changes: 40 additions & 0 deletions docs/assets/js/hbot-stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
async function updateHBOTStats() {
try {
// Get HBOT price
const priceResponse = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=hummingbot&vs_currencies=usd');
const priceData = await priceResponse.json();
const price = priceData.hummingbot.usd;

// Get circulating supply
const supplyResponse = await fetch('https://script.googleusercontent.com/macros/echo?user_content_key=N4n4qQVTKApqGc2int0KWqnepzV2kV38ue_DhxNyGkX-q4V6BwcSbcUYRulrmn3J4-m-9-rbax0QtMuLYtcEvnwE87sOlQEgm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnH1LtfJpvsx6ko-sqM14URZmZ3jYd3cBL80m9K3ehDaYBabPl9oGCLEKQlYYtvNTgmPDw6d8UvRjIjfxHAj5tMsQoE6T5t6l9Q&lib=M0hBf2ltttBRyRQ7geRilVBeMw4PaOM-o');
const supplyData = await supplyResponse.json();
const supply = parseFloat(supplyData.circulating_supply);

// Calculate market cap and fully diluted value
const TOTAL_SUPPLY = 1000000000;
const marketCap = price * supply;
const fdv = price * TOTAL_SUPPLY;

// Update DOM elements
const elements = {
'hbot-price': price.toFixed(4),
'circulating-supply': Math.round(supply).toLocaleString(),
'market-cap': Math.round(marketCap).toLocaleString(),
'fdv': Math.round(fdv).toLocaleString()
};

for (const [id, value] of Object.entries(elements)) {
const element = document.getElementById(id);
if (element) element.textContent = value;
}
} catch (error) {
console.error('Error updating HBOT stats:', error);
}
}

// Wait for DOM to be ready
document.addEventListener('DOMContentLoaded', () => {
// Update immediately and then every 30 seconds
updateHBOTStats();
setInterval(updateHBOTStats, 30000);
});
2 changes: 0 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ dependencies:
- mkdocs-git-revision-date-localized-plugin
- mkdocs-table-reader-plugin
- mkdocs-charts-plugin
- mkdocs-macros-plugin
- requests
- pip
- pip:
- git+ssh://[email protected]/hummingbot/mkdocs-material-insiders
32 changes: 0 additions & 32 deletions main.py

This file was deleted.

2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ theme:
plugins:
- search
- charts
- macros
- table-reader
- git-revision-date-localized
- social:
Expand Down Expand Up @@ -115,6 +114,7 @@ extra_javascript:
- https://cdn.jsdelivr.net/npm/vega@5
- https://cdn.jsdelivr.net/npm/vega-lite@5
- https://cdn.jsdelivr.net/npm/vega-embed@6
- assets/js/hbot-stats.js

# Extensions
markdown_extensions:
Expand Down

0 comments on commit 725a3fd

Please sign in to comment.