From 48f2977175fa0ff577b5181ef5eb2abce8feea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20B=E1=BA=A3o?= <36961697+0xj4m35@users.noreply.github.com> Date: Tue, 10 Dec 2024 10:02:45 +0700 Subject: [PATCH] add CHIPS market-cap (#394) * add CHIPS market-cap Signed-off-by: James Ng * update mnt Signed-off-by: James Ng --------- Signed-off-by: James Ng --- src/index.ts | 2 ++ src/tokens/chips.ts | 26 ++++++++++++++++++++++++++ src/tokens/mnt.ts | 19 ++++++++----------- 3 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 src/tokens/chips.ts diff --git a/src/index.ts b/src/index.ts index d1002c3c..635c9f29 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,6 +30,7 @@ import cerraFetcher from "./tokens/cerra"; import cgiFetcher from "./tokens/cgi"; import charlyFetcher from "./tokens/charly"; import chipFetcher from "./tokens/chip"; +import chipsFetcher from "./tokens/chips"; import clapFetcher from "./tokens/clap"; import clarityFetcher from "./tokens/clarity"; import clayFetcher from "./tokens/clay"; @@ -360,4 +361,5 @@ export const supplyFetchers: Record = { "30d2ebdb2fec06142ee84e5120c2717b4d68a91bffd924420d94ddea43484950": chipFetcher, "86340a33acf14b5c967584c9a20e984695ab3289696d138048f572be4255524e5a": burnzFetcher, "766fce8055f39d40fcfc19721677b3deb2e7846950ae08dce757f1e753554741522042555348": sugarBushFetcher, + "5df9a1b9af5172602cbf8e4ba9c2a608c3820fc6e5d8c5e48f2d907c5468652047697261666665": chipsFetcher, }; diff --git a/src/tokens/chips.ts b/src/tokens/chips.ts new file mode 100644 index 00000000..68adb25f --- /dev/null +++ b/src/tokens/chips.ts @@ -0,0 +1,26 @@ +import { defaultFetcherOptions, SupplyFetcher } from "../types"; +import { getAmountInAddresses, getBlockFrostInstance } from "../utils"; + +const CHIPS = "5df9a1b9af5172602cbf8e4ba9c2a608c3820fc6e5d8c5e48f2d907c5468652047697261666665"; + +const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { + const blockFrost = getBlockFrostInstance(options); + const total = 1_000_000_000; + const treasuryRaw = await getAmountInAddresses(blockFrost, CHIPS, [ + "stake1uxtyqt2qck9mcxek68vqmyyly95a9h7n7qk40gxezp3uxvs9cmtjr", // Treasury + ]); + + const burnRaw = await getAmountInAddresses(blockFrost, CHIPS, [ + "addr1w8qmxkacjdffxah0l3qg8hq2pmvs58q8lcy42zy9kda2ylc6dy5r4", // burn address + ]); + + const treasury = Number(treasuryRaw); + const burn = Number(burnRaw); + + return { + circulating: (total - burn - treasury).toString(), + total: (total - burn).toString(), + }; +}; + +export default fetcher; diff --git a/src/tokens/mnt.ts b/src/tokens/mnt.ts index 9769ffa5..9835bf5d 100644 --- a/src/tokens/mnt.ts +++ b/src/tokens/mnt.ts @@ -1,21 +1,18 @@ import { defaultFetcherOptions, SupplyFetcher } from "../types"; import { getAxiosInstance } from "../utils"; -// eslint-disable-next-line unused-imports/no-unused-vars -const MNT = "43b07d4037f0d75ee10f9863097463fc02ff3c0b8b705ae61d9c75bf"; - -const TOTAL_SUPPLY = 100_000_000; - -const MNT_SUPPLY_ADDRESS = "https://www.mynth.ai/api/token-supply"; - const fetcher: SupplyFetcher = async (options = defaultFetcherOptions) => { const axios = getAxiosInstance(options); - const response = await axios.get(MNT_SUPPLY_ADDRESS); - const treasury = response.data.current_supply; + const [totalSupplyResponse, circulatingResponse] = await Promise.all([ + axios.get("https://www.mynth.ai/api/total-supply"), + axios.get("https://www.mynth.ai/api/current-supply"), + ]); + const totalSupply = Number(totalSupplyResponse.data) / 1e6; + const circulating = Number(circulatingResponse.data) / 1e6; return { - circulating: treasury.toString(), - total: TOTAL_SUPPLY.toString(), + total: totalSupply.toString(), + circulating: circulating.toString(), }; };