Add Liquidity
Adding liquidity to a QsnDEX pool deposits both tokens of a pair and mints LP tokens in return. These LP tokens represent your share of the pool and entitle you to a proportional cut of all trading fees.
Auto-Ratio Calculation
When a pool already exists, the interface automatically calculates the required ratio of both tokens based on the current pool reserves. Entering an amount for one token will populate the corresponding amount for the other, ensuring your deposit maintains the pool's current price.
First Liquidity Provider
If you are the first to add liquidity to a new pair, you set the initial price by choosing the ratio of the two tokens you deposit.
Important: The first MINIMUM_LIQUIDITY of 1000 wei of LP tokens is permanently locked (sent to the zero address). This is a standard safeguard that prevents the total LP supply from ever reaching zero and protects against certain mathematical edge cases in the AMM.
Automatic Pool Creation
If no pool exists for a given token pair and fee tier, adding liquidity will automatically deploy a new pool through the Factory contract. No separate pool creation step is required.
Slippage Protection
When submitting an add-liquidity transaction, you specify minimum acceptable LP token output. If the pool state changes between signing and execution (e.g., another transaction lands first) and the resulting LP tokens would fall below your minimum, the transaction reverts. This protects against unfavorable price movements during the confirmation window.
ETH Pair Support
For pairs involving ETH, the Router contract handles wrapping and unwrapping automatically. You deposit native ETH and the contract wraps it to WETH before adding it to the pool. No manual WETH conversion is needed.
Gasless Approvals via Permit
QsnDEX tokens support EIP-2612 permit, allowing you to approve token spending through a signature rather than an on-chain approval transaction. This saves gas and streamlines the deposit flow into a single transaction from the user's perspective.
Step-by-Step Process
- Select the two tokens and fee tier for the pool.
- Enter the amount for one token; the other amount is calculated automatically (unless you are the first LP).
- Set your slippage tolerance (controls the minimum LP tokens you will accept).
- Approve the tokens (or sign a permit message for gasless approval).
- Confirm the transaction to deposit tokens and receive LP tokens.