marginfi

Build Solana lending, borrowing, flash loan, and leveraged position integrations with the Marginfi SDK.

Updated Jul 10, 2026
One-click install
npx skills add https://github.com/Kaleb-Rupe/aurora --skill marginfi-kaleb-rupe
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: marginfi
Source: https://github.com/Kaleb-Rupe/aurora/tree/main/system/aurora-bridge/.claude/skills/marginfi
Command: npx skills add https://github.com/Kaleb-Rupe/aurora --skill marginfi-kaleb-rupe

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Integrating with Marginfi's decentralized lending protocol on Solana requires navigating account creation, bank discovery, health calculations, and complex operations like flash loans and looping, which is error-prone without structured guidance. ## Core Features & Use Cases - Lending & Borrowing Operations: Deposit collateral, borrow assets, repay debt, and withdraw positions using the @mrgnlabs/marginfi-client-v2 SDK. - Advanced DeFi Operations: Execute flash loans, leveraged looping positions, and repay-with-collateral swaps in single transactions. - Health & Risk Monitoring: Compute account health components, free collateral, interest rates, and utilization to avoid liquidation. - Use Case: Build a bot that deposits SOL as collateral, borrows USDC against it at 50% of capacity, and continuously monitors maintenance health to prevent liquidation. ## Quick Start Ask the AI to initialize a Marginfi client on Solana mainnet and deposit 1 SOL into a Marginfi account using the marginfi-client-v2 SDK.

Frequently Asked Questions about marginfi

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I deposit and borrow on Marginfi with TypeScript?

Initialize MarginfiClient with getConfig("production"), a Connection, and a NodeWallet, then call account.deposit(amount, bank.address) and account.borrow(amount, bank.address). Banks are looked up by token symbol via client.getBankByTokenSymbol("SOL").

How do flash loans work on Marginfi?

Marginfi flash loans let you borrow without collateral as long as repayment happens in the same transaction. Call account.flashLoan({ ixs }) with your custom arbitrage or liquidation instructions, and the protocol enforces atomic repayment.

How do I check Marginfi account health before borrowing?

Call account.computeHealthComponents(MarginRequirementType.Maintenance) to get weighted assets and liabilities, and account.computeFreeCollateral() for borrowing capacity. Borrow only when net health and free collateral are positive.

Why does my Marginfi repay amount differ from what I calculated?

Interest accrues between your calculation and transaction submission, changing the owed amount. Pass repayAll=true with account.repay(0, bankAddress, true) to automatically cover accrued interest and close the position.

What environments does the Marginfi SDK support?

The SDK's getConfig function supports production, alpha, staging, and dev environments, each with distinct program IDs and group addresses. Production uses program MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA on Solana mainnet.