Final Result
1
2 import hmacSHA256 from 'crypto-js/hmac-sha256';
3
4 const generate = ({ clientSeed, serverSeed, edge }) => {
5 let hash = hmacSHA256(clientSeed, serverSeed).toString(hex);
6 let chunk = hash.substring(0, 8);
7 let denominator = parseInt(chunk, 16) + 1;
8 let maxValue = Math.pow(2, 32);
9
10 let result = (
11 Math.floor(Math.max(1, (maxValue / denominator) * (1 - edge / 100.0)) * 100) / 100.0
12 ).toFixed(2);
13 console.log(result)
14 return result;
15 };
16