Socket
Socket
Sign inDemoInstall

@muesliswap/market-cap

Package Overview
Dependencies
59
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @muesliswap/market-cap

Transparent and accurate market cap for Cardano native tokens


Version published
Weekly downloads
57
increased by1800%
Maintainers
1
Install size
13.3 MB
Created
Weekly downloads
 

Readme

Source

Market Cap

This is the fork used by MuesliSwap to display market cap information on tokens

Transparent, accurate and open-sourced circulating supply and market cap calculation for Cardano's native tokens.

Overview

This package doesn't expose market cap by itself, but only circulating supply and total supply.

Market cap = Circulating supply * Market price

Fully-diluted market cap = Total supply * Market price

You can use Blockfrost Adapter to query market price from Minswap.

Install

  • NPM: npm install @muesliswap/market-cap
  • Yarn: yarn add @muesliswap/market-cap

Usage

import { supplyFetchers } from "@muesliswap/market-cap";

const minInfo = await supplyFetchers[
  "29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e"
]();
console.log(minInfo);
// { circulating: '240813714.66121483', total: '5000000000' }

How to add my token

  1. Create a file in src/tokens with your token's name and export default a function of type SupplyFetcher.
  2. Import the function into src/index.ts and add the corresponding entry in supplyFetchers map with the key being the concatenation of your token's policyID and assetName
  3. Test your function:
# only if you use Blockfrost
export BLOCKFROST_PROJECT_ID=<your_blockfrost_key>
ONLY_TEST=<your_policy_id_concat_with_asset_name> npm test
  1. Run format: npm run format

Example

  1. MIN token fetcher: src/tokens/min.ts
  2. Add entry to index.ts:
import minFetcher from "./tokens/min";

export const supplyFetchers: Record<string, SupplyFetcher> = {
  "29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e": minFetcher,
  ...
};
  1. Run test:
export BLOCKFROST_PROJECT_ID=<your_blockfrost_key>
ONLY_TEST=29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e npm test

Keywords

FAQs

Last updated on 15 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc