Submitted by QiuhaoLi, also found by 0xvj, Toshii, bin2chen, Udsen, sces60107, carrotsmuggler, bart1e, said, T1MOH, 0xDING99YA, SBSecurity, wintermute, and pep7siup
When _curveSwap is called with minAmount = 0 (upperDepeg/lowerDepeg use the default slippage 0.5%), the minOut will be a wrong value which leads to slippage protect failure.
In _curveSwap, the getDpxEthPrice and getEthPrice is in wrong order:
When _ethToDpxEth is true, we swap eth for dpxeth. However, we use getDpxEthPrice, which is dpxeths price in eth (dpxeth/eth). Also, when we swap dpxeth for eth, we use getEthPrice which is eths price in dpxeth.
Below is a PoC that demonstrates we get the wrong slippage when calling upperDepeg with default slippage tolerance:
Output:
Reverse the order:
psytama (Dopex) confirmed via duplicate issue 970
