1

I know how to implement a tax/fee on each transaction.

What I'd like to know is where to send the tokens? Is the liquidity pool simply an address I can redirect the taxes to? Do I have to use some Uniswap library?

Thanks!

2 Answers 2

1

You can't simply add tokens to your pool. A pool always consists of two different assets. If you only add one type of assets, the pool's balance goes wrong and arbitrators will screw it up (assuming the token has enough liquidity).

You should add both of the assets at the same time, at the right ratio. So you need to convert some of the fee tokens to the other asset (even maybe by using your own pool) and then deposit those together.

For the Uniswap interaction you should use the Router contract: https://uniswap.org/docs/v2/smart-contract-integration/trading-from-a-smart-contract/

2
  • Hi Lauri, thanks for the reply. Can you explain what you mean when you say even maybe by using your own pool? May 6, 2021 at 20:06
  • Well, nothing stops you from swapping the asset in your own pool - the pool certainly has the other asset you need May 7, 2021 at 4:33
0

You didn't make it clear what you have access to. I'm assuming you have a token you are in control of, and you want to add liquidity to a Uniswap (v2? v3?) pool for users of that token.

If you want to just institute a tax on certain token transactions, you would do that in the token contract. If using e.g. OZ's ERC-20 contract, you could include this by adding an override of the _beforeTokenTransfer hook. Within the hook, you evaluate the transfer and determine if it's a uniswap trade, and if so, take a cut.

The liquidity pool will indeed be a certain address that the token will be being sent to.

However, if you also want to make sure that those fees go to LP providers, it gets a bit more interesting. You have a couple options.

  1. Uniswap already does this, so just use uniswap if you're fine with that rate. In v2 it's .3%.
  2. Deploy your own liquidity pool with a different rate--could be a uniswap clone if you like.
  3. While you could write your own router for the uniswap pool that would in theory be able to extract extra fees, and put those fees into the liquidity pool, and give a proportionate amount of those fees back to providers when they withdraw their liquidity, you won't be able to incentivize swappers to use your router instead of the cheaper uniswap router. To handle that, you need to extract the tax from the token contract itself (e.g. in the hook as described above), and then have liquidity pool depositors use the custom router that shares collected tax earnings with them (most likely when they burn their liquidity pool tokens in exchange for the underlying liquidity, but could be whenever you want,e.g. through a claim function).

Your Answer

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

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