The tillIn function in the TokenManager contract does not handle cases where the msg.value exceeds the _amount parameter. This can lead to a situation where excess Ether sent by the caller is not returned, potentially causing a loss of funds for the user.
In the tillIn function, when the msg.value is greater than _amount, the function does not return the excess Ether to the caller. This is an issue because if a user sends more Ether than required for the transaction, the excess amount is not refunded, resulting in a loss of the excess funds.
The specific code segment that demonstrates this issue is:
After this check, the function proceeds to deposit the exact _amount of Ether but does not handle the scenario where msg.value is greater than _amount.
Users who interact with the tillIn function may accidentally send more Ether than required. Since the function does not return the excess Ether, users may lose these additional funds. This could lead to a poor user experience and financial loss for users who are unaware of this behavior.
Manual code review
Refund Excess Ether: Modify the tillIn function to handle cases where msg.value is greater than _amount. You should return any excess Ether to the caller after processing the deposit. For example:
Invalid, these are by default, invalid based on codehawks [general guidelines](https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity#findings-that-may-be-invalid). The check implemented is simply a sufficiency check, it is users responsibility to only send an appropriate amount of native tokens where amount == msg.value when native token is intended to be used as collateral (which will subsequently be deposited as wrapped token). All excess ETH can be rescued using the `Rescuable.sol` contract. > Users sending ETH/native tokens > If contracts allow users to send tokens acc111identally.
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.