0

I am developing a BEP20 token. The employer wants this token to be swappable in PancakeSwap.

When I read source of similar tokens, they add IUniswapV2Pair, IUniswapV2Router01 and IUniswapV2Router02 interfaces, but I can't find a guide that shows how to use these interfaces in the token contract source.

Is it necessary to use these interfaces for swappable tokens?

If yes, how can we use these interfaces?

3 Answers 3

2

Any token that complies the following criteria is swappable in PancakeSwap:

  1. It implements the ERC-20 (BEP-20 in Binance ecosystem).
  2. The Smart Contract of the token is deployed in Binance Smart Chain (BSC).

Is it necessary to use these interfaces for swappable tokens?

Absolutely not (considering what I said above).

1

There isn't any need to have a custom logic in your ERC-20 (or BEP-20, or their analogues for other chain) to support trading in decentralized exchanges. The exchange code is written in a way that ensures any token that implements the ERC-20 interface can be swapped, as long as the implementation does not break some simple invariants. On Uniswap v2 and it's clones, almost all existing ERC-20 tokens can be traded; Uniswap v3 and its clones are more demanding and do not support fee-on-transfer and rebasing tokens, for instance.

The reason developers put IUniswapV2Pair or IUniswapV2Router addresses in their contract logic is to exempt these addresses from transfer fees, or to have other custom logic, typically related to automatically selling the tokens collected via the transfer fee.

4
  • Thanks a lot. Do you know some documents about using these interface? Commented Feb 20, 2023 at 9:46
  • @AlirezaZojaji you have useful links about that in my answer, if helps. docs.openzeppelin.com/contracts/4.x/api/token/erc20#IERC20 Commented Feb 20, 2023 at 14:32
  • I understood your answer, but now I want to know how to use IUniswapV2Pair and IUniswapV2Router interfaces in my token source to decrease transfer fees. Do you know links about this? Commented Feb 20, 2023 at 17:07
  • @AlirezaZojaji questions asking for links to external sites aren't typically permitted on Stack Exchange. That said, I'm not aware of much formal documentation on these practices. I'd just go to Etherscan and read a few contracts for popular ERC-20 tokens with transfer fees.
    – kfx
    Commented Feb 20, 2023 at 17:28
1

Just implement ERC20 and the factory / router contract do the rest.

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.