Merge pull request #8 from propeller-heads/fix/uniswapv2-adapter

fix: Fixed trade price in swap function for UniswapV2Adapter
This commit is contained in:
Alan Höng
2024-02-26 10:54:17 +00:00
committed by GitHub

View File

@@ -87,7 +87,12 @@ contract UniswapV2SwapAdapter is ISwapAdapter {
buy(pair, sellToken, zero2one, r0, r1, specifiedAmount);
}
trade.gasUsed = gasBefore - gasleft();
trade.price = getPriceAt(specifiedAmount, r0, r1);
if(side == OrderSide.Sell) {
trade.price = getPriceAt(specifiedAmount, r0, r1);
}
else {
trade.price = getPriceAt(trade.calculatedAmount, r0, r1);
}
}
/// @notice Executes a sell order on a given pool.