- Fixed _getAmountsInAndPath() and _getAmountsOutData()

This commit is contained in:
eboado 2020-12-03 16:24:57 +01:00
parent 5fdb479333
commit a84cfdabe2

View File

@ -343,6 +343,7 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
uint256[] memory amountsWithWeth;
address[] memory pathWithWeth = new address[](3);
if (reserveIn != WETH_ADDRESS && reserveOut != WETH_ADDRESS) {
pathWithWeth[0] = reserveIn;
pathWithWeth[1] = WETH_ADDRESS;
pathWithWeth[2] = reserveOut;
@ -352,7 +353,10 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
) {
amountsWithWeth = resultsWithWeth;
} catch {
amountsWithWeth = new uint256[](2);
amountsWithWeth = new uint256[](3);
}
} else {
amountsWithWeth = new uint256[](3);
}
uint256 bestAmountOut;
@ -447,6 +451,8 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
uint256[] memory amountsWithoutWeth;
uint256[] memory amountsWithWeth;
address[] memory pathWithWeth = new address[](3);
if (reserveIn != WETH_ADDRESS && reserveOut != WETH_ADDRESS) {
pathWithWeth[0] = reserveIn;
pathWithWeth[1] = WETH_ADDRESS;
pathWithWeth[2] = reserveOut;
@ -458,6 +464,9 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
} catch {
return (new uint256[](2), new address[](2));
}
} else {
amountsWithWeth = new uint256[](3);
}
try UNISWAP_ROUTER.getAmountsIn(amountOut, simplePath) returns (
uint256[] memory resultAmounts