Guides

CLI

How to install, configure, and use the marginfi CLI for advanced Project 0 and operator workflows.

The mfi CLI is the advanced interface for interacting directly with the marginfi protocol that powers Project 0. It is best suited for operators, integrators, admins, and power users who want fine-grained control from the terminal. Most users should use app.0.xyz.

What the CLI Is Best For

  • Inspecting groups, banks, and accounts directly from the terminal
  • Managing marginfi accounts without using the web app
  • Running deposit, withdraw, borrow, repay, and health-check workflows
  • Operating integration flows for venues like Kamino, Drift, and JupLend
  • Running config-driven admin and infrastructure workflows

The CLI is broad, so the built-in help is the live source of truth for flags and examples:

mfi -h
mfi <command> -h
mfi <command> <subcommand> -h

Main command groups:

mfi group
mfi bank
mfi profile
mfi account
mfi kamino
mfi drift
mfi juplend
mfi util

Install

Build from source:

cargo build -p marginfi-v2-cli

Install locally:

cargo install --path clients/rust/marginfi-cli --locked --force

If you are using a tagged release build instead of installing from source, download the published mfi archive from the marginfi releases page.

Create a Profile

Profiles are central to how the CLI works. They store your cluster, keypair path, RPC URL, and optional default group and account. Many commands use the active profile defaults when you omit those inputs.

Typical setup:

mfi profile create \
  --name mainnet \
  --cluster mainnet \
  --keypair-path ~/.config/solana/id.json \
  --rpc-url https://api.mainnet-beta.solana.com

mfi profile set mainnet
mfi profile show

You can also use a different saved profile for a single command:

mfi --profile staging bank get <BANK_PUBKEY>

Profile defaults matter. For example, mfi group get can use the active profile group, and mfi account get can use the active profile account.

Inspect the Protocol

Before sending any transaction, start by discovering the current state of your profile, group, banks, and accounts.

mfi profile show
mfi group get
mfi bank get-all
mfi account list

These commands are the fastest way to confirm which group you are targeting, which banks are available, and which accounts exist for the current authority.

Select or Create an Account

Most user-facing workflows happen through the account command group.

Create an account:

mfi account create

List your accounts and inspect one in detail:

mfi account list
mfi account get <ACCOUNT_PUBKEY>

Set the default account for the current profile:

mfi account use <ACCOUNT_PUBKEY>
mfi account get

Once you set a default account, many account commands can use it automatically.

Core Account Actions

The CLI expects bank arguments as public keys, not token symbols.

Deposit

mfi account deposit <BANK_PUBKEY> 10

If you want the CLI to deposit only the remaining amount allowed before hitting the bank limit, use:

mfi account deposit <BANK_PUBKEY> 10 --up-to-limit

Withdraw

Withdraw a specific amount:

mfi account withdraw <BANK_PUBKEY> 5

Withdraw the entire balance:

mfi account withdraw <BANK_PUBKEY> 0 --all

Borrow

mfi account borrow <BANK_PUBKEY> 3

Repay

Repay a specific amount:

mfi account repay <BANK_PUBKEY> 3

Repay the full liability:

mfi account repay <BANK_PUBKEY> 0 --all

Check Health

Use these commands to inspect your balances and refresh your account health:

mfi account get
mfi account pulse-health

If you are managing active borrows, compare this with Managing Your Account for the protocol-level guidance on health, buffers, and liquidation risk.

Transaction Behavior

By default, the CLI simulates a transaction first, then signs and broadcasts it if simulation succeeds.

  • --no-send-tx simulates and prints an unsigned base58 transaction instead of signing and sending
  • -y or --skip-confirmation skips the interactive safety prompt
  • --compute-unit-price <u64> sets a priority fee in micro-lamports
  • --compute-unit-limit <u32> overrides the compute unit limit
  • -l or --lookup-table <PUBKEY> adds address lookup tables for versioned transactions
  • --json enables machine-oriented output where supported

Most state-changing commands ask you to type the active profile name to continue. This is a safety check, not a simple yes/no confirmation.

--no-send-tx is especially useful for external signing and multisig workflows, but some commands that create fresh accounts or require extra signers are designed for direct send mode.

Config-Driven Workflows

More complex workflows use JSON config files instead of long flag lists. Use --config-example to print a template, then copy it into a real file for your environment.

mfi bank add --config-example
mfi bank add --config ./configs/bank/add/my-bank.json

Other common examples:

mfi bank update <BANK_PUBKEY> --config ./configs/bank/update/config.json.example
mfi group create --config ./configs/group/create/config.json.example
mfi kamino add-bank --config ./configs/kamino/add-bank/config.json.example
mfi drift withdraw --config ./configs/drift/withdraw/config.json.example
mfi juplend add-bank --config ./configs/juplend/add-bank/config.json.example

The config templates live under clients/rust/marginfi-cli/configs/ in the marginfi repository. Several templates are intentionally minimal because the CLI can derive deterministic accounts and integration-specific addresses automatically.

Integration Command Groups

The CLI also supports venue-specific integrations:

  • mfi kamino ... for Kamino integration banks and reserve interactions
  • mfi drift ... for Drift integration banks and spot market interactions
  • mfi juplend ... for JupLend integration banks and positions

At a high level, these command groups cover bank creation, integration account initialization, deposits, withdrawals, and reward workflows.

Some integration commands intentionally derive required accounts from a smaller root input set. Always check mfi <group> <subcommand> -h and the example configs before filling fields manually.

Common Gotchas

  • Bank inputs are raw public keys, not asset symbols
  • The active profile can silently change which group or account a command targets
  • account list depends on the current authority and active group context
  • account use updates the profile default account for future commands
  • --no-send-tx is powerful, but it is not a drop-in replacement for every mutating workflow
  • Built-in help is more reliable than stale command snippets, especially as new subcommands are added

Further Reading

On this page