@marinade.finance/scoring 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/computing/cluster.d.ts +10 -0
- package/dist/computing/cluster.js +95 -0
- package/dist/computing/cluster.js.map +1 -0
- package/dist/computing/eligibility.d.ts +19 -0
- package/dist/computing/eligibility.js +163 -0
- package/dist/computing/eligibility.js.map +1 -0
- package/dist/computing/score.d.ts +20 -0
- package/dist/computing/score.js +174 -0
- package/dist/computing/score.js.map +1 -0
- package/dist/computing/stake.d.ts +26 -0
- package/dist/computing/stake.js +197 -0
- package/dist/computing/stake.js.map +1 -0
- package/dist/computing/validators.d.ts +16 -0
- package/dist/computing/validators.js +123 -0
- package/dist/computing/validators.js.map +1 -0
- package/dist/constants/marinade.json +38 -0
- package/dist/dto/bonds.dto.d.ts +12 -0
- package/dist/dto/bonds.dto.js +3 -0
- package/dist/dto/bonds.dto.js.map +1 -0
- package/dist/dto/cluster.dto.d.ts +12 -0
- package/dist/dto/cluster.dto.js +3 -0
- package/dist/dto/cluster.dto.js.map +1 -0
- package/{dto/eligibility.dto.ts → dist/dto/eligibility.dto.d.ts} +15 -15
- package/dist/dto/eligibility.dto.js +3 -0
- package/dist/dto/eligibility.dto.js.map +1 -0
- package/dist/dto/jito.dto.d.ts +9 -0
- package/dist/dto/jito.dto.js +10 -0
- package/dist/dto/jito.dto.js.map +1 -0
- package/dist/dto/marinade.dto.d.ts +18 -0
- package/dist/dto/marinade.dto.js +3 -0
- package/dist/dto/marinade.dto.js.map +1 -0
- package/dist/dto/rewards.dto.d.ts +17 -0
- package/dist/dto/rewards.dto.js +18 -0
- package/dist/dto/rewards.dto.js.map +1 -0
- package/dist/dto/scoring.dto.d.ts +101 -0
- package/dist/dto/scoring.dto.js +3 -0
- package/dist/dto/scoring.dto.js.map +1 -0
- package/dist/dto/snapshots.dto.d.ts +15 -0
- package/dist/dto/snapshots.dto.js +13 -0
- package/dist/dto/snapshots.dto.js.map +1 -0
- package/dist/dto/stakes.dto.d.ts +30 -0
- package/dist/dto/stakes.dto.js +3 -0
- package/dist/dto/stakes.dto.js.map +1 -0
- package/dist/dto/validators.dto.d.ts +110 -0
- package/dist/dto/validators.dto.js +19 -0
- package/dist/dto/validators.dto.js.map +1 -0
- package/dist/errors/fetching.d.ts +22 -0
- package/dist/errors/fetching.js +30 -0
- package/dist/errors/fetching.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/data-provider.interface.d.ts +16 -0
- package/dist/interfaces/data-provider.interface.js +3 -0
- package/dist/interfaces/data-provider.interface.js.map +1 -0
- package/dist/logging/logger.d.ts +3 -0
- package/dist/logging/logger.js +72 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/providers/api-data.provider.d.ts +30 -0
- package/dist/providers/api-data.provider.js +227 -0
- package/dist/providers/api-data.provider.js.map +1 -0
- package/dist/providers/file-data.provider.d.ts +29 -0
- package/dist/providers/file-data.provider.js +96 -0
- package/dist/providers/file-data.provider.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/csv.d.ts +2 -0
- package/dist/utils/csv.js +53 -0
- package/dist/utils/csv.js.map +1 -0
- package/dist/utils/maths.d.ts +8 -0
- package/dist/utils/maths.js +56 -0
- package/dist/utils/maths.js.map +1 -0
- package/dist/utils/solana.d.ts +1 -0
- package/dist/utils/solana.js +9 -0
- package/dist/utils/solana.js.map +1 -0
- package/dist/utils/zip.d.ts +2 -0
- package/dist/utils/zip.js +15 -0
- package/dist/utils/zip.js.map +1 -0
- package/package.json +7 -13
- package/computing/cluster.ts +0 -102
- package/computing/eligibility.ts +0 -163
- package/computing/score.ts +0 -164
- package/computing/stake.ts +0 -246
- package/computing/validators.ts +0 -133
- package/constants/marinade.json +0 -38
- package/dto/bonds.dto.ts +0 -12
- package/dto/cluster.dto.ts +0 -12
- package/dto/jito.dto.ts +0 -9
- package/dto/marinade.dto.ts +0 -18
- package/dto/rewards.dto.ts +0 -19
- package/dto/scoring.dto.ts +0 -103
- package/dto/snapshots.dto.ts +0 -16
- package/dto/stakes.dto.ts +0 -31
- package/dto/validators.dto.ts +0 -110
- package/errors/fetching.ts +0 -25
- package/interfaces/data-provider.interface.ts +0 -17
- package/providers/api-data.provider.ts +0 -261
- package/providers/file-data.provider.ts +0 -117
- package/utils/csv.ts +0 -30
- package/utils/maths.ts +0 -75
- package/utils/solana.ts +0 -9
- package/utils/zip.ts +0 -12
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BlockProductionResult, ClusterInfo } from '../dto/cluster.dto';
|
|
2
|
+
import { ValidatorDto } from '../dto/validators.dto';
|
|
3
|
+
export declare function computeBlockProduction(validators: ValidatorDto[], startEpoch: number, endEpoch: number): BlockProductionResult;
|
|
4
|
+
export declare function computeTargetCreditsByEpoch(validators: ValidatorDto[]): Map<number, number>;
|
|
5
|
+
export declare function computeConcentrations(validators: ValidatorDto[], epoch: number): {
|
|
6
|
+
city: Map<string, number>;
|
|
7
|
+
country: Map<string, number>;
|
|
8
|
+
aso: Map<string, number>;
|
|
9
|
+
};
|
|
10
|
+
export declare function computeClusterInfo(validators: ValidatorDto[], basicEligibilityEpochs: number, lastEpoch: number): ClusterInfo;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.computeClusterInfo = exports.computeConcentrations = exports.computeTargetCreditsByEpoch = exports.computeBlockProduction = void 0;
|
|
7
|
+
const maths_1 = require("../utils/maths");
|
|
8
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
9
|
+
function computeBlockProduction(validators, startEpoch, endEpoch) {
|
|
10
|
+
const blockProductions = [];
|
|
11
|
+
for (const validator of validators) {
|
|
12
|
+
let leaderSlots = 0;
|
|
13
|
+
let blocksProduced = 0;
|
|
14
|
+
for (let epoch = startEpoch; epoch <= endEpoch; epoch++) {
|
|
15
|
+
if (!validator.epochStats) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const epochStat = validator.epochStats[epoch];
|
|
19
|
+
if (epochStat) {
|
|
20
|
+
leaderSlots += epochStat.leader_slots;
|
|
21
|
+
blocksProduced += epochStat.blocks_produced;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (leaderSlots) {
|
|
25
|
+
blockProductions.push(blocksProduced / leaderSlots);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
mean: (0, maths_1.mean)(blockProductions),
|
|
30
|
+
stdDev: (0, maths_1.stdDev)(blockProductions),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.computeBlockProduction = computeBlockProduction;
|
|
34
|
+
function computeTargetCreditsByEpoch(validators) {
|
|
35
|
+
const sumOfWeightedCreditsPerEpoch = new Map();
|
|
36
|
+
const sumOfWeightsPerEpoch = new Map();
|
|
37
|
+
validators.forEach(validator => {
|
|
38
|
+
validator.epoch_stats.forEach(epochStat => {
|
|
39
|
+
if (epochStat.epoch_end_at) {
|
|
40
|
+
const activatedStakeDecimal = new decimal_js_1.default(epochStat.activated_stake);
|
|
41
|
+
const stakeInSol = activatedStakeDecimal.dividedBy(1e9);
|
|
42
|
+
const prevSumOfWeightedCredits = sumOfWeightedCreditsPerEpoch.get(epochStat.epoch) || new decimal_js_1.default(0);
|
|
43
|
+
sumOfWeightedCreditsPerEpoch.set(epochStat.epoch, prevSumOfWeightedCredits.plus(new decimal_js_1.default(epochStat.credits).times(stakeInSol)));
|
|
44
|
+
const prevSumOfWeightsPerEpoch = sumOfWeightsPerEpoch.get(epochStat.epoch) || new decimal_js_1.default(0);
|
|
45
|
+
sumOfWeightsPerEpoch.set(epochStat.epoch, prevSumOfWeightsPerEpoch.plus(stakeInSol));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
const result = new Map();
|
|
50
|
+
sumOfWeightsPerEpoch.forEach((sumOfWeights, epoch) => {
|
|
51
|
+
const weightedCredits = sumOfWeightedCreditsPerEpoch.get(epoch) || new decimal_js_1.default(0);
|
|
52
|
+
result.set(epoch, weightedCredits.dividedBy(sumOfWeights).toDecimalPlaces(0, decimal_js_1.default.ROUND_HALF_UP).toNumber());
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
exports.computeTargetCreditsByEpoch = computeTargetCreditsByEpoch;
|
|
57
|
+
function computeConcentrations(validators, epoch) {
|
|
58
|
+
let total = 0;
|
|
59
|
+
const city = new Map();
|
|
60
|
+
const country = new Map();
|
|
61
|
+
const aso = new Map();
|
|
62
|
+
for (const validator of validators) {
|
|
63
|
+
const lastEpochStats = validator.epoch_stats[0];
|
|
64
|
+
if (lastEpochStats?.epoch === epoch) {
|
|
65
|
+
const cityKey = validator.dc_full_city ?? '???';
|
|
66
|
+
const countryKey = validator.dc_country ?? '???';
|
|
67
|
+
const asoKey = validator.dc_aso ?? '???';
|
|
68
|
+
const stake = Number(validator.activated_stake) / 1e9;
|
|
69
|
+
city.set(cityKey, (city.get(cityKey) ?? 0) + stake);
|
|
70
|
+
country.set(countryKey, (country.get(countryKey) ?? 0) + stake);
|
|
71
|
+
aso.set(asoKey, (aso.get(asoKey) ?? 0) + stake);
|
|
72
|
+
total += stake;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (total > 0) {
|
|
76
|
+
for (const map of [city, country, aso]) {
|
|
77
|
+
for (const [key, value] of map) {
|
|
78
|
+
map.set(key, value / total);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { city, country, aso };
|
|
83
|
+
}
|
|
84
|
+
exports.computeConcentrations = computeConcentrations;
|
|
85
|
+
function computeClusterInfo(validators, basicEligibilityEpochs, lastEpoch) {
|
|
86
|
+
const { mean: meanBlockProduction, stdDev: stdDevBlockProduction } = computeBlockProduction(validators, lastEpoch - basicEligibilityEpochs, lastEpoch - 1);
|
|
87
|
+
return {
|
|
88
|
+
targetCreditsByEpoch: computeTargetCreditsByEpoch(validators),
|
|
89
|
+
...computeConcentrations(validators, lastEpoch),
|
|
90
|
+
meanBlockProductionOverBasicEligibilityPeriod: meanBlockProduction,
|
|
91
|
+
stdDevBlockProductionOverBasicEligibilityPeriod: stdDevBlockProduction,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
exports.computeClusterInfo = computeClusterInfo;
|
|
95
|
+
//# sourceMappingURL=cluster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/computing/cluster.ts"],"names":[],"mappings":";;;;;;AAEA,0CAA8C;AAC9C,4DAAiC;AAEjC,SAAgB,sBAAsB,CAAC,UAA0B,EAAE,UAAkB,EAAE,QAAgB;IACrG,MAAM,gBAAgB,GAAa,EAAE,CAAC;IAEtC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;QAClC,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,IAAI,cAAc,GAAG,CAAC,CAAC;QAEvB,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,EAAE,EAAE;YACvD,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE;gBACzB,SAAS;aACV;YACD,MAAM,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAC9C,IAAI,SAAS,EAAE;gBACb,WAAW,IAAI,SAAS,CAAC,YAAY,CAAC;gBACtC,cAAc,IAAI,SAAS,CAAC,eAAe,CAAC;aAC7C;SACF;QAED,IAAI,WAAW,EAAE;YACf,gBAAgB,CAAC,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,CAAC;SACrD;KACF;IAED,OAAO;QACL,IA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AAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;YAChE,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;YAEhD,KAAK,IAAI,KAAK,CAAC;SAChB;KACF;IAED,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,KAAK,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE;YACtC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,EAAE;gBAC9B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC;aAC7B;SACF;KACF;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAChC,CAAC;AA/BD,sDA+BC;AACD,SAAgB,kBAAkB,CAAC,UAA0B,EAAE,sBAA8B,EAAE,SAAiB;IAC9G,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,qBAAqB,EAAE,GAAG,sBAAsB,CAAC,UAAU,EAAE,SAAS,GAAG,sBAAsB,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;IAE3J,OAAO;QACL,oBAAoB,EAAE,2BAA2B,CAAC,UAAU,CAAC;QAC7D,GAAG,qBAAqB,CAAC,UAAU,EAAE,SAAS,CAAC;QAC/C,6CAA6C,EAAE,mBAAmB;QAClE,+CAA+C,EAAE,qBAAqB;KACvE,CAAC;AACJ,CAAC;AATD,gDASC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Bonds } from '../dto/bonds.dto';
|
|
2
|
+
import { ClusterInfo } from '../dto/cluster.dto';
|
|
3
|
+
import { EligibilityConfig, EvaluationResult, Issue, ValidatorEligibility, ValidatorsEligibilities } from '../dto/eligibility.dto';
|
|
4
|
+
import { ScoreDto, Scores, ScoringConfig } from '../dto/scoring.dto';
|
|
5
|
+
import { AggregatedValidator, AggregatedValidators } from '../dto/validators.dto';
|
|
6
|
+
export declare function evalLowCreditsIssue(validator: AggregatedValidator, epochIndex: number, eligibilityConfig: EligibilityConfig, clusterInfo: ClusterInfo): Issue | null;
|
|
7
|
+
export declare function evalLowExternalStakeIssue(validator: AggregatedValidator, epochIndex: number, eligibilityConfig: EligibilityConfig): Issue | undefined;
|
|
8
|
+
export declare function evalBlacklistIssue(validator: AggregatedValidator): Issue | undefined;
|
|
9
|
+
export declare function evalHighCommissionIssue(validator: AggregatedValidator, epochIndex: number, eligibilityConfig: EligibilityConfig): Issue | undefined;
|
|
10
|
+
export declare function evalScoreIssue(epochIndex: number, eligibilityConfig: EligibilityConfig, { concentrationScore }: ScoreDto): Issue | undefined;
|
|
11
|
+
export declare function evalBondIssue(validator: AggregatedValidator, bonds: Bonds): Issue | undefined;
|
|
12
|
+
export declare function getValidatorIssuesInEpoch(validator: AggregatedValidator, bonds: Bonds, epochIndex: number, eligibilityConfig: EligibilityConfig, clusterInfo: ClusterInfo, score: ScoreDto): Issue[];
|
|
13
|
+
export declare function evalIssuesInEpoch(issues: Issue[]): EvaluationResult;
|
|
14
|
+
export declare function evalIssues(issuesCollection: Issue[][], epochs: number): EvaluationResult;
|
|
15
|
+
export declare function isBasicEligible(issuesCollection: Issue[][], eligibilityConfig: EligibilityConfig): boolean;
|
|
16
|
+
export declare function isBonusEligible(issuesCollection: Issue[][], eligibilityConfig: EligibilityConfig): boolean;
|
|
17
|
+
export declare function getIssuesCollection(clusterInfo: ClusterInfo, aggregatedValidator: AggregatedValidator, bonds: Bonds, score: ScoreDto, eligibilityConfig: EligibilityConfig): Issue[][];
|
|
18
|
+
export declare function computeValidatorEligibility(clusterInfo: ClusterInfo, aggregatedValidator: AggregatedValidator, bonds: Bonds, scores: ScoreDto, eligibilityConfig: EligibilityConfig, scoringConfig: ScoringConfig): ValidatorEligibility;
|
|
19
|
+
export declare function computeValidatorsEligibilities(clusterInfo: ClusterInfo, scores: Scores, aggregatedValidators: AggregatedValidators, bonds: Bonds, eligibilityConfig: EligibilityConfig, scoringConfig: ScoringConfig): ValidatorsEligibilities;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeValidatorsEligibilities = exports.computeValidatorEligibility = exports.getIssuesCollection = exports.isBonusEligible = exports.isBasicEligible = exports.evalIssues = exports.evalIssuesInEpoch = exports.getValidatorIssuesInEpoch = exports.evalBondIssue = exports.evalScoreIssue = exports.evalHighCommissionIssue = exports.evalBlacklistIssue = exports.evalLowExternalStakeIssue = exports.evalLowCreditsIssue = void 0;
|
|
4
|
+
const validators_1 = require("./validators");
|
|
5
|
+
function evalLowCreditsIssue(validator, epochIndex, eligibilityConfig, clusterInfo) {
|
|
6
|
+
if (!validator.epochs[epochIndex]) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const targetCredits = clusterInfo.targetCreditsByEpoch.get(validator.epochs[epochIndex]);
|
|
10
|
+
if (!targetCredits) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const actualCredits = validator.credits[epochIndex] || 0;
|
|
14
|
+
const creditsPct = Math.round((100 * actualCredits) / targetCredits);
|
|
15
|
+
if (creditsPct < eligibilityConfig.voteCreditsLow) {
|
|
16
|
+
return { type: "VOTE_CREDITS_LOW", message: `Credits @ ${creditsPct}%` };
|
|
17
|
+
}
|
|
18
|
+
else if (creditsPct < eligibilityConfig.voteCreditsWarning) {
|
|
19
|
+
return { type: "VOTE_CREDITS_WARNING", message: `(Warning) Credits @ ${creditsPct}%` };
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
exports.evalLowCreditsIssue = evalLowCreditsIssue;
|
|
24
|
+
function evalLowExternalStakeIssue(validator, epochIndex, eligibilityConfig) {
|
|
25
|
+
const externalStake = validator.externalStake[epochIndex];
|
|
26
|
+
if (!externalStake) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (externalStake < eligibilityConfig.minExternalStake) {
|
|
30
|
+
return { type: "EXTERNAL_STAKE", message: `External stake: ${externalStake}` };
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
exports.evalLowExternalStakeIssue = evalLowExternalStakeIssue;
|
|
35
|
+
function evalBlacklistIssue(validator) {
|
|
36
|
+
if (validator.blacklisted) {
|
|
37
|
+
return { type: "BLACKLIST", message: 'Validator is blacklisted' };
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
exports.evalBlacklistIssue = evalBlacklistIssue;
|
|
42
|
+
function evalHighCommissionIssue(validator, epochIndex, eligibilityConfig) {
|
|
43
|
+
const commission = validator.commission[epochIndex];
|
|
44
|
+
if (!commission) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
if (eligibilityConfig.maxCommission < commission) {
|
|
48
|
+
return { type: "COMMISSION", message: `Commission: ${commission}%` };
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
exports.evalHighCommissionIssue = evalHighCommissionIssue;
|
|
53
|
+
function evalScoreIssue(epochIndex, eligibilityConfig, { concentrationScore }) {
|
|
54
|
+
if (epochIndex === 0 && concentrationScore < eligibilityConfig.minScore) {
|
|
55
|
+
return { type: "SCORE", message: `Concentration Score: ${concentrationScore}` };
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
exports.evalScoreIssue = evalScoreIssue;
|
|
60
|
+
function evalBondIssue(validator, bonds) {
|
|
61
|
+
if (!(validator.voteAccount in bonds)) {
|
|
62
|
+
return { type: "NO_BOND", message: 'Validator has no bond' };
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
exports.evalBondIssue = evalBondIssue;
|
|
67
|
+
function getValidatorIssuesInEpoch(validator, bonds, epochIndex, eligibilityConfig, clusterInfo, score) {
|
|
68
|
+
if (!validator.dataAvailable[epochIndex]) {
|
|
69
|
+
return [{ type: "NO_DATA", message: `No data for validator in epoch ${validator.epochs[epochIndex]}` }];
|
|
70
|
+
}
|
|
71
|
+
return [
|
|
72
|
+
evalBlacklistIssue(validator),
|
|
73
|
+
evalLowCreditsIssue(validator, epochIndex, eligibilityConfig, clusterInfo),
|
|
74
|
+
evalLowExternalStakeIssue(validator, epochIndex, eligibilityConfig),
|
|
75
|
+
evalHighCommissionIssue(validator, epochIndex, eligibilityConfig),
|
|
76
|
+
evalScoreIssue(epochIndex, eligibilityConfig, score),
|
|
77
|
+
evalBondIssue(validator, bonds),
|
|
78
|
+
].filter(Boolean);
|
|
79
|
+
}
|
|
80
|
+
exports.getValidatorIssuesInEpoch = getValidatorIssuesInEpoch;
|
|
81
|
+
function evalIssuesInEpoch(issues) {
|
|
82
|
+
let criticals = 0;
|
|
83
|
+
let warnings = 0;
|
|
84
|
+
const criticalTypes = new Set([
|
|
85
|
+
"NO_BOND",
|
|
86
|
+
"NO_DATA",
|
|
87
|
+
"BLACKLIST",
|
|
88
|
+
"COMMISSION",
|
|
89
|
+
"EXTERNAL_STAKE",
|
|
90
|
+
"CENTRALIZATION",
|
|
91
|
+
"SCORE",
|
|
92
|
+
"VOTE_CREDITS_LOW",
|
|
93
|
+
]);
|
|
94
|
+
const warningTypes = new Set([
|
|
95
|
+
"VOTE_CREDITS_WARNING",
|
|
96
|
+
]);
|
|
97
|
+
issues.forEach(issue => {
|
|
98
|
+
if (criticalTypes.has(issue.type)) {
|
|
99
|
+
criticals++;
|
|
100
|
+
}
|
|
101
|
+
else if (warningTypes.has(issue.type)) {
|
|
102
|
+
warnings++;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw new Error(`Unexpected issue: ${issue.type}`);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return { criticals, warnings };
|
|
109
|
+
}
|
|
110
|
+
exports.evalIssuesInEpoch = evalIssuesInEpoch;
|
|
111
|
+
function evalIssues(issuesCollection, epochs) {
|
|
112
|
+
let totalCriticals = 0;
|
|
113
|
+
let totalWarnings = 0;
|
|
114
|
+
for (let epochIndex = 0; epochIndex < epochs; epochIndex++) {
|
|
115
|
+
if (!issuesCollection[epochIndex]) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const { criticals, warnings } = evalIssuesInEpoch(issuesCollection[epochIndex]);
|
|
119
|
+
totalCriticals += criticals;
|
|
120
|
+
totalWarnings += warnings;
|
|
121
|
+
}
|
|
122
|
+
return { criticals: totalCriticals, warnings: totalWarnings };
|
|
123
|
+
}
|
|
124
|
+
exports.evalIssues = evalIssues;
|
|
125
|
+
function isBasicEligible(issuesCollection, eligibilityConfig) {
|
|
126
|
+
const { criticals, warnings } = evalIssues(issuesCollection, eligibilityConfig.basicEligibilityEpochs + 1);
|
|
127
|
+
return criticals === 0 && warnings <= eligibilityConfig.maxWarnings;
|
|
128
|
+
}
|
|
129
|
+
exports.isBasicEligible = isBasicEligible;
|
|
130
|
+
function isBonusEligible(issuesCollection, eligibilityConfig) {
|
|
131
|
+
const totalEpochs = eligibilityConfig.basicEligibilityEpochs + eligibilityConfig.bonusEligibilityExtraEpochs + 1;
|
|
132
|
+
const { criticals, warnings } = evalIssues(issuesCollection, totalEpochs);
|
|
133
|
+
return criticals === 0 && warnings <= eligibilityConfig.maxWarnings;
|
|
134
|
+
}
|
|
135
|
+
exports.isBonusEligible = isBonusEligible;
|
|
136
|
+
function getIssuesCollection(clusterInfo, aggregatedValidator, bonds, score, eligibilityConfig) {
|
|
137
|
+
return Array.from({ length: eligibilityConfig.basicEligibilityEpochs + eligibilityConfig.bonusEligibilityExtraEpochs + 1 }, (_, epochIndex) => getValidatorIssuesInEpoch(aggregatedValidator, bonds, epochIndex, eligibilityConfig, clusterInfo, score));
|
|
138
|
+
}
|
|
139
|
+
exports.getIssuesCollection = getIssuesCollection;
|
|
140
|
+
function computeValidatorEligibility(clusterInfo, aggregatedValidator, bonds, scores, eligibilityConfig, scoringConfig) {
|
|
141
|
+
const issuesCollection = getIssuesCollection(clusterInfo, aggregatedValidator, bonds, scores, eligibilityConfig);
|
|
142
|
+
const minExternalStake = (0, validators_1.selectExternalStakeMin)(aggregatedValidator, eligibilityConfig.basicEligibilityEpochs);
|
|
143
|
+
return {
|
|
144
|
+
basicEligibility: isBasicEligible(issuesCollection, eligibilityConfig),
|
|
145
|
+
bonusEligibility: isBonusEligible(issuesCollection, eligibilityConfig),
|
|
146
|
+
issuesCollection,
|
|
147
|
+
capFromBond: scoringConfig.CAP_FROM_BOND,
|
|
148
|
+
capFromExternalStake: minExternalStake * (eligibilityConfig.maxStakeShare / (1 - eligibilityConfig.maxStakeShare)),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
exports.computeValidatorEligibility = computeValidatorEligibility;
|
|
152
|
+
function computeValidatorsEligibilities(clusterInfo, scores, aggregatedValidators, bonds, eligibilityConfig, scoringConfig) {
|
|
153
|
+
const result = {};
|
|
154
|
+
for (const [voteAccount, validator] of Object.entries(aggregatedValidators)) {
|
|
155
|
+
if (!scores[voteAccount]) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
result[voteAccount] = computeValidatorEligibility(clusterInfo, validator, bonds, scores[voteAccount], eligibilityConfig, scoringConfig);
|
|
159
|
+
}
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
exports.computeValidatorsEligibilities = computeValidatorsEligibilities;
|
|
163
|
+
//# sourceMappingURL=eligibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eligibility.js","sourceRoot":"","sources":["../../src/computing/eligibility.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AAOtD,SAAgB,mBAAmB,CAAC,SAA8B,EAAE,UAAkB,EAAE,iBAAoC,EAAE,WAAwB;IACpJ,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,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,aAAa,CAAC,CAAC;KAC1I;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AATD,wEASC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ClusterInfo } from '../dto/cluster.dto';
|
|
2
|
+
import { ScoreDto, ScoreConfig, Scores, Variables } from '../dto/scoring.dto';
|
|
3
|
+
import { AggregatedValidator, AggregatedValidators } from '../dto/validators.dto';
|
|
4
|
+
import { ValidatorsEligibilities } from '../dto/eligibility.dto';
|
|
5
|
+
import { ScoringConfig } from '../dto/scoring.dto';
|
|
6
|
+
export declare function selectVariables(clusterInfo: ClusterInfo, aggregatedValidator: AggregatedValidator, scoreConfig: ScoreConfig): Variables;
|
|
7
|
+
export declare function computeValidatorScore(clusterInfo: ClusterInfo, aggregatedValidator: AggregatedValidator, formulas: string[], weights: number[], scoreConfig: ScoreConfig): ScoreDto;
|
|
8
|
+
export declare function computeValidatorsScores(clusterInfo: ClusterInfo, aggregatedValidators: AggregatedValidators, formulas: string[], weights: number[], scoreConfig: ScoreConfig): Scores;
|
|
9
|
+
export declare function scoreTooltipCredits(validator: AggregatedValidator, clusterInfo: ClusterInfo): string;
|
|
10
|
+
export declare function scoreTooltipBlockProduction(validator: AggregatedValidator, _clusterInfo: ClusterInfo): string;
|
|
11
|
+
export declare function scoreTooltipCommissionInflation(validator: AggregatedValidator, _clusterInfo: ClusterInfo): string;
|
|
12
|
+
export declare function scoreTooltipCommissionMEV(validator: AggregatedValidator, _clusterInfo: ClusterInfo): string;
|
|
13
|
+
export declare function scoreTooltipCountryStakeConcentration(validator: AggregatedValidator, _clusterInfo: ClusterInfo): string;
|
|
14
|
+
export declare function scoreTooltipCityStakeConcentration(validator: AggregatedValidator, _clusterInfo: ClusterInfo): string;
|
|
15
|
+
export declare function scoreTooltipNodeStake(validator: AggregatedValidator, _clusterInfo: ClusterInfo): string;
|
|
16
|
+
export declare function scoreTooltipASOStakeConcentration(validator: AggregatedValidator, _clusterInfo: ClusterInfo): string;
|
|
17
|
+
export declare function getScoreTooltipBuilders(): ((validator: AggregatedValidator, clusterInfo: ClusterInfo) => string)[];
|
|
18
|
+
export declare function getDefaultFormulas(scoringConfig: ScoringConfig): string[];
|
|
19
|
+
export declare function getDefaultWeights(scoringConfig: ScoringConfig): number[];
|
|
20
|
+
export declare function orderByEligibiltyAndScore(scores: Scores, eligibilities: ValidatorsEligibilities): string[];
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.orderByEligibiltyAndScore = exports.getDefaultWeights = exports.getDefaultFormulas = exports.getScoreTooltipBuilders = exports.scoreTooltipASOStakeConcentration = exports.scoreTooltipNodeStake = exports.scoreTooltipCityStakeConcentration = exports.scoreTooltipCountryStakeConcentration = exports.scoreTooltipCommissionMEV = exports.scoreTooltipCommissionInflation = exports.scoreTooltipBlockProduction = exports.scoreTooltipCredits = exports.computeValidatorsScores = exports.computeValidatorScore = exports.selectVariables = void 0;
|
|
4
|
+
const expr_eval_1 = require("expr-eval");
|
|
5
|
+
const maths_1 = require("../utils/maths");
|
|
6
|
+
const zip_1 = require("../utils/zip");
|
|
7
|
+
const validators_1 = require("./validators");
|
|
8
|
+
const logger_1 = require("../logging/logger");
|
|
9
|
+
function selectVariables(clusterInfo, aggregatedValidator, scoreConfig) {
|
|
10
|
+
return {
|
|
11
|
+
bp_cluster_mean: clusterInfo.meanBlockProductionOverBasicEligibilityPeriod,
|
|
12
|
+
bp_cluster_std_dev: clusterInfo.stdDevBlockProductionOverBasicEligibilityPeriod,
|
|
13
|
+
credits_pct_mean: (0, validators_1.selectCreditsPctMean)(aggregatedValidator, clusterInfo, scoreConfig.epochs),
|
|
14
|
+
bp_mean: (0, validators_1.selectBlockProductionMean)(aggregatedValidator, scoreConfig.epochs),
|
|
15
|
+
commission_inflation_max: (0, validators_1.selectCommissionInflationMax)(aggregatedValidator, scoreConfig.epochs + 1),
|
|
16
|
+
commission_mev: (0, validators_1.selectCommissionMEV)(aggregatedValidator),
|
|
17
|
+
country_stake_concentration_last: (0, validators_1.selectCountryStakeConcentration)(aggregatedValidator, clusterInfo),
|
|
18
|
+
city_stake_concentration_last: (0, validators_1.selectCityStakeConcentration)(aggregatedValidator, clusterInfo),
|
|
19
|
+
aso_stake_concentration_last: (0, validators_1.selectASOStakeConcentration)(aggregatedValidator, clusterInfo),
|
|
20
|
+
node_stake_last: (0, validators_1.selectNodeStake)(aggregatedValidator),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.selectVariables = selectVariables;
|
|
24
|
+
function computeValidatorScore(clusterInfo, aggregatedValidator, formulas, weights, scoreConfig) {
|
|
25
|
+
const scoreErrors = [];
|
|
26
|
+
const scores = [];
|
|
27
|
+
const values = [];
|
|
28
|
+
const tooltips = [];
|
|
29
|
+
let totalWeight = 0;
|
|
30
|
+
let totalScore = 0;
|
|
31
|
+
let totalConcentrationWeight = 0;
|
|
32
|
+
let totalConcentrationScore = 0;
|
|
33
|
+
const variables = { ...selectVariables(clusterInfo, aggregatedValidator, scoreConfig), ...(0, maths_1.mathUtilityFunctions)() };
|
|
34
|
+
for (const [formula, weight, tooltipBuilder] of (0, zip_1.zip)(formulas, weights, getScoreTooltipBuilders())) {
|
|
35
|
+
let score = 0;
|
|
36
|
+
try {
|
|
37
|
+
values.push(0);
|
|
38
|
+
score = expr_eval_1.Parser.evaluate(formula, variables);
|
|
39
|
+
scoreErrors.push(false);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
(0, logger_1.error)('Failed to calculate', formula, 'for', aggregatedValidator.voteAccount, 'err:', err);
|
|
43
|
+
scoreErrors.push(true);
|
|
44
|
+
}
|
|
45
|
+
totalWeight += weight;
|
|
46
|
+
totalScore += weight * score;
|
|
47
|
+
if (scoreConfig.concentrationParams.includes(scores.length)) {
|
|
48
|
+
totalConcentrationWeight += weight;
|
|
49
|
+
totalConcentrationScore += weight * score;
|
|
50
|
+
}
|
|
51
|
+
tooltips.push(tooltipBuilder(aggregatedValidator, clusterInfo));
|
|
52
|
+
scores.push(score);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
score: totalScore / totalWeight,
|
|
56
|
+
concentrationScore: totalConcentrationScore / totalConcentrationWeight,
|
|
57
|
+
scores,
|
|
58
|
+
values,
|
|
59
|
+
scoreErrors,
|
|
60
|
+
tooltips,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.computeValidatorScore = computeValidatorScore;
|
|
64
|
+
function computeValidatorsScores(clusterInfo, aggregatedValidators, formulas, weights, scoreConfig) {
|
|
65
|
+
const result = {};
|
|
66
|
+
for (const [voteAccount, aggregatedValidator] of Object.entries(aggregatedValidators)) {
|
|
67
|
+
result[voteAccount] = computeValidatorScore(clusterInfo, aggregatedValidator, formulas, weights, scoreConfig);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
exports.computeValidatorsScores = computeValidatorsScores;
|
|
72
|
+
function scoreTooltipCredits(validator, clusterInfo) {
|
|
73
|
+
return `Credits: ${validator.credits.slice(1).map((credits, e) => {
|
|
74
|
+
const epoch = validator.epochs[e + 1];
|
|
75
|
+
if (epoch !== undefined) {
|
|
76
|
+
const targetCredits = clusterInfo.targetCreditsByEpoch.get(epoch) || 1;
|
|
77
|
+
return `${(100 * credits / targetCredits).toFixed(2)}%`;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return 'N/A';
|
|
81
|
+
}
|
|
82
|
+
}).join(', ')}`;
|
|
83
|
+
}
|
|
84
|
+
exports.scoreTooltipCredits = scoreTooltipCredits;
|
|
85
|
+
function scoreTooltipBlockProduction(validator, _clusterInfo) {
|
|
86
|
+
return `Block production: ${validator.blocksProduced.map((blocksProduced, e) => {
|
|
87
|
+
const leaderSlot = validator.leaderSlots[e];
|
|
88
|
+
if (leaderSlot) {
|
|
89
|
+
return `${(100 * blocksProduced / leaderSlot).toFixed(2)}%`;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return '-';
|
|
93
|
+
}
|
|
94
|
+
}).join(', ')}`;
|
|
95
|
+
}
|
|
96
|
+
exports.scoreTooltipBlockProduction = scoreTooltipBlockProduction;
|
|
97
|
+
function scoreTooltipCommissionInflation(validator, _clusterInfo) {
|
|
98
|
+
return `Inflation commission: ${validator.commission.map(c => `${c}%`).join(', ')}`;
|
|
99
|
+
}
|
|
100
|
+
exports.scoreTooltipCommissionInflation = scoreTooltipCommissionInflation;
|
|
101
|
+
function scoreTooltipCommissionMEV(validator, _clusterInfo) {
|
|
102
|
+
return `MEV commission: ${validator.mevCommission} %`;
|
|
103
|
+
}
|
|
104
|
+
exports.scoreTooltipCommissionMEV = scoreTooltipCommissionMEV;
|
|
105
|
+
function scoreTooltipCountryStakeConcentration(validator, _clusterInfo) {
|
|
106
|
+
return `Country: ${validator.country}`;
|
|
107
|
+
}
|
|
108
|
+
exports.scoreTooltipCountryStakeConcentration = scoreTooltipCountryStakeConcentration;
|
|
109
|
+
function scoreTooltipCityStakeConcentration(validator, _clusterInfo) {
|
|
110
|
+
return `City: ${validator.city}`;
|
|
111
|
+
}
|
|
112
|
+
exports.scoreTooltipCityStakeConcentration = scoreTooltipCityStakeConcentration;
|
|
113
|
+
function scoreTooltipNodeStake(validator, _clusterInfo) {
|
|
114
|
+
return `Stake of the node: ${Math.round(validator.stake[0] ?? 0).toLocaleString()} SOL`;
|
|
115
|
+
}
|
|
116
|
+
exports.scoreTooltipNodeStake = scoreTooltipNodeStake;
|
|
117
|
+
function scoreTooltipASOStakeConcentration(validator, _clusterInfo) {
|
|
118
|
+
return `ASO: ${validator.aso}`;
|
|
119
|
+
}
|
|
120
|
+
exports.scoreTooltipASOStakeConcentration = scoreTooltipASOStakeConcentration;
|
|
121
|
+
function getScoreTooltipBuilders() {
|
|
122
|
+
return [
|
|
123
|
+
scoreTooltipCredits,
|
|
124
|
+
scoreTooltipBlockProduction,
|
|
125
|
+
scoreTooltipCommissionInflation,
|
|
126
|
+
scoreTooltipCommissionMEV,
|
|
127
|
+
scoreTooltipCountryStakeConcentration,
|
|
128
|
+
scoreTooltipCityStakeConcentration,
|
|
129
|
+
scoreTooltipASOStakeConcentration,
|
|
130
|
+
scoreTooltipNodeStake,
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
exports.getScoreTooltipBuilders = getScoreTooltipBuilders;
|
|
134
|
+
function getDefaultFormulas(scoringConfig) {
|
|
135
|
+
return [
|
|
136
|
+
scoringConfig.formulaVoteCredits,
|
|
137
|
+
scoringConfig.formulaBlockProduction,
|
|
138
|
+
scoringConfig.formulaInflationCommission,
|
|
139
|
+
scoringConfig.formulaMEVCommission,
|
|
140
|
+
scoringConfig.formulaStakeConcentrationCountry,
|
|
141
|
+
scoringConfig.formulaStakeConcentrationCity,
|
|
142
|
+
scoringConfig.formulaStakeConcentrationASO,
|
|
143
|
+
scoringConfig.formulaStakeConcentrationNode,
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
exports.getDefaultFormulas = getDefaultFormulas;
|
|
147
|
+
function getDefaultWeights(scoringConfig) {
|
|
148
|
+
return [
|
|
149
|
+
scoringConfig.weightVoteCredits,
|
|
150
|
+
scoringConfig.weightBlockProduction,
|
|
151
|
+
scoringConfig.weightInflationCommission,
|
|
152
|
+
scoringConfig.weightMEVCommission,
|
|
153
|
+
scoringConfig.weightStakeConcentrationCountry,
|
|
154
|
+
scoringConfig.weightStakeConcentrationCity,
|
|
155
|
+
scoringConfig.weightStakeConcentrationASO,
|
|
156
|
+
scoringConfig.weightStakeConcentrationNode,
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
exports.getDefaultWeights = getDefaultWeights;
|
|
160
|
+
function orderByEligibiltyAndScore(scores, eligibilities) {
|
|
161
|
+
const voteAccounts = Object.keys(scores);
|
|
162
|
+
voteAccounts.sort((a, b) => {
|
|
163
|
+
const eligibilityOrder = Number(eligibilities[b]?.basicEligibility ?? 0) - Number(eligibilities[a]?.basicEligibility ?? 0);
|
|
164
|
+
if (eligibilityOrder === 0) {
|
|
165
|
+
const scoreA = scores[a]?.score ?? 0;
|
|
166
|
+
const scoreB = scores[b]?.score ?? 0;
|
|
167
|
+
return scoreB - scoreA;
|
|
168
|
+
}
|
|
169
|
+
return eligibilityOrder;
|
|
170
|
+
});
|
|
171
|
+
return voteAccounts;
|
|
172
|
+
}
|
|
173
|
+
exports.orderByEligibiltyAndScore = orderByEligibiltyAndScore;
|
|
174
|
+
//# sourceMappingURL=score.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"score.js","sourceRoot":"","sources":["../../src/computing/score.ts"],"names":[],"mappings":";;;AAGA,yCAAmC;AACnC,0CAAsD;AACtD,sCAAmC;AAGnC,6CAA+O;AAC/O,8CAA0C;AAE1C,SAAgB,eAAe,CAAC,WAAwB,EAAE,mBAAwC,EAAE,WAAwB;IAC1H,OAAO;QACL,eAAe,EAAE,WAAW,CAAC,6CAA6C;QAC1E,kBAAkB,EAAE,WAAW,CAAC,+CAA+C;QAC/E,gBAAgB,EAAE,IAAA,iCAAoB,EAAC,mBAAmB,EAAE,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;QAC5F,OAAO,EAAE,IAAA,sCAAyB,EAAC,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAC;QAC3E,wBAAwB,EAAE,IAAA,yCAA4B,EAAC,mBAAmB,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;QACnG,cAAc,EAAE,IAAA,gCAAmB,EAAC,mBAAmB,CAAC;QACxD,gCAAgC,EAAE,IAAA,4CAA+B,EAAC,mBAAmB,EAAE,WAAW,CAAC;QACnG,6BAA6B,EAAE,IAAA,yCAA4B,EAAC,mBAAmB,EAAE,WAAW,CAAC;QAC7F,4BAA4B,EAAE,IAAA,wCAA2B,EAAC,mBAAmB,EAAE,WAAW,CAAC;QAC3F,eAAe,EAAE,IAAA,4BAAe,EAAC,mBAAmB,CAAC;KACtD,CA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,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACzB,MAAM,gBAAgB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,gBAAgB,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,gBAAgB,IAAI,CAAC,CAAC,CAAC;QAC3H,IAAI,gBAAgB,KAAK,CAAC,EAAE;YAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;YACrC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;YAErC,OAAO,MAAM,GAAG,MAAM,CAAC;SACxB;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC;AAdD,8DAcC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ValidatorsEligibilities } from '../dto/eligibility.dto';
|
|
2
|
+
import { Scores, ScoringConfig } from '../dto/scoring.dto';
|
|
3
|
+
import { Votes } from '../dto/snapshots.dto';
|
|
4
|
+
import { ProcessedVotesAndTVLs, Stakes, StakesConfig, StakingVariables } from '../dto/stakes.dto';
|
|
5
|
+
import { AggregatedValidators } from '../dto/validators.dto';
|
|
6
|
+
export interface ComputeStakesForValidatorsParams {
|
|
7
|
+
stakingVariables: StakingVariables;
|
|
8
|
+
eligibleValidators: string[];
|
|
9
|
+
scores: Scores;
|
|
10
|
+
eligibilities: ValidatorsEligibilities;
|
|
11
|
+
stakesConfig: StakesConfig;
|
|
12
|
+
mSolVotes: Votes;
|
|
13
|
+
veMndeVotes: Votes;
|
|
14
|
+
totalMsolVotes: number;
|
|
15
|
+
totalVeMndeVotes: number;
|
|
16
|
+
mSolTvl: number;
|
|
17
|
+
veMndeTvl: number;
|
|
18
|
+
algoTvl: number;
|
|
19
|
+
blockSize: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function removeFromVotes(votes: Votes, toRemove: string): Votes;
|
|
22
|
+
export declare function processVotesAndCalculateTVLs(mSolVotes: Votes, veMndeVotes: Votes, stakesConfig: StakesConfig, scoringConfig: ScoringConfig): ProcessedVotesAndTVLs;
|
|
23
|
+
export declare function filterEligibleValidators(aggregatedValidators: AggregatedValidators, eligibilities: ValidatorsEligibilities): string[];
|
|
24
|
+
export declare function initStakes(eligibleValidators: string[]): Stakes;
|
|
25
|
+
export declare function computeStakesForValidators(params: ComputeStakesForValidatorsParams): Stakes;
|
|
26
|
+
export declare function computeValidatorsStakes(aggregatedValidators: AggregatedValidators, scores: Scores, eligibilities: ValidatorsEligibilities, stakesConfig: StakesConfig, scoringConfig: ScoringConfig, mSolVotes: Votes, veMndeVotes: Votes): Stakes;
|