2.2.5 • Published 3 years ago

divicalculatorfunctions v2.2.5

Weekly downloads
85
License
MIT
Repository
github
Last release
3 years ago

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
2.2.5

3 years ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.6.4

3 years ago

1.6.0

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.2.4

3 years ago

1.1.0

3 years ago

1.2.2

3 years ago

1.0.0

3 years ago