Last active
August 7, 2021 17:31
-
-
Save this-post/2be3811298979f97932640a573f0d7b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { | |
for (uint i; i < path.length - 1; i++) { | |
(address input, address output) = (path[i], path[i + 1]); | |
(address token0,) = PancakeLibrary.sortTokens(input, output); | |
uint amountOut = amounts[i + 1]; | |
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); | |
address to = i < path.length - 2 ? PancakeLibrary.pairFor(factory, output, path[i + 2]) : _to; | |
IPancakePair(PancakeLibrary.pairFor(factory, input, output)).swap( | |
amount0Out, amount1Out, to, new bytes(0) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment