Uniswap – Understanding Fees on Transfer Tokens and Uniswap V2

uniswap

I am implementing a uniswap v2 front end interface for a UniswapV2Router contract. I was wondering how does uniswap identifies when swapExactETHSupportingFeeOnTransferTokens needs to be used instead of swapExactETHForTokens. In other words, how does the uniswap interface identifies fee on transfer tokens? Also for both these functions does the user only need approve the router ?

Best Answer

For your two questions:

  1. How does uniswap identifies when swapExactETHSupportingFeeOnTransferTokens needs to be used instead of swapExactETHForTokens.
const useFeeOnTransfer = Boolean(options.feeOnTransfer)

const methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens'
  1. Both these functions does the user only need approve the router ?
  • The answer is No if you swap from native token to standard token, eg. swapExactETH... However, if you swap from standard token to native token (i.e., WETH to LDO), you have to approve the router to use the token.

Hope it helps you.

Related Topic