Advertisement
Guest User

Npip4 reward model v3

a guest
Aug 20th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var networkWeightStart = networkWeight = 20000000;
  3.  
  4. var balance0Start = balance0 = 1500000;
  5. var balance1Start = balance1 = 1000000;
  6. var balance2Start = balance2 = 100000;
  7. var balance3Start = balance3 = 10000;
  8. var balance4Start = balance4 = 1000;
  9.  
  10. var blockReward = 2;
  11. var blocktime = 30; //seconds
  12. var blocksYear = 60 / blocktime * 60 * 24 * 365;
  13.  
  14. var otherWeightStart = otherWeight = networkWeight - balance0 - balance1 - balance2 - balance3 - balance4
  15.  
  16. var BiggerShare = 0.15; // Residual Network Share in the hand of more rich or lucky
  17. var BiggerWeightStart = BiggerWeight = otherWeight * BiggerShare;
  18.  
  19. otherWeightStart = otherWeight -= BiggerWeightStart;
  20.  
  21. for (var i=0; i<blocksYear; i++) {
  22.  
  23.   networkWeight += 2;
  24.  
  25.   if (i % (networkWeight/BiggerWeight) < 1) BiggerWeight += 2;
  26.   else if (i % (networkWeight/balance0) < 1) balance0 += 2;
  27.   else if (i % (networkWeight/balance1) < 1) balance1 += 2;
  28.   else if (i % (networkWeight/balance2) < 1) balance2 += 2;
  29.   else if (i % (networkWeight/balance3) < 1) balance3 += 2;
  30.   else if (i % (networkWeight/balance4) < 1) balance4 += 2;
  31.   else otherWeight += 2;
  32. }
  33.  
  34.  
  35.  
  36. function Pad(S, w)  // pad a string left o right(-w)
  37. {
  38.   if ((w>0) && (S.length < w))
  39.     return S + ' '.repeat(w - S.length);
  40.   else if ((w<0) && (S.length < -w))
  41.     return ' '.repeat(-w - S.length) + S;
  42.   else
  43.     return S;
  44. }
  45.  
  46. function Idy(n, w, d) { return Pad(n.toFixed(d), w);}
  47.  
  48. function ShowNeat(Item, Start, End)
  49. {
  50.   return '| ' + Pad(Item, 16) + ' |  ' + Idy(Start, -12, 0) + ' | ' + Idy(End, -12, 0) + ' | ' + Idy(((End/Start)-1)*100, -10, 2) + '%  |';
  51. }
  52.  
  53.  
  54.  
  55. console.log('|----------------------------------------------------------------|');
  56. console.log('| Staker           |', 'Balance Start |', ' Balance End |', 'Percent Gain |');
  57. console.log('|----------------------------------------------------------------|');
  58.  
  59. console.log(ShowNeat('Bigger('+BiggerShare*100+'%)', BiggerWeightStart, BiggerWeight));
  60. console.log(ShowNeat('balance0', balance0Start, balance0));
  61. console.log(ShowNeat('balance1', balance1Start, balance1));
  62. console.log(ShowNeat('balance2', balance2Start, balance2));
  63. console.log(ShowNeat('balance3', balance3Start, balance3));
  64. console.log(ShowNeat('balance4', balance4Start, balance4));
  65. console.log(ShowNeat('others weight', otherWeightStart, otherWeight));
  66.  
  67. console.log(ShowNeat('network weight', networkWeightStart, networkWeight));
  68.  
  69. console.log('|----------------------------------------------------------------|');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement