0

I am not so familiar with Uniswap but I was wondering if a contract could add liquidity to a pair and be the owner. This is to prevent the developer from removing the liquidity. Thanks.

2 Answers 2

1

Yes a contract can call Uniswap to add liquidity into any pair. The contract simply needs to provide the required assets for the liquidity. Furthemore, the contract will then own the LP tokens, and therefore only the contract can remove liquidity - remember to add such functionality, otherwise you can never remove that liquidity anymore.

You can look here for an example: https://github.com/safemoonprotocol/Safemoon.sol/blob/a2a1b922b1260b618427183ec8d4475d70cf4daf/Safemoon.sol#L1098

3
  • Thanks! This works great. If I don't set the remove liquidity function, will only users with tokens be able to pull out money from the liquidity? My goal is that only mined tokens can be swapped for eth, and nobody can withdraw liquidity from the pool.
    – Ozmode
    Aug 10, 2021 at 8:08
  • If you don't add "remove liquidity" functionality in the contract, and you don't add functionality to transfer the LP tokens onwards from the contract, then that liquidity can't be removed. Of course if somebody manually adds liquidity, they can also remove that. If your pair is for tokenA and tokenB, then anyone who wants to trade needs to own either one of these tokens. Aug 10, 2021 at 8:15
  • The example contract is helpful. Is it possible to have the same contract to be able to add liquidity also for another external token? I tried to create the addLiquidity2 function for such purpose and couldn't get it to work.
    – Ozmode
    Aug 10, 2021 at 16:06
0

Yeah it's possible if the contract is using an auto LP function.

Also ask the developer to transfer the ownership and the tokens that are minted in the moment of deployment to you.

If you want to talk more about this, leave me a message: https://twitter.com/polthedev

2
  • Thanks. I mean nobody should be able to remove liquidity, only the contract itself under certain conditions.
    – Ozmode
    Aug 9, 2021 at 16:11
  • Also you can lock the liquidity for a certain amount of time using DXlock or DeepLock Aug 9, 2021 at 16:37

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.