DeFi developers

Build DeFi on a single global state

Every Solana program reads and writes the same state, so a swap, a loan repayment and an oracle update can run in one atomic transaction. Start from a working Anchor app, integrate live liquidity and ship with production practices.

Scaffold a Next.js app with an Anchor vault program
npx -y create-solana-dapp@latest -t solana-foundation/templates/kit/nextjs-anchor

Solana DeFi in numbers

DEX volume in the 30 days to Oct 8, 2026
$76B
Source
USD stablecoins on Solana as of Oct 8, 2026
$16B
Source
Compute units per block since Jul 29, 2026
100M
Source
Maximum v1 transaction size, up from 1,232
4,096 bytes
Source

Why Solana

Properties your protocol design can rely on

Atomic composability

Programs call each other through cross-program invocations inside one transaction. If any step fails, the whole transaction reverts, so a multi-protocol strategy never settles halfway.

Parallel execution

Each transaction declares the accounts it reads and writes up front. The runtime executes transactions that don't touch the same writable accounts in parallel, so one busy market doesn't stall unrelated ones.

Local fee markets

Transactions that write to a contested account compete for that account's share of the block. Price priority fees from the accounts you write, not from network-wide averages.

Shorter slots, faster finality

Mainnet slot times are being cut in stages, and Alpenglow will replace the current voting and finality protocol. Track both before you tune quote expiry, timeouts and liquidation windows.


Developer stack

Write, test and ship a program

The default path for a new protocol: Anchor for the program, LiteSVM and Surfpool for tests, Codama for clients and Kit for the app.

  1. 01Write the program

    Anchor or Pinocchio

    Anchor is the recommended framework for most programs, with account validation, IDL generation and CPI helpers built in. Reach for Pinocchio, a zero-dependency library, on hot paths where every compute unit counts.

  2. 02Test it

    LiteSVM, Mollusk and Surfpool

    Run fast in-process tests with LiteSVM or Mollusk. Then run integration tests on Surfpool, a local network that loads mainnet accounts on demand, so you can test against real pools and oracles.

  3. 03Generate clients

    Codama

    Generate typed TypeScript and Rust clients from your program's IDL, so instruction builders and account decoders stay in step with each deploy.

  4. 04Build the app

    Solana Kit

    @solana/kit is the standard JavaScript SDK. Its wallet plugin finds installed wallets through Wallet Standard, with no per-wallet adapter packages.


Building blocks

Integrate live DeFi protocols

These protocols publish developer documentation for their programs and APIs. Read each protocol's docs and audit reports before you route user funds through it.

Swaps and routing

Route swaps across Solana liquidity with an aggregator API, or request raw instructions to compose a swap inside your own transaction.

AMMs and liquidity pools

Create pools, provide concentrated liquidity and quote prices directly against on-chain AMMs.

Lending and borrowing

Supply collateral, borrow and read reserve state through lending market SDKs.

Oracles

Pull signed price updates into your transaction, and check confidence and staleness before you use a price.

Liquid staking

Accept liquid staking tokens as collateral, or route SOL into stake pools that earn validator rewards.

Examples only. Listing a protocol is not an endorsement by the Solana Foundation.


Transaction delivery

Land transactions when markets move

DeFi traffic peaks during volatility, exactly when users need their transactions to land. Build these into your client before mainnet.

  1. 1

    Set compute limits and priority fees

    Simulate to measure compute units, set a tight limit and price priority fees from recent fees on the accounts you write.

  2. 2

    Pick a transaction format per route

    v1 transactions raise the size limit; address lookup tables compress long account lists. Each carries a trade-off for complex routes.

  3. 3

    Send through staked connections

    Stake-weighted QoS reserves leader capacity for transactions forwarded by staked validators. Choose an RPC provider that supports it.

  4. 4

    Protect users from MEV

    Send user swaps through sandwich protection, and enforce slippage limits in the program as well as the interface.

  5. 5

    Confirm and retry correctly

    Track blockhash expiry, rebroadcast until the transaction lands or expires, and confirm at the commitment level your logic needs.


Security

Ship and operate securely

A DeFi program can hold user funds from its first deploy. Control who can change it, prove what's deployed and watch what it does.

Put authorities behind a multisig

Hold program upgrade and admin authorities in a Squads multisig, with a time lock on changes.

Publish a verified build

Let users and integrators confirm that the deployed program matches its public source.

Audit every release

Get independent audits before mainnet and run a bug bounty. The Solana Foundation funds STRIDE security evaluations and free tooling for ecosystem teams.

Monitor and alert

Microscope decodes your program's instructions and Squads proposals into self-hosted dashboards and alerts.


Further reading


Build DeFi on Solana | Solana