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!
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityYou 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/
even maybe by using your own pool
?
May 6, 2021 at 20:06
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.