Submitted by bin2chen, also found by Toshii, QiuhaoLi, sces60107, 0Kage, flacko, ubermensch, ether_sky, qpzm, kutugu, pep7siup, gjaldon, carrotsmuggler, mert_eren, said, 0xDING99YA, tapir, Yanchuan, and deadrxsezzz
in reLP() , Calculating mintokenAAmount using the wrong formula can invalidate the slippage protection
ReLPContract.reLP()The implementation is as follows:
The formula for calculating mintokenAAmount in the above code is
((amountB / 2) * tokenAInfo.tokenAPrice) / 1e8
amountB is the amount of tokenB, but tokenAInfo.tokenAPrice is the price of tokenA, which shouldnt be multiplied together
The correct one should be
((amountB / 2) * 1e8 / tokenAInfo.tokenAPrice)
psytama (Dopex) confirmed
