reward schedule – Inventory to Circulation Calculation in JS – what am I lacking?

0
26


I am attempting to calculate the S2F vary worth in Typescript however I am not getting the identical outcomes because the digitalik.internet website for a similar calculation, and I am curious the place mine falls down. What am I lacking?

This is the place I am at utilizing coinmetrics.io public day by day BlkCnt metric to get manufacturing for the final 10 and 463 days:

import { DateTime } from "luxon"
import axios from 'axios'

async perform getBitcoinProduction(daysInArrears: quantity = 10): Promise<quantity> {
  const startDate = DateTime.native().minus({ days: daysInArrears }).toISODate()
  const urlBase="community-api.coinmetrics.io/v4"
  const urlMetric="timeseries/asset-metrics"
  let coinMetricsBlocksPerDayResponse
  attempt {
    coinMetricsBlocksPerDayResponse = await axios.get(`https://${urlBase}/${urlMetric}`, {
    params: {
      belongings: 'btc',
      metrics: 'BlkCnt',
      start_time: startDate,
      frequency: '1d',
      fairly: true,
      page_size: daysInArrears
    }
  })
  } catch(error) {
    console.log(error)
  }

  // console.log('coinMetricsBlocksPerDay-------------------------', coinMetricsBlocksPerDayResponse.knowledge)

  const coinMetricsBlocksPerDay = coinMetricsBlocksPerDayResponse.knowledge

  const lastHalveningDateTime = DateTime.utc(2020, 5, 11, 19, 23, 43)
  const stream = coinMetricsBlocksPerDay.knowledge.cut back((accum, merchandise) => {
    const itemDate = DateTime.fromISO(merchandise.time).toUTC()
    const blockReward = (lastHalveningDateTime < itemDate) ? 6.25 : 12.5
    const issuance = merchandise.BlkCnt * blockReward
    // console.log(`itemDate: ${itemDate}, blkcnt: ${merchandise.BlkCnt}, blkReward: ${blockReward}, issuance: ${issuance}`)
    // console.log(`accum: ${accum + issuance}`)
    return accum + issuance
  }, 0)
  return stream
}

export async perform stock2flow(daysInArrears: quantity = 463): Promise<quantity> {

  const inventory: quantity = 18691869 // todo: get from api

  // is likely to be off by just a few blocks since that is by day
  const manufacturing : quantity = await getBitcoinProduction(daysInArrears)

  const stream: quantity = (daysInArrears === 10) ? (manufacturing / daysInArrears * 365) : manufacturing

  const SF: quantity = inventory / stream

  const worth: quantity = Math.exp(-1.84) * Math.pow(SF, 3.36)

  console.log('daysInArrears:', daysInArrears)
  console.log('inventory:', inventory)
  console.log('manufacturing:', manufacturing)
  console.log('stream:', stream)
  console.log('SF:', SF)
  console.log('worth:', worth)

  return worth
}

stock2flow(10)
stock2flow(463)

This outputs

daysInArrears: 463
inventory: 18691869
manufacturing: 522081.25
stream: 522081.25
SF: 35.80260543737206
worth: 26427.210144116314

daysInArrears: 10
inventory: 18691869
manufacturing: 7618.75
stream: 278084.375
SF: 67.21653814602134
worth: 219390.58584450412

However it is a far cry from the present $168,103 / $49,106 on digitalik.internet/btc/ and likewise fairly completely different from the day by day stats telegram notification:

>> Day by day stats <<
Inventory/stream 10d/463d: 61 / 43
Inventory/stream worth 10d/463d: $159.374 / $49.216
Precise worth: $55.000
Mined BTC: 18.692.706
Mayer a number of: 1,55
Days to halving: 1097
Pow legislation osc: 0,45
Dormant BTC >10y: 2.039.028



Supply hyperlink

Leave a reply