coinsupply inflation calc
This commit is contained in:
@@ -1255,6 +1255,7 @@ UniValue prices(const UniValue& params, bool fHelp)
|
||||
rngval = (rngval*11109 + 13849);
|
||||
if ( (correlated[i]= komodo_pricecorrelated(rngval,j,&prices[offset],1,0,PRICES_SMOOTHWIDTH)) < 0 )
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "null correlated price");
|
||||
|
||||
}
|
||||
tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW);
|
||||
for (i=0; i<maxsamples&&i<numsamples; i++)
|
||||
|
||||
@@ -413,7 +413,7 @@ public:
|
||||
|
||||
UniValue coinsupply(const UniValue& params, bool fHelp)
|
||||
{
|
||||
int32_t height = 0; int32_t currentHeight; int64_t sproutfunds,zfunds,supply = 0; UniValue result(UniValue::VOBJ);
|
||||
int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf,sf,sproutfunds,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ);
|
||||
if (fHelp || params.size() > 1)
|
||||
throw runtime_error("coinsupply <height>\n"
|
||||
"\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n"
|
||||
@@ -448,6 +448,26 @@ UniValue coinsupply(const UniValue& params, bool fHelp)
|
||||
result.push_back(Pair("zfunds", ValueFromAmount(zfunds)));
|
||||
result.push_back(Pair("sprout", ValueFromAmount(sproutfunds)));
|
||||
result.push_back(Pair("total", ValueFromAmount(zfunds + supply)));
|
||||
if ( ASSETCHAINS_BLOCKTIME > 0 )
|
||||
{
|
||||
blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME;
|
||||
if ( height > blocks_per_year )
|
||||
{
|
||||
supply1 = komodo_coinsupply(&zf,&sf,height - blocks_per_year/12);
|
||||
supply3 = komodo_coinsupply(&zf,&sf,height - blocks_per_year/4);
|
||||
supply12 = komodo_coinsupply(&zf,&sf,height - blocks_per_year);
|
||||
if ( supply1 != 0 && supply3 != 0 && supply12 != 0 )
|
||||
{
|
||||
result.push_back(Pair("lastmonth", ValueFromAmount(supply1)));
|
||||
result.push_back(Pair("monthcoins", ValueFromAmount(supply - supply1)));
|
||||
result.push_back(Pair("lastquarter", ValueFromAmount(supply3)));
|
||||
result.push_back(Pair("quartercoins", ValueFromAmount(supply - supply3)));
|
||||
result.push_back(Pair("lastyear", ValueFromAmount(supply12)));
|
||||
result.push_back(Pair("yearcoins", ValueFromAmount(supply - supply12)));
|
||||
result.push_back(Pair("inflation", 100. * (((double)supply/supply12)-1.)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else result.push_back(Pair("error", "couldnt calculate supply"));
|
||||
} else {
|
||||
result.push_back(Pair("error", "invalid height"));
|
||||
|
||||
Reference in New Issue
Block a user