Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: ZuniswapV2Router.sol swapTokensForExactTokens #10

Open
zatoichi0826 opened this issue Jun 8, 2023 · 1 comment
Open

Bug: ZuniswapV2Router.sol swapTokensForExactTokens #10

zatoichi0826 opened this issue Jun 8, 2023 · 1 comment

Comments

@zatoichi0826
Copy link

function swapTokensForExactTokens(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to
    ) public returns (uint256[] memory amounts) {
        amounts = ZuniswapV2Library.getAmountsIn(
            address(factory),
            amountOut,
            path
        );
        if (amounts[amounts.length - 1] > amountInMax)
            revert ExcessiveInputAmount();
        _safeTransferFrom(
            path[0],
            msg.sender,
            ZuniswapV2Library.pairFor(address(factory), path[0], path[1]),
            amounts[0]
        );
        _swap(amounts, path, to);

for expression if (amounts[amounts.length - 1] > amountInMax)
I thought it would be if (amounts[0] > amountInMax)?

@zatoichi0826
Copy link
Author

I think amounts[amounts.length - 1] is the last logic amout input and amounts[0] is the first logic input, and for amountInMax, we need first logic input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant