From be9ce6ffc1cca6a5d1acdc52bc5b6b5c0f200a1f Mon Sep 17 00:00:00 2001 From: domenicodev Date: Thu, 22 Feb 2024 18:38:12 +0100 Subject: [PATCH] fix: Fixed trade price in swap function for UniswapV2Adapter --- evm/src/uniswap-v2/UniswapV2SwapAdapter.sol | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/evm/src/uniswap-v2/UniswapV2SwapAdapter.sol b/evm/src/uniswap-v2/UniswapV2SwapAdapter.sol index cd07683..16a1673 100644 --- a/evm/src/uniswap-v2/UniswapV2SwapAdapter.sol +++ b/evm/src/uniswap-v2/UniswapV2SwapAdapter.sol @@ -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.