-
Notifications
You must be signed in to change notification settings - Fork 1
/
examples.js
51 lines (40 loc) · 1.65 KB
/
examples.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const eth2 = require("./eth2");
// Issuance rate as a function of the total staked
const getIssuanceRate = function(data) {
const networkStake = eth2.toGwei(data.networkStake);
const p = data.p;
const deposit = eth2.toGwei(data.deposit);
const baseRewardQuotient = data.baseRewardQuotient;
const numberOfShards = data.numberOfShards;
const ethInCirculation = eth2.toGwei(data.ethInCirculation);
const baseReward = eth2.economics.baseReward(deposit, baseRewardQuotient, networkStake, p);
const numberOfValidators = eth2.economics.numberOfValidatorsByStake(networkStake, deposit);
const issuancePerEpoch = eth2.economics.issuancePerEpoch(numberOfValidators, baseReward);
const issuancePerYear = eth2.economics.issuancePerYear(issuancePerEpoch);
const issuanceRate = eth2.economics.issuanceRate(issuancePerYear, ethInCirculation);
return issuanceRate;
}
// Validator interest as a function of the total staked
const getValidatorInterest = function(data) {
const networkStake = eth2.toGwei(data.networkStake);
const p = data.p;
const deposit = eth2.toGwei(data.deposit);
const baseRewardQuotient = data.baseRewardQuotient;
const baseReward = eth2.economics.baseReward(deposit, baseRewardQuotient, networkStake, p);
const validatorInterest = eth2.economics.validatorInterest(baseReward, deposit);
return validatorInterest;
}
console.log("issuance rate", getIssuanceRate({
networkStake: 10000000,
p: 0.5,
deposit: 32,
baseRewardQuotient: 32,
numberOfShards: 1024,
ethInCirculation: 110000000
}));
console.log("validator interest", getValidatorInterest({
networkStake: 10000000,
p: 0.5,
deposit: 32,
baseRewardQuotient: 32
}));