marginfi — Program ID & Overview
MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA marginfi is a lending and borrowing protocol on Solana. Users deposit assets to earn yield and borrow against their collateral. marginfi uses a risk-tiered system to manage protocol solvency.
Program ID
MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA
Architecture
| Account | Description |
|---|---|
| MarginfiGroup | Global configuration for a lending group |
| Bank | Individual asset reserve (SOL bank, USDC bank, etc.) |
| MarginfiAccount | User’s account holding deposits and borrows |
Risk tiers
marginfi classifies assets into risk tiers that determine how they interact:
| Tier | Description |
|---|---|
| Collateral | Can be used as collateral for borrows |
| Isolated | Can only be borrowed in isolation (no mixing with other borrows) |
| Volatile | Higher-risk assets with lower LTV |
Key instructions
| Instruction | Description |
|---|---|
MarginfiAccountInitialize | Creates a user account |
LendingAccountDeposit | Deposits tokens into a bank |
LendingAccountBorrow | Borrows tokens against collateral |
LendingAccountRepay | Repays borrowed tokens |
LendingAccountWithdraw | Withdraws deposited tokens |
LendingAccountLiquidate | Liquidates an unhealthy account |
Interest rate model
marginfi uses a piecewise linear interest rate curve:
Rate
↑
| ╱
| ╱
| ╱ ← kink point
| ────╱
| ────
|────
└──────────────────→ Utilization %
Below the optimal utilization (kink), rates increase slowly. Above it, rates increase sharply to incentivize repayment and new deposits.
Using the SDK
import { MarginfiClient, getConfig } from "@mrgnlabs/marginfi-client-v2";
const config = getConfig("production");
const client = await MarginfiClient.fetch(config, wallet, connection);
const account = await client.createMarginfiAccount();
const banks = client.banks;
// Deposit SOL
const solBank = [...banks.values()].find(b => b.label === "SOL");
await account.deposit(1_000_000_000, solBank.address); // 1 SOL
FAQ
What happens during a liquidation? When an account’s health factor drops below 1 (borrows exceed collateral × LTV), liquidators can repay a portion of the debt and receive the equivalent collateral plus a liquidation bonus. Liquidations are partial to minimize market impact.
How are interest rates determined? Rates are set by the utilization curve parameters: base rate, optimal utilization, and the rate at optimal and maximum utilization. Each bank (asset) has its own rate parameters.
Can I flash borrow on marginfi? marginfi supports flash loans where you borrow and repay within the same transaction. This is used for liquidations, leveraged strategies, and arbitrage.
Updated: