npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

divicalculatorfunctions

v2.2.5

Published

Calculate Divi Rewards

Downloads

27

Readme

Divi Calculations

Please keep in mind these docs are still under construction. May be missing information on certain functions.

Financial Calculator

Functions

Calculate Return on investment

calculateROI (costOfInvestment, currentValue)

Description: Calculates return on investment.

Example

const fCalc = new FinancialCalculator()

fCalc.calculateROI(100, 4) // -0.96 (-96%)
fCalc.calculateROI(100, 200) // +1 (100%)

Calculate Compound Anual Growth Rate

calculateCAGR (costOfInvestment, currentValue, reinvestmentPeriods)

Description: Calculates growth rate when reinvested.

Example

const fCalc = new FinancialCalculator()

fCalc.calculateCAGR(100, 4, 2) // -0.8 (-80%)
fCalc.calculateCAGR(100, 200, 2) // +0.41 (41%)

Blockchain Calculator - Extends Financial Calculator

constructor ( <int blockHeight>, <Date genesis>, <int moneySupply (optional)> )

Functions

Calculate Seconds until Block

estimateBlockTimeFromHeight(<int blockHeight (optional)>, <Date currentDate (optional)>)

Description: Calculates the block time from blockheight provided. If no blockheight is provided, use the blockheight the class was constructed with. Uses the "currentDate" argument as an anchor. This function runs on construction, so it is necessary to run again unless you update the blockheight.

Returns the average blocktime in different intervals

Example

{
    "milliseconds": 60000, 
    "seconds": 60,
    "minutes": 1,
    "hours": 0.01,
    "days": 0.0007,
    "months": 0.00002,
    "years": 0.000001,
}

Get Average Time Until Block in Seconds

getBlockTime()

Description: Returns previously calculated blocktime in different intervals

Get Average Blocks per Day

blocksPer()

Description: Returns the amount of blocks created per interval, averaged using the blocktime.

Example

import { BlockchainCalculator } from "divicalculatorfunctions";
const blockchainCalc = new BlockchainCalculator(height, genesis, supply);

blockchainCalc.blocksPer().day // ~1440

Masternode Calculator

constructor ( <int blockheight>, <Object masternodeCounts>, <int moneySupply (optional)> )

Functions

Set total counts of masternodes in each tier

setMasternodeCounts ({
    COPPER: <int>, 
    SILVER: <int>, 
    GOLD: <int>, 
    PLATINUM: <int>, 
    DIAMOND: <int>
})

Description: Sets the total amount of masternodes (per tier), to use in calculations. This is also set on construction. You must use all caps for tier names.

Get total tickets

totalTickets ()

Description: Gets the total count of all tickets combined.

Get total tickets in Tier

totalTicketsInTier ( <string TIER> )

Description: Gets the total count of all tickets in one specific tier.

Get total coins

totalCoinsInMasternodes ()

Description: Gets the total count of all coins held in masternodes.

Get total coins in Tier

totalCoinsInTier ( <string TIER> )

Description: Gets the total count of all coins held by one specific tier.

Calculate ratio of Tier's coins to All Coins held by Masternodes

tierTicketsToTotalTicketsRatio ( <string TIER> )

Description: Gets the ratio of all of one specific tier's held coins, to the total coins held by all masternodes.

Chance to win per block

chanceToWinPerBlock ( <string TIER> )

Description: How likely a tier is to win each block

Blocks Until Masternode Reward

blocksUntilReward ( <string TIER> )

Description: How many blocks (on average) it will take a tier to earn a reward.

Time until reward

timeUntilReward ( <string TIER> )

Description: How long (on average) it will take a tier to earn a reward.

Returns object containing measurements over several time intervals.

{
    milliseconds: 101790000,
    seconds: 101790,
    minutes: 1696.5,
    hours: 28.275,
    days: 1.1781249999999999,
    months: 0.038004032258064514,
    years: 0.003218920765027322
}

Rewards over time

rewardsOverTime ( 
    tier: <String>
)

Description: How many times (on average) a tier recieves an award.

Returns object containing how many times a masternode will recieve a reward over several time intervals.

{
    milliseconds: 9.824147755182238e-9,
    seconds: 0.000009824147755182238,
    minutes: 0.0005894488653109342,
    hours: 0.03536693191865606,
    days: 0.8488063660477455,
    months: 26.312997347480106,
    years: 310.66312997347484
}

Rewards in Divi over time

masternodeRewardsInDiviOverTime ( 
    <String tier>,
)

Description: How many rewards in divi (on average) a tier earns over time.

Returns object containing how much divi a masternode will recieve a reward over several time intervals.

{
    milliseconds: 0.000004862953138815207,
    seconds: 0.004862953138815207,
    minutes: 0.2917771883289125,
    hours: 17.50663129973475,
    days: 420.15915119363405,
    months: 13024.933687002653,
    years: 153778.24933687004
}

Return on Investment over time

returnOnInvestmentOverTime (
    <String tier>
)

Description: Return on Investment over time for specified tier.

Returns percentages based on time invested.

{
    milliseconds: 4.862959031015635e-11,
    seconds: 4.862953137489967e-8,
    minutes: 0.0000029177718832215758,
    hours: 0.0001750663129973691,
    days: 0.0042015915119362765,
    months: 0.1302493368700266,
    years: 1.5377824933687003
}

Example

const mnCalc = new MasternodeCalculator( 
    1234183, 
    {
        COPPER: 600, 
        SILVER: 500, 
        GOLD: 200, 
        PLATINUM: 100, 
        DIAMOND: 30
    },
    2139044874.98652363
)

mnCalc.masternodeRewardsInDiviOverTime('COPPER').days // 76.04889975550122