On-Chain Automatic Dividend Algorithm
Cause
The traditional dividend calculation formula is: MyDividend = MyHashrate * (DividendAmount / TotalHashrate).
At dividend time, the dividend amount must be calculated for each user. When the number of users is large, on-chain calculations consume significant gas, sometimes even causing the smart contract method to fail due to excessive gas consumption. As a result, many opt for centralized dividend calculations, which cannot guarantee fairness and transparency. If the centralized server stops running, dividend rewards cannot be claimed.
To solve this problem, ComFox's LPH mining reward distribution adopts a 100% decentralized on-chain automatic dividend algorithm.
Implementation
totalLPH: The total LPH of the entire network. Increases when users purchase LPH.
usersUnitAcc: The cumulative unit hashrate reward value.
myLPH: My LPH hashrate value.
myDebt: My debt value. Updated after claiming rewards.
When releasing rewards, only the usersUnitAcc value needs to be updated:
usersUnitAcc = usersUnitAcc + (ReleasedAmount / totalLPH)
Real-Time Reward Calculation
MyPendingRewards = myLPH * usersUnitAcc - myDebt
Claiming Rewards
CurrentClaimableRewards = myLPH * usersUnitAcc - myDebt
Update My Debt: myDebt = usersUnitAcc * myLPH
3 Advantages
Efficiency: Dividend calculation does not increase with the number of users, saving significant gas fees.
Fairness: 100% on-chain execution ensures openness and fairness.
Real-Time: Once rewards are released, users can immediately view and claim their earnings.
Security: Unclaimed rewards accumulate daily. Your rewards will never be lost.
Last updated