marginfi

Interact with the Marginfi lending protocol on Solana using its TypeScript SDK.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/0xinit/cryptoskills --skill marginfi-0xinit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: marginfi
Source: https://github.com/0xinit/cryptoskills/tree/main/skills/marginfi
Command: npx skills add https://github.com/0xinit/cryptoskills --skill marginfi-0xinit

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @mrgnlabs/marginfi-client-v2, @mrgnlabs/mrgn-common, @solana/web3.js, @coral-xyz/anchor, decimal.js, bn.js, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide and SDK for interacting with Marginfi, a decentralized lending protocol on Solana, enabling developers to build sophisticated DeFi applications.

Core Features & Use Cases

  • Lending & Borrowing: Integrate core deposit, borrow, and repayment functionalities.
  • Leveraged Positions: Implement advanced strategies like looping and leveraged trading.
  • Flash Loans: Utilize uncollateralized loans for arbitrage, liquidations, and other strategies.
  • Use Case: A decentralized exchange could integrate Marginfi to offer leveraged trading by allowing users to borrow assets against their collateral directly within the DEX interface.

Quick Start

Use the marginfi skill to initialize the client and create a new Marginfi account.

Frequently Asked Questions about marginfi

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

FAQPage Schema
How do I integrate Marginfi lending and borrowing into my Solana DeFi app?

You can integrate Marginfi lending and borrowing by using its TypeScript SDK to initialize the client, create a Marginfi account, and facilitate core deposit, borrow, and repayment functionalities on Solana. This enables programmatic interaction with the protocol.

Can I execute flash loans on Solana using the Marginfi protocol?

Yes, you can execute flash loans on Solana using the Marginfi protocol. The SDK facilitates uncollateralized loans for arbitrage, liquidations, and other strategies, allowing you to borrow and repay assets within a single transaction.

What dependencies are required to build with the Marginfi TypeScript SDK?

Required dependencies include @mrgnlabs/marginfi-client-v2, @solana/web3.js, @coral-xyz/anchor, bn.js, and decimal.js. You also need Solana blockchain infrastructure and wallet management for transaction signing to use the Marginfi SDK.

How do I implement leveraged positions and looping strategies on Marginfi?

You implement leveraged positions and looping strategies on Marginfi using the TypeScript SDK to manage advanced trading configurations. The protocol supports these advanced DeFi operations by allowing users to borrow assets against their supplied collateral.

Does Marginfi work with @coral-xyz/anchor for Solana smart contract development?

Yes, Marginfi works with @coral-xyz/anchor for Solana smart contract development. Anchor is a required dependency for the SDK, enabling the programmatic interaction and transaction signing needed for the Marginfi decentralized lending protocol.