Swap / DEX·Solana
Lifinity
Proactive market maker on Solana that uses a Pyth oracle as the price reference and rebalances inventory algorithmically. Concentrated liquidity is provided by the protocol, not external LPs (v2 pools are protocol-owned).
- 01oracle-priced Solana swaps with low impermanent loss
- 02routing through Lifinity v2 pools (often via Jupiter)
- 03stable + correlated-asset pairs
- 04low-slippage execution on majors (SOL, USDC, mSOL, jitoSOL)
- pnpm add @lifinity/sdk-v2 @solana/web3.js bn.js
| Variable | Scope | Description |
|---|---|---|
| SOLANA_RPC_URL | Server | Solana mainnet RPC. Pyth account reads add latency — prefer a paid RPC. |
Use `@lifinity/sdk-v2` to interact with Lifinity v2 pools directly, or — recommended for most apps — route through Jupiter (`@jup-ag/api`), which already includes Lifinity in its DEX set. Direct SDK usage: `const amm = new LifinityAmm(connection, poolKey)`; call `amm.getQuote({ inputMint, outputMint, amount, slippageBps })` then `amm.swap({ user, ...quote })` to get a swap instruction. Always read the Pyth price account referenced by the pool to validate that the oracle is fresh (`price.publishTime` within ~10s) before submitting.
- ⚑Lifinity v2 pools are PROTOCOL-OWNED liquidity — third parties cannot deposit/withdraw LP positions; only Lifinity's vault rebalances. Do not build an `addLiquidity` UX against v2.
- ⚑Quotes depend on the Pyth oracle attached to the pool — if the Pyth feed is stale or has high `confidence`, the program will refuse the swap. Surface oracle-down errors to the user explicitly.
- ⚑Lifinity is best consumed via Jupiter aggregation (`@jup-ag/api`) — direct SDK usage adds maintenance burden and Jupiter routing usually finds equal-or-better fills.
- ⚑Set compute unit limit ≥ 400k and a priority fee — Pyth account loads + AMM math are CU-heavy and the tx will silently drop under defaults during congestion.
- ⚑Slippage protection should be enforced at the client (`minOutAmount`) since Lifinity's oracle-based pricing can deviate from on-chain reference if Pyth is delayed.