> For the complete documentation index, see [llms.txt](https://docs.warpx.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.warpx.exchange/for-developers/warpx-v2/integration-workflows.md).

# Integration Workflows

#### Discovering or Creating Pools

1. Call `factory.getPair(tokenA, tokenB)`.
2. If it returns `address(0)`, call `factory.createPair(tokenA, tokenB)` (tokens will be sorted).
3. Alternatively, derive the address off-chain via `pair = address(uint(keccak256(abi.encodePacked(hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), INIT_CODE_PAIR_HASH))))` and watch for `PairCreated`.

#### Adding Liquidity (token-token)

1. Use `router.getAmountsOut` or `WarpLibrary.quote` to decide `amountAMin`/`amountBMin`.
2. `IERC20(tokenA/B).approve(router, amountADesired/amountBDesired)`.
3. Call `router.addLiquidity(...)` and receive LP tokens in `to`.
4. Capture the returned `(amountA, amountB, liquidity)` for accounting.\
   *For bonding-curve launchpads graduating to Warp, `addLiquidityETH` is typically the final step that pairs the emitted token with native ETH/WMEGAETH.*

#### Removing Liquidity

* Use `removeLiquidity` or `removeLiquidityETH` to withdraw, optionally signing a permit beforehand so the router can transfer LP tokens without a separate transaction.
* Integrations that tax transfers must route through the `SupportingFeeOnTransferTokens` variants to avoid shortfalls.

#### Swapping

1. Construct a `path` array (up to any length) of token addresses.
2. Determine `amountIn`/`amountOut` via the helper methods.
3. Approve the router for the first token (unless swapping from native ETH).
4. Call the appropriate swap function and monitor for `Swap` events emitted by each touched pair.
5. Set `deadline` on every user call to avoid stuck transactions.
