Submitted by hyh
exchange() -> _exchange() -> _alchemistWithdraw() is user funds utilizing call sequence and the slippage hard coded to 1% there can cause a range of issues.
For example, if there is not enough shares, the number of shares to withdraw will be unconditionally reduced to the number of the shares available. This can pass under 1% slippage and user will give away up to 1% without giving a consent to such a fee, which is big enough to notice.
On the other hand, in a similar situation when there is not enough shares available a user might knowingly want to execute with even bigger fee, but hard coded slippage will not be met and the withdraw be unavailable and funds frozen.
Setting the severity to medium as the end impact is either modest user fund loss or exchange functionality unavailability.
_alchemistWithdraw uses hard coded 1% slippage threshold and rewrites wantShares to be availableShares once TransmuterBuffers position isnt big enough:
TransmuterBuffer.sol#L511-L524
Alchemists _unwrap will revert withdrawUnderlying call once minimumAmountOut isnt met:
AlchemistV2.sol#L1344-L1346
There are 2 use cases for the function:
exchange (onlyKeeper) -> _exchange -> _alchemistWithdraw,
setFlowRate (onlyAdmin) -> _exchange -> _alchemistWithdraw
exchange() is the most crucial as it should be able to fulfil various types of user funds exchange requests:
TransmuterBuffer.sol#L526-L546
This way, one issue here is that user can end up giving away the full 1% unconditionally to market situation because there are not enough shares available.
Another one is that knowing that the conditions are bad or that there are not enough shares available and willing to run the exchange with bigger slippage the user will not be able to as there are no means to control it and the functionality will end up unavailable, being reverted by Alchemists _unwrap check.
Consider adding the function argument with a default value of 1%, so the slippage can be tuned when it is needed.
thetechnocratic (Alchemix) acknowledged and commented:
0xleastwood (judge) commented:
