Open code423n4 opened 2 years ago
WatchPug
https://github.com/code-423n4/2021-12-amun/blob/98f6e2ff91f5fcebc0489f5871183566feaec307/contracts/basket/contracts/singleJoinExit/SingleTokenJoin.sol#L47-L71
function joinTokenSingle(JoinTokenStruct calldata _joinTokenStruct) external { // ######## INIT TOKEN ######### IERC20 inputToken = IERC20(_joinTokenStruct.inputToken); inputToken.safeTransferFrom( msg.sender, address(this), _joinTokenStruct.inputAmount ); _joinTokenSingle(_joinTokenStruct); // ######## SEND TOKEN ######### uint256 remainingIntermediateBalance = INTERMEDIATE_TOKEN.balanceOf( address(this) ); if (remainingIntermediateBalance > 0) { INTERMEDIATE_TOKEN.safeTransfer( msg.sender, remainingIntermediateBalance ); } }
SingleTokenJoin#joinTokenSingle() can be changed to:
SingleTokenJoin#joinTokenSingle()
outputAmount
inputToken
msg.sender
This way we can avoid unnecessary dust INTERMEDIATE_TOKEN.
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-amun/blob/98f6e2ff91f5fcebc0489f5871183566feaec307/contracts/basket/contracts/singleJoinExit/SingleTokenJoin.sol#L47-L71
SingleTokenJoin#joinTokenSingle()
can be changed to:outputAmount
;inputToken
needed based on the amount of INTERMEDIATE_TOKEN (the output of above);inputToken
required frommsg.sender
;This way we can avoid unnecessary dust INTERMEDIATE_TOKEN.