fix: Fixed trade price in swap function for UniswapV2Adapter

This commit is contained in:
domenicodev
2024-02-22 18:38:12 +01:00
parent 58c56e2287
commit be9ce6ffc1

View File

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