[M-05] Incorrect variable used in function setupNewRound()
Severity
Impact: Medium
Likelihood: Medium
Description
The process of a round in AuctionV1Base is as follows:
The operator invokes the setupNewRound() function to calculate the newPrice and start a new round. The state of the new round is set to lotteryStarted = false and winnersSelected = false.
The seller invokes the startLottery() function, setting the round state to lotteryStarted = true.
The seller calls the selectWinner() function to conclude the round and set winnersSelected = true.
In the setupNewRound() function, the numberOfTickets variable is used to determine whether the price should increase or decrease. However, numberOfTickets always resets to 0 when the previous round ends in the selectWinner() function.
function setupNewRound(uint256 _finishAt, uint256 _numberOfTickets) public onlyOperator {
require(_numberOfTickets <= totalNumberOfTickets, "Tickets per round cannot be higher than total number of tickets in AuctionV1");
uint256 newPrice = 0;
// @audit `numberOfTickets` is always reset to `0`
// after finishing previous round in `selectWinner()`
if (prevRoundDeposits >= numberOfTickets) {
...
}
...
}
Recommendations
Consider revising the logic used to calculate newPrice in the setupNewRound() function.
[M-05] Incorrect variable used in function
setupNewRound()
Severity
Impact: Medium
Likelihood: Medium
Description
The process of a round in AuctionV1Base is as follows:
setupNewRound()
function to calculate thenewPrice
and start a new round. The state of the new round is set tolotteryStarted = false
andwinnersSelected = false
.startLottery()
function, setting the round state tolotteryStarted = true
.selectWinner()
function to conclude the round and setwinnersSelected = true
.In the
setupNewRound()
function, thenumberOfTickets
variable is used to determine whether the price should increase or decrease. However,numberOfTickets
always resets to0
when the previous round ends in theselectWinner()
function.Recommendations
Consider revising the logic used to calculate
newPrice
in thesetupNewRound()
function.