0

how can I calculate the cost of deploying a new liquidity pair on uniswap? Ty

0

1 Answer 1

0

On a basic level, you can add the baseFeePerGas with a maxPriorityFee to get a maxFeePerGas that you are willing to pay, and then multiply that by the gas limit needed to call the relevant addLiquidity function.

It will generally require a consistent amount of gas, but it can vary wildly if a token you are adding has some wasteful mechanic on transfer.

To summarize one approach might look like:

#...
# Get basic gas price estimate
base = w3.eth.get_block('pending').baseFeePerGas
prio = w3.eth.max_priority_fee
max_gas = base + prio

#...

add_limit = router.functions.addLiquidity(
  TOKENA,
  TOKENB,
  AMOUNTA,
  AMOUNTB,
  slippageA,
  slippageB,
  DESTINATION,
  deadline
).estimate_gas()

print(f'''[>] Gas estimate:\n
[+] Add liquidity: {(max_gas*add_limit)}\n
''')

Assuming approvals have been done already, else they can be estimated the same way. To estimate addLiquidity pre approvals you would have to override state/use a fork, else estimate should fail at insufficient allowance.

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