← Protocols
Curve
01Description

The dominant stableswap and pegged-asset DEX. Curve also runs crvUSD (LLAMMA-based CDP), Curve Lend (isolated lending), and Stableswap-NG factory pools across all major EVM chains.

02Best for
  • 01stablecoin swaps (low slippage)
  • 02LSD / pegged-asset swaps (stETH, frxETH)
  • 03deep liquidity routing
  • 04crvUSD borrowing against ETH/LSTs
  • 05Curve Lend isolated markets
03Install
  • pnpm add @curvefi/api ethers
04Environment variables
VariableScopeDescription
NEXT_PUBLIC_CURVE_NETWORKClientNetwork slug for `@curvefi/api` (e.g. `ethereum`, `arbitrum`, `optimism`, `base`, `polygon`).
RPC_URLServerEVM RPC for the target chain.
05Prompt snippet
Integrate Curve. Use `@curvefi/api`: `await curve.init('JsonRpc', { url: RPC_URL }, { chainId })`, then `await curve.factory.fetchPools()` and `await curve.cryptoFactory.fetchPools()` to populate the pool registry. Quote a swap with `curve.router.getBestRouteAndOutput(fromAddress, toAddress, amount)` and execute with `curve.router.swap(...)`. For direct pool interaction call `pool.swap(i, j, dx, minDy)`, `pool.addLiquidity(amounts, minMintAmount)`, `pool.removeLiquidityOneCoin(burnAmount, i, minReceived)`. For crvUSD: open a LLAMMA position via `Controller.create_loan(collateral, debt, N)` where `N` = number of bands. For Curve Lend: each market is a `Vault` (ERC-4626) — `vault.deposit(assets, receiver)` to lend, `controller.create_loan` to borrow.
06Gotchas
  • Curve has multiple AMM math types — Stableswap (pegged), Cryptoswap (volatile), Stableswap-NG (factory, dynamic fees). Use the routing SDK; direct `get_dy` on the wrong pool will mis-quote.
  • `int128` indices `i, j` must match the pool's coin ordering — passing them swapped silently routes the wrong direction.
  • Many factory pools are unaudited / permissionless — verify a pool's deployer and oracle before listing it in your UI.
  • crvUSD uses LLAMMA: instead of one liquidation price, the position is soft-liquidated band-by-band, accruing losses (`loss`) as price moves through bands. Display `health` and `bands`, not a single price.
  • stETH/ETH pool depeg events have caused cascading liquidations historically — pool oracle may diverge from Chainlink during stress.
  • veCRV gauge weights, boosts, and bribes (Convex, Yearn, StakeDAO) sit on top of base APR — don't quote pool APR without including gauge rewards if relevant.
  • Approvals go to each individual pool/zap address — there is no central router approval; the SDK handles this but raw integrations must too.
07Alternatives