invalid prizePool value for historical lotteries
iparsrc opened this issue · comments
I think the problem is in the claimReward
function that calls _transferPrize
function. In the _transferPrize
function, the _winnerPrize
is reduced from prizePool
and then it's added to the historical lotteries.
function claimReward()
external
ifCompleted
randomNumberGenerated
onlyWinnerOrOwner
{
uint256 winnerPrize = prizePool * (winnerPercentage / 100);
_transferPrize(winnerPrize);
_addLottery();
_reset();
emit ClaimedReward(lotteryID);
}
function _transferPrize(uint256 _winnerPrize) private {
prizePool -= _winnerPrize;
winner.transfer(_winnerPrize); // transfer the winnerPrize to the winner
payable(owner()).transfer(prizePool); // transfer the rest of the prizePool to the owner
}
function _addLottery() private {
allLotteries[lotteryID++] = LotteryInfo(
lotteryID,
prizePool,
costPerTicket,
startingTimestamp,
closingTimestamp,
winner,
randomResult
);
}
And please make the startingTimestamp
, winnerPercentage
and lotteryDuration
public :D