tera/Source/SITE/emission.html

256 lines
7.2 KiB
HTML
Raw Normal View History

2019-04-05 10:13:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tera Emission</title>
<script type="text/javascript" src="../HTML/JS/diagram.js"></script>
<script>
function UpdateDiagrams()
{
// var Account0=529202650;
// var BlockNumStart=22841472;
var Account0=Math.floor($("idAccount0Start").value);
var BlockNumStart=Math.floor($("idBlockNumStart").value);
var BlockNumEnd=Math.floor($("idBlockNumEnd").value);
var KTera=Number($("idKTera").value);
var PERIOD_END_43=Math.floor($("idPERIOD_END_43").value);
var PERIOD_END_45=Math.floor($("idPERIOD_END_45").value);
var StepNumber=24*3600;
var Ret=CalcReward(Account0,BlockNumStart,BlockNumEnd,StepNumber,KTera,PERIOD_END_43,PERIOD_END_45);
var ArrX=[];
for(var i=0;i<Ret.BlockNum.length;i++)
ArrX[i]=DateFromBlock(Ret.BlockNum[i]);
var MaxEmission=1000;
var ArrEmission=[];
for(var i=0;i<Ret.Account0.length;i++)
{
if(i<365)
{
if(i>=1)
{
ArrEmission[i]=365*(Ret.Account0[0]-Ret.Account0[i])/i;
if(i===1)
ArrEmission[0]=ArrEmission[i];
}
else
{
ArrEmission[i]=0;
}
}
else
{
ArrEmission[i]=Ret.Account0[i-365]-Ret.Account0[i];
}
}
DrawDiagramMy({id:"idReward",red:"#1b9031",arrX:ArrX,arr:Ret.Reward,KPrecision:100});
DrawDiagramMy({id:"idEmission",red:"#c0465d",arrX:ArrX,arr:ArrEmission,KPrecision:10});
DrawDiagramMy({id:"idAccount0",red:"#1e21cb",startnumber:BlockNumStart,steptime:StepNumber,arr:Ret.Account0});
}
function DrawDiagramMy(Item)
{
Item.name=Item.id;
Item.fillStyle="#FFF";
Item.line=1;
if(!Item.steptime)
Item.steptime=1;
DiagramMapId[Item.id]=Item;
DiagramMap[Item.name]=Item;
DrawDiagram(Item);
}
window.onload=function()
{
//COMMON MOUSE MOVING
window.onmousemove = function(event)
{
SetDiagramMouseX(event);
}
//UpdateDiagrams();
InitDiagramByArr([]);
};
function $(id)
{
return document.getElementById(id);
}
</script>
<script>
function CalcReward(Account0,BlockNumStart,BlockNumEnd, ArrDelta, KTera, PERIOD_END_43,PERIOD_END_45)
{
//old consts
var REF_PERIOD_START=2*1000000;
var REF_PERIOD_END=30*1000000;
// var PERIOD_END_43=43*1000000;
// var PERIOD_END_45=45*1000000;
var ArrIndex=0;
var Ret={Reward:[],Account0:[],Emission:[],BlockNum:[]};
var BlockNum=BlockNumStart;
//var KTera=3;
var SumReward=0;
var NumDelta=0;
while(BlockNum<=BlockNumEnd)
{
var Reward=Account0*43*43/100/1000000000;
if(BlockNum<=REF_PERIOD_END)
{
Reward=Account0*43*43/100/1000000000;
var K=(REF_PERIOD_END-BlockNum)/(REF_PERIOD_END-REF_PERIOD_START);
if(K>0)
Reward+=2*K*Reward;
}
else
if(BlockNum<=PERIOD_END_43)
{
Reward=Account0*43*43/100/1000000000;
var K=(PERIOD_END_45-BlockNum)/(PERIOD_END_45-REF_PERIOD_END);
Reward=K*Reward
}
else
{
Reward=KTera*Account0/1000000000;
}
SumReward=SumReward+Reward;
Account0-=Reward;
//stat
NumDelta++;
if(NumDelta>=ArrDelta)
{
Ret.Reward[ArrIndex]=Reward;
Ret.Account0[ArrIndex]=Account0/1000000;
//Ret.Emission[ArrIndex]=SumReward/1000000;
Ret.BlockNum[ArrIndex]=BlockNum;
ArrIndex++;
//console.log(""+DateFromBlock(BlockNum)+" = "+Reward+" SUM:"+Math.floor(SumReward)+"/"+Math.floor(Account0));
NumDelta=0;
SumReward=0;
}
BlockNum++;
}
return Ret;
}
function formatDate(now)
{
var year=now.getFullYear();
var month=now.getMonth()+1;
var date=now.getDate();
return year+"-"+String(month).padStart(2,"0")+"-"+String(date).padStart(2,"0");
}
function DateFromBlock(BlockNum)
{
var Str;
var FIRST_TIME_BLOCK=1530446400000;
var now = new Date(FIRST_TIME_BLOCK + BlockNum * 1000);
Str = formatDate(now);
return Str;
};
</script>
</head>
<body>
<h3>The parameters of the economy</h3>
<TABLE>
<TR>
<TD>
Point 43:
</TD>
<TD>
<INPUT type="number" id="idPERIOD_END_43" style="width:120px" value="43000000">
</TD>
</TR>
<TR>
<TD>
Point 45:
</TD>
<TD>
<INPUT type="number" id="idPERIOD_END_45" style="width:120px" value="45500000">
</TD>
</TR>
<TR>
<TD>
KTera:
</TD>
<TD>
<INPUT type="number" id="idKTera" style="width:120px" value="3">
</TD>
</TR>
</TABLE>
<h3>The parameters of view</h3>
<TABLE>
<TR>
<TD>
Start BlockNum:
</TD>
<TD>
<INPUT type="number" id="idBlockNumStart" style="width:120px" value="22841472">
</TD>
</TR>
<TR>
<TD>
Start Account0:
</TD>
<TD>
<INPUT type="number" id="idAccount0Start" style="width:120px" value="529202650">
</TD>
</TR>
<TR>
<TD>
End BlockNum:
</TD>
<TD>
<INPUT type="number" id="idBlockNumEnd" style="width:120px" value="100000000">
</TD>
</TR>
<TR>
<TD>
<button onclick="UpdateDiagrams()">SHOW DIAGRAMS</button>
</TD>
</TR>
</TABLE>
<h4 >Reward, TERA per block</h4>
<canvas class="DIAGRAM" width='1100' height='200' id='idReward'></canvas>
<h4 >Emission, Million TERA per Year</h4>
<canvas class="DIAGRAM" width='1100' height='200' id='idEmission'></canvas>
<h4 >Balance of account 0, Million TERA</h4>
<canvas class="DIAGRAM" width='1100' height='200' id='idAccount0'></canvas>
</body>
</html>