Incorrect Confidence Calculation in Ticket Minting
calculateTicketsToMint reads _pythPrice.price instead of _pythPrice.conf for the confidence value, so (price - confidence) yields zero or negative ticket amounts and every purchase reverts.
Description
In the calculateTicketsToMint function of the MonadexV1Library contract, there is a critical error in the calculation of the confidence value. The function is using _pythPrice.price instead of _pythPrice.conf for the confidence calculation. This mistake leads to an incorrect subtraction of the confidence from the price, resulting in zero or negative ticket amounts.
Incorrect code:
uint256 confidence = _pythPrice.expo < 0? uint256(uint64(_pythPrice.price)) * decimals / 10 ** uint256(uint32(-1 * _pythPrice.expo)): uint256(uint64(_pythPrice.price)) * decimals * 10 ** uint256(uint32(-1 * _pythPrice.expo));
The current implementation:
uint256 ticketsToMint = (price - confidence) * _amount / _pricePerTicket;
Impact
The function will always calculate zero or negative tickets to mint, causing all ticket purchase transactions to revert with MonadexV1Raffle__ZeroTickets error. The raffle system becomes non-functional as no user can purchase tickets.
Recommendation
Correct code should use _pythPrice.conf:
uint256 confidence = _pythPrice.expo < 0? uint256(uint64(_pythPrice.conf)) * decimals / 10 ** uint256(uint32(-1 * _pythPrice.expo)): uint256(uint64(_pythPrice.conf)) * decimals * 10 ** uint256(uint32(-1 * _pythPrice.expo));

