0

I'm writing a token contract, and I'm wondering how pairing works precisely. I want to pair my token A with custom token B. I will add liquidity with x amount of token A and y amount of token B to create a liquidity pool. So the code would usually look like this when pairing with ETH

IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());

Now since I'm paring with token B, I have

 IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), address(TOKEN_B));

Now what I'm not sure about do you always create a pair with WETH and then the liquidity pool handles transfers from token A -> WETH -> token B. What's the downside of directly pairing with a custom token instead of WETH? Just a side not I want to identify the sale transaction in the transfer function by checking if the recipient is uniswapV2Pair.

1 Answer 1

0

When you pair your token A and token B, you'll bypass the intermediate step of converting to WETH, and you can only swap token A for token B and vice versa within that specific liquidity pool.

But if you pair token A with WETH, you can easily swap token A for many other tokens (As long as it is paired to WETH). Since WETH is popular, it can be traded with almost all tokens.

Direct Pairing:

Token A <-> Token B

Pairing with WETH:

Token A <-> WETH <-> Token B
Token A <-> WETH <-> Token C
2
  • That's what I thought, thanks for the explanation. In that case, how do I identify the sell event? Since with direct pairing, I can check if the recipient is that pair? Commented Apr 24, 2023 at 10:37
  • You can check the swap events, you can read the Transfer events from your liquidity Pool
    – Adam Boudj
    Commented Apr 24, 2023 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.