DeFi integrations on Solana are patterns for composing liquidity, credit, stake receipts, prices, and derivatives through explicit account lists and cross-program invocations (CPIs). Once you map AMMs, Jupiter routing, lending, LSTs, oracles, perps, and Jito/MEV as one composability graph, product design becomes "which programs, which accounts, which failure modes," not a pile of unrelated SDKs.
Solana DeFi is a composability graph: SPL token accounts, pool and market programs, price oracles, and inclusion paths (fees and MEV) that your client or program must name, validate, and sequence in one atomic transaction when possible.
Insight: Almost every product feature that moves value (swap, deposit, borrow, liquidate, rebalance) is an integration problem: wrong accounts, stale quotes, bad oracle freshness, or missing tip strategy fail in production even when math is correct.
Key Concepts:AMM pools, aggregators (Jupiter), money markets, LSTs, oracle price accounts, perps / CLOBs, CPI chains, slippage and health factors, priority fees vs Jito tips.
When to Use: Designing a wallet swap, vault, leverage loop, treasury rebalance, liquidator bot, or any program that CPIs into ecosystem liquidity and risk rails.
Limitations/Trade-offs: Routes and pool layouts change; oracles and markets can pause; CU and account limits constrain multi-hop CPI; MEV can extract value from unprotected flow; each venue adds program-id and layout version risk.
Related Topics: DeFi basics, AMMs, Jupiter swaps, lending, LSTs, oracles, Jito and MEV, perps and order books.
Solana does not ship a single "DeFi VM." It ships a runtime that moves lamports and program-owned bytes under owner-writes rules, plus programs that interpret those bytes as pools, banks, stake receipts, and order books. Integration means speaking those programs' instruction layouts and account graphs correctly.
Every durable balance is still an SPL token account (or native / wrapped SOL). DeFi positions add more accounts: pool vaults, obligation PDAs, LST mints, margin accounts, oracle feeds. Clients and programs must declare them so Sealevel can lock them and CPIs can pass them down the stack.
Think of the builder map as layers from user intent to inclusion:
User intent (swap, lend, lever, hedge) | v +--------------------------------------+ | Aggregators / routers (e.g. Jupiter) | optional off-chain route plan +--------------------------------------+ | Venue programs: AMM / CLOB / perps / | | lending / stake pools | on-chain state + CPI +--------------------------------------+ | Oracles (Pyth, Switchboard, ...) | price and risk inputs +--------------------------------------+ | Token Program + ATAs / vaults | custody of balances +--------------------------------------+ | Inclusion: priority fees, Jito tips | land under contention +--------------------------------------+
AMMs (Raydium, Orca, Meteora, and peers) hold reserves or concentrated liquidity and price swaps by curve or tick math. Jupiter sits above many of them: quote off-chain and return a route so you do not maintain every pool graph. Lending (Kamino, MarginFi, and similar) maps collateral and debt to health and liquidations. LSTs (jitoSOL, mSOL, and peers; often Sanctum-style routing) wrap staked SOL into fungible claims for collateral and loops. Oracles publish price accounts you treat as time-bounded inputs. Perps and order books add positions, matching, and mark/funding rules. Jito and MEV paths decide whether multi-leg flow lands atomically and who captures sandwich or arb value.
The rule: your product owns the composition. Each leg is a validated CPI or client-built instruction list; atomicity is one transaction succeeds or none do until you deliberately multi-tx and accept partial state.
Before any swap or deposit, resolve mints, decimals, and ATAs for the user and intermediate hops. Missing ATAs are a common "works in tests, fails in wallet" bug. Wrap/unwrap SOL is first-class; treat wSOL as a mint with create/close, not free-floating lamports inside every pool.
Direct AMM work fits LP deposit/withdraw, custom routing, or on-chain CPI swaps without an aggregator. Validate program id, pool mints, and vault addresses before transfer CPI. See AMMs (Raydium, Orca, Meteora).
Constant-product intuition helps, but production liquidity is often concentrated or dynamic. Refresh pool state at build time and enforce slippage (min out / max in).
Swaps with Jupiter is the default product path: quote → swap tx → sign with @solana/kit. Duties remain: pin slippage bps, handle wrap SOL, simulate, re-quote on failure. Do not hard-code forever routes; liquidity migrates.
Use Jupiter for best price and low maintenance. Use direct AMM CPIs when your program must control path, custody, or fee skim inside one stack.
Money markets turn deposits into supply and allow borrows under a health factor: deposit collateral, optionally borrow, monitor health, and design for liquidators. Leverage loops are lending + AMM/Jupiter, not a separate chain feature. Plan for oracle dependency and utilization spikes. Details: Lending & Borrowing.
An LST is usually an SPL mint whose rate tracks staked SOL (minus provider fees). That unlocks collateral and faster market exit, plus contract, liquidity, and depeg risk. Surfaces: mint/redeem, LST swaps, collateral with oracle haircuts. See Liquid Staking (LSTs).
Any borrow, liquidation, or funding that depends on USD value must read a price feed, enforce max age, confidence, and correct feed id. Pyth and Switchboard still require fail-closed checks on stale or wrong accounts.
risk action --> load feed --> age/conf OK? --> convert units --> LTV or min-out | fail closed if stale or wrong feed
Do not use last-trade pool spot alone as the risk oracle for undercollateralized credit. See Oracles.
CLOBs and perps optimize for price-time priority, limits, and leverage. Account graphs grow (market, orders, positions, vaults). Partial fills differ from AMM single-price swaps. Prefer them when limit UX or derivatives models beat curve swaps. See Perps & Order Books.
Multi-leg DeFi competes on inclusion and ordering. Priority fees bid via compute unit price. Jito bundles and tips are a parallel path through block engines.
Path A: single tx + CU price --> public leader schedule Path B: bundle + tip --> block engine --> leader
Bound slippage, consider bundles for toxic flow, and do not confuse tips with Compute Budget priority fees. See Jito & MEV.
Production DeFi fails less on algebra than on account graphs, versioning, and contention. Match depth to surface.
Path
What you integrate
Strengths
Weaknesses
Best fit
Jupiter-only swaps
Quote/swap API + kit
Fast ship; multi-venue
Off-chain dependency
Wallets, rebalance
Direct AMM CPI
Pool accounts + ix
On-chain control; LP
Layout churn
Vaults, custom routers
Lending + oracle
Banks, obligations, feeds
Credit and leverage
Liquidation / pause risk
Money markets, loops
LST collateral stack
Pools + lending + oracles
Yield-bearing collateral
Depeg, provider risk
Treasury and loops
Perps / CLOB
Market + positions
Limits; derivatives
Latency and ops cost
Trading venues, hedges
MEV-aware landing
Tips, bundles, fees
Better atomic land rates
Extra infra
Liquidators, arbs, size
CU and account limits cap hops per transaction. Split only with recovery: if leg 1 lands and leg 2 fails, UX must handle partial state.
Program upgrades change discriminators and remaining accounts. Pin IDL/SDK versions and fixture-test mainnet txs across upgrades.
Hot accounts serialize writers under load. Fees, tips, simulation, and fresh blockhashes are part of DeFi integration, not "infra only."
Security for integrators: verify external program ids, constrain client-supplied oracle/pool accounts, enforce slippage and health on-chain when you CPI, and document venue pause/upgrade authorities.
For design reviews: intent → instruction graph, custody per mint, oracle policy, slippage/health bounds, landing strategy, and which sibling article owns the deep dive.
"DeFi is one protocol I integrate once." It is a graph of independent programs and token accounts; each edge is a separate validation and failure surface.
"Jupiter replaces understanding AMMs." Aggregators hide pool selection for swaps; LP, custom CPI, and incident debugging still require venue literacy.
"If the quote looks good, the on-chain swap is safe." Quotes age; without slippage bounds and simulation, fills can fail or worsen between build and land.
"Pool spot price is enough for lending risk." Undercollateralized credit needs robust oracles with freshness and confidence checks, not only last swap price.
"LSTs are free yield with no integration cost." They add mint/redeem flows, oracle haircuts, and depeg scenarios on top of staking economics.
"Priority fee and Jito tip are the same field." CU price is Compute Budget; tips and bundles use separate inclusion machinery.
"Atomic multi-venue strategy always fits one transaction." Account and CU limits force multi-tx designs that need explicit partial-failure handling.
"Client SDKs remove the need to check account owners." On-chain programs must still constrain program ids and key relationships; clients can be wrong or hostile.
What is the single most important idea in Solana DeFi integration?
Compose external programs through explicit accounts and CPIs (or client-built instruction lists), and treat oracles, slippage, health, and inclusion as first-class product requirements, not afterthoughts.
When should I use Jupiter instead of direct AMM integration?
Use Jupiter for best-price user swaps and simple rebalances without maintaining pool graphs. Use direct AMM paths for LP management, tightly controlled on-chain CPI, or venue-specific features aggregators do not expose.
What accounts does a typical swap touch?
User token accounts (in/out), intermediate ATAs if multi-hop, pool or route accounts, Token Program, sometimes System Program for ATA create or SOL wrap, and compute budget accounts for fees.
How do lending protocols relate to AMMs?
They are separate programs. Leverage and vault strategies often CPI or sequence both: borrow from a money market, swap on an AMM or via Jupiter, then deposit again.
Why do LSTs show up so often in Solana DeFi?
They turn staked SOL into a transferable SPL balance that markets accept as collateral or liquidity, enabling yield-bearing loops without native stake account UX on every hop.
What must every oracle integration enforce?
Correct feed account, price age bound, confidence or status checks, and unit conversion (expo, decimals) before any risk-sensitive math.
How is a CLOB integration different from an AMM swap?
CLOBs use order and position accounts with place/cancel/match semantics and often tighter latency requirements; AMMs usually price from pool state in a single swap-style instruction.
When do I need Jito bundles?
When atomic multi-transaction strategies, liquidations, or high-value order-sensitive flows need better inclusion and ordering than public mempool priority fees alone provide.
Can my Anchor program CPI into Jupiter?
Many products build Jupiter transactions off-chain with kit. Pure on-chain aggregator CPI is specialized and version-sensitive; prefer known venue interfaces when you must CPI from a program.
What fails first under mainnet load?
Stale quotes, undersized CU, missing writable accounts, hot-account contention, and underpriced fees or tips - more often than pure math bugs.
How should I handle SOL vs wSOL?
Decide wrap policy up front. Many venues want wSOL ATAs: create, fund, use, and close temporary accounts so users are not left with dust or failed transfers.
What is a health factor in one sentence?
The protocol ratio of haircut, oracle-priced collateral to debt; below threshold the position is liquidatable.
Do I need an indexer for DeFi products?
RPC and kit suffice for current balances and one-shot txs. History, PnL, liquidator scanners, and ops metrics need parsed indexed events.
How do I version integrations across venue upgrades?
Pin SDKs/IDLs, fixture-test real transactions, gate remaining-account changes behind client versions, and watch upgrade authorities you depend on.
What is a practical integration checklist before launch?
Map mints and ATAs, name external program ids, define oracle and slippage/health policy, simulate full txs, set CU and fee/tip strategy, document partial-failure recovery, and own venue upgrade response.