Skip to content

Instantly share code, notes, and snippets.

// https://codeakk.medium.com/hex-development-data-a1b1822446fa
// https://togosh.medium.com/hex-developer-guide-3b018a943a55
// https://nomics.com/docs/#operation/getCurrenciesTicker
test();
async function test(){
var price = await getPrice();
console.log("Price: $" + Number(price).toLocaleString(undefined, {minimumFractionDigits:2, maximumFractionDigits:2}));
}
// JSON API --- https://hexdailystats.com/fulldata
// JSON API --- https://hexdailystats.com/livedata
// https://codeakk.medium.com/hex-development-data-a1b1822446fa
// https://togosh.medium.com/hex-developer-guide-3b018a943a55
// NOTE: New rows of historical full data usually get added into database about 20 minutes after 00:00:00 UTC every day
// NOTE: Live data updates every 1 minute
// TEST: Copy and run code with online javascript compiler --- https://jsfiddle.net/
@togosh
togosh / currentDayHEX.js
Created September 23, 2021 03:40
Current Day of HEX
// https://codeakk.medium.com/hex-development-data-a1b1822446fa
// https://togosh.medium.com/hex-developer-guide-3b018a943a55
// https://etherscan.io/apis
test();
async function test(){
var currentDay = await getCurrentDay();
console.log("Current Day: " + Number(currentDay).toLocaleString(undefined, {minimumFractionDigits:0, maximumFractionDigits:0}));
}
@togosh
togosh / liquidityOfHEXUniswapV2V3.js
Last active April 12, 2023 01:25
Liquidity of HEX, USDC, ETH, DAI trading pairs - Uniswap V2 & V3
// https://codeakk.medium.com/hex-development-data-a1b1822446fa
// https://togosh.medium.com/hex-developer-guide-3b018a943a55
// https://thegraph.com/legacy-explorer/subgraph/uniswap/uniswap-v2
// https://thegraph.com/legacy-explorer/subgraph/uniswap/uniswap-v3
test();
async function test(){
console.log("=== Uniswap V2");
var { liquidityUV2_HEXUSDC, liquidityUV2_USDC } = await getUniswapV2HEXUSDC_Polling(); await sleep(1000);
@togosh
togosh / nodeFetchRetryJSON.js
Last active September 23, 2021 07:54
Node Fetch Retry for JSON APIs - https://github.com/jonbern/fetch-retry
// https://codeakk.medium.com/hex-development-data-a1b1822446fa
// https://togosh.medium.com/hex-developer-guide-3b018a943a55
// https://github.com/jonbern/fetch-retry
// https://github.com/node-fetch/node-fetch/blob/main/README.md#custom-highwatermark
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
var fetchRetry = require('fetch-retry')(fetch, {
retryOn: async function(attempt, error, response) {
if (attempt > 3) { return false; }
@togosh
togosh / currencyRateCalculatorHEX.js
Last active October 17, 2021 09:33
Currency Rate Calculator for HEX --- https://exchangeratesapi.io/
// https://exchangeratesapi.io/ - Replace XXXXXXXXXXXXX with API Key
//////////////////////////////////////////////////////////
// SERVER
const schedule = require('node-schedule');
io = require('socket.io')(httpServer)
var jobCurrencyRates = schedule.scheduleJob("0 */3 * * *", function() {
getCurrencyData();
@togosh
togosh / totalValueLockedHEX.js
Created October 28, 2021 17:39
Total Value Locked of HEX
// https://codeakk.medium.com/hex-development-data-a1b1822446fa
// https://togosh.medium.com/hex-developer-guide-3b018a943a55
// https://thegraph.com/legacy-explorer/subgraph/uniswap/uniswap-v2
// https://thegraph.com/legacy-explorer/subgraph/uniswap/uniswap-v3
// https://etherscan.io/apis
// NOTE: REPLACE XXXXXXXX with Etherscan API Key
test();
async function test(){
@togosh
togosh / ethereumPriceAndGasFees.js
Created November 3, 2021 07:46
Ethereum Price and Gas Fees
var priceURL = "https://api.etherscan.io/api?module=stats&action=ethprice&apikey=YourApiKeyToken"
var gasURL = "https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=YourApiKeyToken";
test();
async function test(){
var price = await getEthereumPrice();
await sleep(5000);
@togosh
togosh / averagePayoutPerTshareHEXfast.js
Last active November 5, 2021 02:02
Average Payout per Tshare of HEX between Days - Codeak API - Fast
// https://codeakk.medium.com/hex-development-data-a1b1822446fa
// https://togosh.medium.com/hex-developer-guide-3b018a943a55
test()
async function test(){
var startDay = 700; // 2 or higher
var endDay = 702;
var data = await get_dailyDataUpdateData();
@togosh
togosh / allStakeDataHEX.js
Created November 7, 2021 19:45
Get All Historical Stake Data of HEX - for Jose (hex_crypto_bull) - Outputs 3 CSV files
//"dependencies": {
// "fetch-retry": "^5.0.1",
// "node-fetch": "^3.0.0"
// }
// Get all historical stake data by HEX day
//// Created for Jose (https://www.reddit.com/user/hex_crypto_bull/)
//Three CSV tables:
//- issued_cds (stakeStarts) // Desired: hex_staked>0 and shares>0