Skip to content

getting UniswapV2: LOCKED error #159

@Samboy76

Description

@Samboy76

Hi Uniswap team,

I've encountered an issue when trying to integrate with Uniswap, didn't find anything on google which is similar.

I'm using Hardhat deployment (forking mainnet)
MS Visual Studio IDE

I´ve taken out a flashloan for USDC token0 amount from uniswap_router, let´s say 1 USDC as an example, and then attempted to perform a swap using this 1 USDC flashloan amount to WETH on the same uniswap_router within the same transaction which I was told it is possible to do on the same router without the LOCKED error occuring.

Here´s the following code snippet which illustrates a simple contract which attempts to exchange USDC -> WETH (and erc20 token)

`
address[] memory path = new address;
path[0] = usdc; ()
path[1] = weth; ()

uint[] memory amounts = IUniswapV2Router02(uniswap_router).swapExactTokensForTokens(1, path, address(this), now + 15);
return amounts[1];`

uniswap_router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
USDC = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

From that call I get UniswapV2: LOCKED which, after looking around, only appears in UniswapV2Pair.sol (https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2Pair.sol)

What did I do wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions