The SablierFlow::depositViaBroker function manages fund deposits through a broker, while the internal SablierFlow::_depositViaBroker function verifies the broker and calculates the deposit amount. This internal function calls the Helpers::checkAndCalculateBrokerFee function to determine the broker fee and deposit amount based on the totalAmount.
However, the Helpers::checkAndCalculateBrokerFee function then relies on Helpers::calculateAmountsFromFee to compute the fee and net amount by subtracting the fee from the `totalAmount, according to a specified fee percentage. None of these functions validate that the totalAmount is not zero , even though the fee and deposit amounts are calculated from it.
Additionally, Helpers::calculateAmountsFromFee is also invoked in the SablierFlow::_withdraw internal function, which manages withdrawals and calculates the protocol fee and net withdrawal amount. Without validating that the totalAmount is not zero, the calculations of both the protocol fees and net withdrawal amounts may be inaccurate.
The Helpers::calculateAmountsFromFee function is utilized within the Helpers::checkAndCalculateBrokerFee and SablierFlow::_withdraw function, but neither of these functions currently includes a validation to confirm that the totalAmount is not zero. This lack of validation can result in calculation inconsistencies and unpredictable behavior. Specifically, when Helpers::calculateAmountsFromFee is called in Helpers::checkAndCalculateBrokerFee and SablierFlow::_withdrawto calculate the fees and net amounts, a zero totalAmount can lead to errors during broker deposits or when calculating protocol fees and net withdrawal amounts.
SablierFlow::_withdrawcode block below
It can lead to an unexpected behavior when the Protocolfee and net withdraw amount are being calculated
Manual Review
Include a check that will ensure that the totalAmount is not zero in the Helpers::calculateAmountsFromFeeto ensure totalAmount can not be zero.
Note: The error message can be changed according to the protocol chioce of error message.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.