prepare_marginfi_init
Initialize a deterministic MarginfiAccount PDA under your wallet on MarginFi mainnet. This one-time setup enables subsequent supply, withdraw, borrow, and repay operations.
Instructions
One-time setup: build a tx that creates a deterministic MarginfiAccount PDA under the user's wallet on MarginFi mainnet. Uses marginfi_account_initialize_pda so only the wallet (authority + fee_payer) signs — no ephemeral keypair required, Ledger-compatible. PDA seeds are ["marginfi_account", group, wallet, accountIndex, 0], with accountIndex defaulting to 0. After broadcast, prepare_marginfi_supply / withdraw / borrow / repay for this wallet will use this MarginfiAccount automatically. COST: ~0.01698 SOL rent-exempt minimum (for the 2312-byte PDA) + ~0.000005 SOL tx fee. The rent is PAID FROM THE USER WALLET DIRECTLY (not via an ephemeral keypair) and is reclaimable when the MarginfiAccount is closed. Surface this cost to the user before they approve on Ledger — the blind-sign screen only shows a Message Hash, so the user has no on-device check of the balance delta. DURABLE NONCE REQUIRED: this tx carries ix[0] = nonceAdvance (same pattern as every other Solana send in this server), so the wallet must have run prepare_solana_nonce_init first; otherwise this tool errors with a clear pointer. BLIND-SIGN on Ledger (MarginFi's program ID is not in the Solana app's clear-sign registry) — the user matches the Message Hash on-device after preview_solana_send. Refuses if a MarginfiAccount already exists at the derived PDA.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wallet | Yes | Solana wallet that will own the MarginfiAccount PDA. The account is deterministic — seeds (marginfi_account, group, authority, accountIndex, third_party_id=0) produce the same PDA every time. Only the user (authority + fee_payer) signs; no rent-exempt seed is moved (this is a PDA, not a fresh account). | |
| accountIndex | No | Account slot (default 0). Pass a different index to init a second MarginfiAccount under the same wallet. |