TypeScript SDK

Overview

What the Project 0 TypeScript SDK is, how it is organised, and where to start.

@0dotxyz/p0-ts-sdk is the official TypeScript SDK for the marginfi program that powers Project 0 on Solana. It loads the protocol state (banks, oracle prices, lookup tables, e-mode settings) into a single client, wraps your marginfi account in a convenient API, and builds complete, ready-to-sign transactions for every protocol action — from a plain deposit to a leveraged loop that crosses venues (Project 0, Kamino, Drift and Jupiter Lend).

Program upgrade 0.1.10 — 2026-08-25 15:00 UTC. Integrators must be on @0dotxyz/p0-ts-sdk@^2.7.0 before the mainnet flip; older SDKs break on flash loans, health simulation and account transfers afterwards. See Program Upgrade 0.1.10.

Coming from @mrgnlabs/marginfi-client-v2? It has been deprecated since March 2026 — follow the migration guide.

Start here

Core

Advanced flows

Reference

Package entry points

ImportContents
@0dotxyz/p0-ts-sdkEverything you normally need: Project0Client, MarginfiAccountWrapper, transaction and instruction builders, types and utilities.
@0dotxyz/p0-ts-sdk/vendorHeavy oracle and venue integrations (Pyth, Switchboard, Kamino, Drift, Jupiter Lend, Exponent, …). Split out to keep bundles small.
@0dotxyz/p0-ts-sdk/jupiterJupiter swap helpers (createJupiterClient).
@0dotxyz/p0-ts-sdk/instructionsRaw Anchor instruction builders — see Architecture.

The SDK is written in TypeScript and exports all of its types. Builders never sign or send: every make*Tx returns unsigned transactions and every make*Ix returns instructions, so the SDK fits any wallet or key-management setup. It works on mainnet (production) and the staging deployments; there is no devnet deployment.

Running the examples

The SDK repository ships runnable examples in examples/:

  • Core01-deposit, 02-borrow, 03-withdraw, 04-repay
  • Pricing & health05-oracle-prices, 06a-account-health-simulated, 06b-account-health-calculated
  • Position swaps10-swap-collateral, 11-swap-debt
  • Native stake12-mint-staked-lst, 13-redeem-staked-lst, 14-merge-stake-accounts
  • Exponent PT rollover15-roll-pt, 17-roll-pt-redeem-proof
  • Leverage loops16a-loop, 16b-loop-bridged, 16c-loop-pinned-route
  • Discovery18-mint-holders
  • Swapsswap-engine (multi-provider quoting used by loops and swaps)
git clone https://github.com/0dotxyz/p0-ts-sdk.git
cd p0-ts-sdk/examples
cp .env.example .env   # set RPC URL, account address, optional keypair
npx tsx 01-deposit.ts

Each example runs in simulation mode by default, so you can explore without spending fees or risking funds.

API reference and help

  • TypeDoc — clone the repository and run pnpm docs (output in docs/). Every exported function and type also carries JSDoc in src/.
  • GitHub Issuesreport bugs or request features.
  • Discord — join the developer community.
  • AI agents — the docs are available through the MCP server and as plain markdown (/llms.txt).

On this page