TrancheRouter.issue function does not sweep unused ETH back to the caller
Summary
The TrancheRouter.issue function does not sweep unused ETH back to the caller, resulting in a loss of assets for the affected users.
Vulnerability Detail
Assume that when executing the issue function, Bob sends 101 ETH but sets the underlyingAmount to 100 ETH. Line 51 below will wrap 100 ETH to 100 WETH. Line 58 below will pull 100 WETH from the Router and 100 WETH worth of PT+YT will be minted to Bob.
However, there is still 1 unused ETH left on the Router, which is not swept back to Bob's account at the end of the TX. As such, the remaining ETH will be stolen by MEV.
Most router functions within Napier protocol will sweep any unused assets back to the caller at the end of the TX to handle such a case. However, this feature was missed in the TrancheRouter.issue function.
xiaoming90
high
TrancheRouter.issue
function does not sweep unused ETH back to the callerSummary
The
TrancheRouter.issue
function does not sweep unused ETH back to the caller, resulting in a loss of assets for the affected users.Vulnerability Detail
Assume that when executing the
issue
function, Bob sends 101 ETH but sets theunderlyingAmount
to 100 ETH. Line 51 below will wrap 100 ETH to 100 WETH. Line 58 below will pull 100 WETH from the Router and 100 WETH worth of PT+YT will be minted to Bob.However, there is still 1 unused ETH left on the Router, which is not swept back to Bob's account at the end of the TX. As such, the remaining ETH will be stolen by MEV.
Most router functions within Napier protocol will sweep any unused assets back to the caller at the end of the TX to handle such a case. However, this feature was missed in the
TrancheRouter.issue
function.https://github.com/sherlock-audit/2024-01-napier/blob/main/napier-v1/src/Tranche.sol#L179
Impact
Loss of assets for the affected users.
Code Snippet
https://github.com/sherlock-audit/2024-01-napier/blob/main/napier-v1/src/Tranche.sol#L179
Tool used
Manual Review
Recommendation
Consider implementing a feature to sweep any unused assets back to the callers at the end of the TX.