function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = IUniswapV2Pair(pair).mint(to);
}
- I have minted 2 ERC Token say Token1 & Token2 and also approved the address of deployed Router v2 contract from Token contracts.
- Also generated the INIT_CODE_HASH in the factory contract and added to the hash value by removing 0X.
- While trying to transact addLiquidity function I am getting an error "TransferHelper: TRANSFER_FROM_FAILED".
I have used the deployed code of Router & Factory contracts from ether scan. I am unable to point out the issue any help will be appreciated.
Thanks in Advance
tokenA.approve(ContractCallingSafeTrasnfer, AmountUsuallyMAXINT)