← Protocols
Lifinity
01Description

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).

02Best for
  • 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)
03Install
  • pnpm add @lifinity/sdk-v2 @solana/web3.js bn.js
04Environment variables
VariableScopeDescription
SOLANA_RPC_URLServerSolana mainnet RPC. Pyth account reads add latency — prefer a paid RPC.
05Prompt snippet
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.
06Gotchas
  • 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.
07Alternatives