Uniswap / v2-periphery

🎚 Peripheral smart contracts for interacting with Uniswap V2
https://uniswap.org/docs
GNU General Public License v3.0
1.14k stars 1.69k forks source link

getting UniswapV2: LOCKED error #159

Open Samboy76 opened 1 year ago

Samboy76 commented 1 year ago

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?

Salah-SH commented 1 month ago

did you solve the issue?