Giter VIP home page Giter VIP logo

supply-info-api's Introduction

Supply Info API

An API for basic info about the any cosmos token supply.

The base route / returns all info in JSON:

{
  "apr": 0.5356138011434268,
  "bondedRatio": 0.26138236113619256,
  "circulatingSupply": "1035311800.378731",
  "communityPool": "4863561.388632",
  "denom": "UMEE",
  "totalStaked": "2677292310.820958",
  "totalSupply": "10242819366.934873"
}

Other routes

  • /circulating-supply: returns circulating supply in plain text
  • /total-supply: returns total supply in plain text
  • /community-pool: returns community pool size in plain text
  • /denom: returns denom in plain text

How to use?

⚠️ This example for Umee network:

Parse vesting accounts:

cd $HOME
git clone https://github.com/NodesGuru/supply-info-api.git
cd ~/supply-info-api
cp .env.example .env # you can find working .env for umee network in the umee folder
cd umee
wget https://github.com/umee-network/mainnet/raw/main/genesis.json
cat genesis.json | jq -r '.app_state.auth.accounts[] | select(."@type" | contains ("vesting")) | .base_vesting_account.base_account.address' > vesting_accounts_unformatted
sed -i '$ d' vesting_accounts_unformatted
tr '\n' ',' < vesting_accounts_unformatted > vesting_accounts
sed -i '$ s/.$//' vesting_accounts
sed -i '$ d' ~/supply-info-api/.env
echo "VESTING_ACCOUNTS=$(cat vesting_accounts)" >> ~/supply-info-api/.env

Test with the progress bar:

⚠️ Do not forget to install NodeJS and (optional) Yarn

cd ~/supply-info-api
yarn # or npm install
yarn start # or npm run start

Press Ctrl + C to exit.

Run as systemd service:

echo "[Unit]
Description=Supply Info API
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/supply-info-api
ExecStart=$(which yarn) --cwd $HOME/supply-info-api/ start
Restart=always
RestartSec=1
LimitNOFILE=10000
[Install]
WantedBy=multi-user.target" > $HOME/supply-api-umee.service
sudo mv $HOME/supply-api-umee.service /etc/systemd/system/supply-api-umee.service
sudo systemctl daemon-reload
sudo systemctl enable supply-api-umee
sudo systemctl restart supply-api-umee
journalctl -u supply-api-umee -f -o cat

Test:

curl localhost:3000 | jq .

How circulating supply is calculated

  1. Get total supply.
  2. Get community pool.
  3. Subtract community pool from total supply.
  4. Iterate through list of vesting amounts for large accounts (like the Dev Fund), and subtract the vesting ammount from total supply.

This yields the circulating supply.

Vesting accounts are provided by an environment variable. See .env.example for an example.

supply-info-api's People

Contributors

kinrokinro avatar jakehartnell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.