UNPKG

near-protocol-rewards

Version:

A transparent, metric-based rewards system for NEAR projects

34 lines (33 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OnChainRewardsCalculator = void 0; class OnChainRewardsCalculator { constructor(metrics) { this.metrics = metrics; this.weights = { transactionVolume: 0.4, contractInteractions: 0.4, uniqueWallets: 0.2, }; this.thresholds = { transactionVolume: 10000, contractInteractions: 500, uniqueWallets: 100, }; } calculate() { const tvScore = Math.min(this.metrics.transactionVolume / this.thresholds.transactionVolume, 1) * this.weights.transactionVolume * 50; const ciScore = Math.min(this.metrics.contractInteractions / this.thresholds.contractInteractions, 1) * this.weights.contractInteractions * 50; const uwScore = Math.min(this.metrics.uniqueWallets / this.thresholds.uniqueWallets, 1) * this.weights.uniqueWallets * 50; const totalScore = Math.min(tvScore + ciScore + uwScore, 50); return { totalScore, breakdown: { transactionVolume: tvScore, contractInteractions: ciScore, uniqueWallets: uwScore, }, }; } } exports.OnChainRewardsCalculator = OnChainRewardsCalculator;