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,8 +87,13 @@ contract UniswapV2SwapAdapter is ISwapAdapter {
buy(pair, sellToken, zero2one, r0, r1, specifiedAmount);
}
trade.gasUsed = gasBefore - gasleft();
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.
/// @param pair The pair to trade on.