Marginfi connects lending deposits with collateral-backed borrowing on Solana
Marginfi's Solana lending program connects deposited assets with collateral-backed loans and powers Project 0. Supplying supported assets can earn variable interest; eligible deposits also contribute collateral after risk weights apply. The former Marginfi frontend was retired in mid-2026. Current application use runs through Project 0, while the underlying program retains lending, withdrawals, borrowing and repayment.
A supply balance, borrowing capacity and liquidation health describe different aspects of the same account. Their relationship changes with asset prices, accrued debt and bank settings. Native lending pools and integrated collateral also earn interest through different mechanisms.
Collateral Weights and Borrowing Capacity
A deposited asset contributes borrowing capacity only after the program applies its asset weight to the value it accepts for risk calculations. Borrowed assets carry liability weights, which adjust how much debt counts against collateral. These settings explain why an account's raw token value doesn't equal its available borrowing power.
Initial Weights for New Loans
Initial weights govern new borrowing by discounting collateral and adjusting debt through the program's respective asset and liability weights. A larger liability weight consumes more borrowing capacity for the same debt value.
For a collateral and debt pair, effective loan-to-value equals the applicable asset weight divided by the liability weight. Loan-to-value, or LTV, therefore involves both sides of the position. An asset weight alone doesn't describe the complete borrowing relationship.
Maintenance Weights for Liquidation Health
Maintenance weights govern liquidation eligibility. They generally allow more collateral value and less weighted debt than initial weights, creating a buffer between opening a loan and liquidation exposure. An account can lack capacity for another borrow while retaining positive maintenance health. Price changes and accumulating debt can consume that buffer.
Pair-Specific E-Mode Treatment
Efficiency Mode, or e-mode, applies preferential collateral weights when positions match configured asset pairings. Project 0 applies eligible treatment automatically. Each collateral asset uses the least favorable applicable weight across the account's liabilities, so an additional debt asset can reduce existing borrowing power. Correlation alone doesn't establish eligibility; the borrowing bank's configuration determines the supported pairing.
Marginfi, Mrgnlend and Project 0
mrgnlend was Marginfi's lending application in September 2024. Its supply pools funded overcollateralized borrowing on Solana. Project 0 builds on the same mrgnLendv2 program and adds cross-venue collateral. The former frontend's retirement left the underlying program operating through Project 0's native lending markets, integration banks and margin accounts. The earlier application's Lend/Supply labels and sign-in options belong to its historical interface.
Banks, Accounts and Oracle Prices
A bank defines an asset's lending settings, including interest curves, risk weights, caps, fees and oracle configuration. Multiple banks can represent the same underlying token. A margin account holds asset and liability balances across banks within its group. The selected bank therefore matters alongside the token name: it determines the pool, risk treatment and applicable integration.
Oracles supply the prices the program uses for risk calculations. Confidence intervals affect valuation: collateral uses a conservative lower price bound, while debt uses an upper bound. A stale price from a required oracle can prevent a risk-sensitive action. Refresh requirements vary with the oracle and integration involved; a wallet balance alone doesn't establish executable borrowing capacity.
Pool Utilization, APR and APY
A native pool's borrowing demand changes its interest rate through the bank's configured utilization curve. Utilization measures borrowed funds relative to deposits. Borrow rates generally rise as utilization increases, particularly beyond a configured bend in the curve. The curve belongs to the bank; neither its bend nor its current rate is a universal protocol constant.
Annual percentage rate, or APR, describes interest without compounding; annual percentage yield, or APY, includes interest earned on earlier interest. Native banks update accrued interest around balance-changing activity, so compounding frequency varies with usage. A displayed APY expresses a calculation assumption, not a fixed return over the next year. Borrowers also fund applicable insurance and administrator charges, so their interest cost differs from the yield suppliers receive.
Interest Accrual and Full-Balance Closure
A native lending balance represents shares whose token conversion value grows as borrower interest accrues. The program handles this accrual without requiring a separate reward claim. Debt also grows, which can change the amount needed for repayment between preview and execution. The full-withdrawal and full-repayment flags settle the selected balance after accrual. They don't remove liquidity limits, health requirements or the need to supply enough repayment tokens, and closing one balance doesn't necessarily close the margin account.
Deposits, Debt and Position Changes
Project 0's SDK separates ordinary balance changes from operations that restructure collateral or debt. The transaction shapes below apply to those builders, rather than every possible frontend or custom integration. Oracle preparation can add transactions even when the principal action fits into one.
Marginfi - Deposits Fund Borrowing Against Collateral
- Deposits, Debt and Position Changes
- Native Pools and Cross-Venue Collateral
- Loops, Flash Loans and Specialized Collateral
- Protocol Fees and Transaction Costs
| Operation | Position Change | SDK Execution Shape |
|---|---|---|
| Native Deposit | Adds supplied assets | One transaction from the deposit builder |
| Native Withdrawal | Removes supplied assets | Action transaction, with oracle preparation when needed |
| Native Borrow | Adds a liability | Action transaction, with oracle preparation when needed |
| Native Repayment | Reduces a liability | One transaction from the repayment builder |
| Collateral Swap | Replaces supplied collateral | Direct flash-loan action or bridged atomic bundle |
| Debt Swap | Replaces the debt asset | Direct flash-loan action or bridged atomic bundle |
| Repayment With Collateral | Uses supplied assets to reduce debt | Direct flash-loan action; no bridged builder variant |
| Preparation transactions can accompany flash-loan actions; the builder result determines ordering and any atomic-bundle requirement. | ||
A withdrawal reduces a supplied asset balance, while repayment reduces debt. Their effects on account health differ even when both decrease a displayed balance. These collateral-swap builders require a destination supporting standard deposits; debt-swap builders require a destination supporting standard borrowing. Successful transaction construction doesn't override those requirements or establish on-chain completion.
Native Pools and Cross-Venue Collateral
A native bank and an integration bank can expose the same token while representing different sources of yield and different underlying positions. Project 0 accounts for those differences through separate banks and conversion data.
Native Lending Liquidity
Native deposits provide liquidity for the program's borrowers. Available pool liquidity limits withdrawals and borrowing alongside account health and configured caps. At full utilization, all deposited liquidity is on loan, so lenders can't withdraw it immediately. A positive supply balance doesn't establish that the pool currently holds enough unborrowed tokens. If borrower bad debt exceeds the bank's insurance reserves, bankruptcy settlement can reduce its asset share value and pass losses to suppliers.
Venue-Backed Positions
Project 0's deposit-only integration banks route assets into another venue and track the resulting positions as collateral. Their liquidity isn't available for borrowing on Project 0. Kamino-backed deposits earn interest through the Kamino reserve's token conversion rate. This yield comes from that venue's lending activity. The integration adds another protocol's accounting and refresh requirements to the position's operation.
The SDK includes Kamino, Drift and Jupiter Lend adapters. Actual access requires an applicable operational bank; an adapter's existence doesn't establish availability. Existing Drift banks are non-operational.
Loops, Flash Loans and Specialized Collateral
A flash loan lets the program combine intermediate balance changes within one transaction before evaluating the final position's initial health. This mechanism supports leveraged loops and position restructuring. If the account fails that final health check, the whole transaction reverts; swap execution constraints still apply.
Leveraged Loops
A loop combines borrowing, conversion and additional collateral to increase exposure. The SDK can build the combined action through a flash loan, rather than requiring repeated manual borrowing cycles. Its direct and bridged builders handle different routing structures. Borrow interest, swap costs and changing collateral prices affect the resulting position.
Collateral-Based Debt Management
Repayment with collateral withdraws supplied assets to reduce debt, swapping them into the debt token when the mints differ. A debt swap changes the liability's denomination while leaving a borrowing position open. Swap output, supported banks and final health constrain their execution.
Native Stake and Exponent Positions
Native-stake helpers mint a single-validator liquid staking token from a stake account delegated to the matching bank's validator. The LST must then be deposited into its matching bank to provide collateral. Accounts with STAKED positions can borrow only SOL and can't hold DEFAULT assets. A separate Exponent builder rolls matured principal-token collateral into a successor maturity. That rollover needs a matured position and a suitable successor market; ordinary token deposits don't provide those prerequisites.
Protocol Fees and Transaction Costs
Ordinary deposits and withdrawals carry no program deposit or withdrawal fee under Project 0's documented lending model. That fee category doesn't include Solana transaction charges. Borrow interest includes lender compensation and applicable insurance or administrator charges. A configured origination fee can add an upfront charge to a borrow.
Swaps introduce conversion costs, slippage and any applicable frontend fee. A repayment using collateral can therefore cost more than repayment using tokens already available for settlement. A quoted expected output also differs from a minimum-output constraint. The latter limits acceptable execution; it doesn't represent tokens already received or debt already repaid.
Bank Restrictions and Liquidation Exposure
Bank settings can restrict otherwise supported actions. Reduce-only mode permits withdrawals and repayments while disabling new deposits and borrowing; existing positions continue accruing interest. A paused bank blocks user financial operations. Oracle circuit breakers can also restrict risk-increasing actions. Those states affect availability independently of a wallet's connection or the account's nominal balance.
The program measures account health as weighted asset value minus weighted liability value. Negative maintenance health exposes an account to liquidation. Classic liquidation transfers debt to a liquidator in exchange for collateral; receivership lets a liquidator withdraw collateral and repay debt within one transaction. Repayment or additional eligible collateral can improve health when the bank permits those actions. Liquidation charges depend on the mechanism and applicable bank or program-level fee settings.
SDK Compatibility and Transaction Authorization
The replacement TypeScript SDK,
@0dotxyz/p0-ts-sdk
, builds transactions for the continuing Marginfi program. Its builders don't sign or send them. Reading an account or preparing a transaction therefore doesn't authorize a movement of funds. Signing, submission and confirmation remain distinct, and an oracle-update transaction's confirmation doesn't establish that the borrowing action completed.
The legacy
@mrgnlabs/marginfi-client-v2
package has been deprecated since March 2026. Program upgrades changed flash-loan instruction layouts and added oracle configurations older clients can't decode. Integrations must also respect the returned transaction order and any
mustBeAtomicBundle
requirement. Sending an atomic set as independent transactions can leave only part of its intended restructuring executed.
For program 0.1.11 oracle configurations, the documented SDK compatibility floor is version 2.8.0.
Common questions about Marginfi
Why Does a Supplied Asset Add No Borrowing Capacity?
An asset in the isolated risk tier has zero collateral weight but can still earn lending interest. Its supplied balance therefore doesn't add borrowing capacity. Interest eligibility and collateral eligibility describe separate properties, so an interest-bearing deposit can remain unusable as security for a loan.
Is a Devnet Deployment Available for the Replacement SDK?
The documented Project 0 SDK environments include Solana mainnet and staging deployments, without a devnet deployment. Staging serves a different purpose from production, even when its bank settings resemble mainnet. An environment's name doesn't establish that its accounts, assets or positions are interchangeable with those in the production deployment.
How Does Repay All Handle Native SOL Wrapping?
The SDK uses the supplied repayment amount to decide how much native SOL to wrap. The repay-all flag settles the full liability, including interest accrued before execution, but it doesn't fund the token transfer. The wallet still needs enough tokens, and the amount passed to the builder must cover the wrapping needed for settlement.
Can a Higher Priority Fee Resolve a Rejected Borrow?
A higher priority fee doesn't override the program's borrowing rules. Insufficient initial health, a bank cap or a rate limit can still cause rejection. Priority fees address transaction processing probability during congestion; they don't guarantee inclusion or repair a borrow whose requested amount exceeds an applicable constraint.
Will a Deposit and a Borrow Coexist in the Same Bank?
The program doesn't allow an account to hold both an asset balance and a liability balance in the same bank. Accounts can hold positions across different banks within their group. Multiple banks can also represent the same underlying token, so the bank identity matters when interpreting a portfolio's supplied and borrowed balances.
Are SDK Deposit Amounts Expressed in Raw Token Units?
The current account wrapper accepts deposit amounts in token display units, rather than raw native units. Integration-bank methods also use underlying-token display amounts and handle the venue's share-token conversion. Lower-level program instructions can use different amount types, so passing the same numerical value between layers can change its meaning.
Updated -