Skip to content

Commit

Permalink
updated formula and tests (#242)
Browse files Browse the repository at this point in the history
Co-authored-by: Aodhgan <aodhgan@pooltogether.com>
  • Loading branch information
aodhgan and Aodhgan committed Oct 14, 2021
1 parent 1f26a90 commit b0cec3f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 147 deletions.
12 changes: 4 additions & 8 deletions contracts/DrawCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,10 @@ contract DrawCalculator is IDrawCalculator, Ownable {
pure
returns (uint256)
{
uint256 bitRangeDecimal = 2**uint256(_bitRangeSize);
uint256 numberOfPrizesForIndex = bitRangeDecimal**_prizeTierIndex;

while (_prizeTierIndex > 0) {
numberOfPrizesForIndex -= bitRangeDecimal**(_prizeTierIndex - 1);
_prizeTierIndex--;
if (_prizeTierIndex > 0) {
return ( 1 << _bitRangeSize * _prizeTierIndex ) - ( 1 << _bitRangeSize * (_prizeTierIndex - 1) );
} else {
return 1;
}

return numberOfPrizesForIndex;
}
}
Loading

0 comments on commit b0cec3f

Please sign in to comment.