import React, { useState, useEffect } from 'react'; import { Calculator, TrendingUp, Users, BookOpen, Award } from 'lucide-react'; const TrustScoreCalculator: React.FC = () => { const [stakedAmount, setStakedAmount] = useState(100); const [stakingMonths, setStakingMonths] = useState(6); const [referralCount, setReferralCount] = useState(5); const [perwerdeScore, setPerwerdeScore] = useState(30); const [tikiScore, setTikiScore] = useState(40); const [finalScore, setFinalScore] = useState(0); // Calculate base amount score based on pallet_staking_score logic const getAmountScore = (amount: number) => { if (amount <= 100) return 20; if (amount <= 250) return 30; if (amount <= 750) return 40; return 50; // 751+ HEZ }; // Calculate staking multiplier based on months const getStakingMultiplier = (months: number) => { if (months < 1) return 1.0; if (months < 3) return 1.2; if (months < 6) return 1.4; if (months < 12) return 1.7; return 2.0; }; // Calculate referral score (matches pezpallet-referral tiered scoring) const getReferralScore = (count: number) => { if (count === 0) return 0; if (count <= 10) return count * 10; if (count <= 50) return 100 + ((count - 10) * 5); if (count <= 100) return 300 + ((count - 50) * 4); return 500; }; useEffect(() => { const amountScore = getAmountScore(stakedAmount); const multiplier = getStakingMultiplier(stakingMonths); const adjustedStaking = Math.min(amountScore * multiplier, 100); const adjustedReferral = getReferralScore(referralCount); const weightedSum = adjustedStaking * 100 + adjustedReferral * 300 + perwerdeScore * 300 + tikiScore * 300; const score = (adjustedStaking * weightedSum) / 10000; setFinalScore(Math.round(score)); }, [stakedAmount, stakingMonths, referralCount, perwerdeScore, tikiScore]); return (

Trust Score Calculator

Simulate your trust score based on staking, referrals, education, and roles

{/* Calculator Inputs */}
{/* Staking Score */}

Staking Amount

setStakedAmount(parseInt(e.target.value))} className="w-full mt-2" />
{stakedAmount} HEZ Score: {getAmountScore(stakedAmount)}
setStakingMonths(parseInt(e.target.value))} className="w-full mt-2" />
{stakingMonths} months ×{getStakingMultiplier(stakingMonths).toFixed(1)} multiplier
{/* Referral Score */}

Referral Score

setReferralCount(parseInt(e.target.value) || 0)} className="w-full mt-2 px-4 py-2 bg-gray-800 text-white rounded-lg border border-gray-700 focus:border-cyan-500 focus:outline-none" />
Score: {getReferralScore(referralCount)} points
{/* Other Scores */}

Perwerde Score

setPerwerdeScore(parseInt(e.target.value))} className="w-full" />
{perwerdeScore}

Tiki Score

setTikiScore(parseInt(e.target.value))} className="w-full" />
{tikiScore}
{/* Results and Formula */}
{/* Final Score */}

Final Trust Score

{finalScore}
Out of theoretical maximum
{/* Formula Breakdown */}

Formula Breakdown

weighted_sum =
staking × 100 +
referral × 300 +
perwerde × 300 +
tiki × 300
final_score = staking × weighted_sum / 10000
Staking Component: {Math.min(Math.round(getAmountScore(stakedAmount) * getStakingMultiplier(stakingMonths)), 100)} × 100
Referral Component: {getReferralScore(referralCount)} × 300
Perwerde Component: {perwerdeScore} × 300
Tiki Component: {tikiScore} × 300
{/* Score Impact */}

Score Impact

Monthly Rewards Eligibility 100 ? 'bg-green-900/30 text-green-400' : 'bg-red-900/30 text-red-400'}`}> {finalScore > 100 ? 'Eligible' : 'Not Eligible'}
Governance Voting Weight {Math.min(Math.floor(finalScore / 100), 10)}x
); }; export default TrustScoreCalculator;