/SKILL.md
Use for Project 0 (P0) defi native prime broker protocol on Solana, including yield discovery, deposits, borrows, repayments, withdrawals, and account health checks.
npx skillsauth add 0dotxyz/p0-agents project0Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Project 0 is a permissionless DeFi prime broker on Solana. It exposes unified margin accounts across P0 native, Kamino, and Drift venues.
This skill has two jobs:
ai.0.xyz APIs for read-only discovery,
market data, strategy inspection, and wallet matching.mfi for installation, profile configuration,
account selection, and protocol execution.Operating model:
ai.0.xyz APIs for discovery, pricing, strategy data, and wallet matchingmfi for installation, configuration, and all protocol interactionsDo not use the TypeScript SDK for normal execution.
References:
mfi README: https://github.com/0dotxyz/marginfi-v2/tree/main/clients/rust/marginfi-climfi Installation Guide: https://github.com/0dotxyz/marginfi-v2/tree/main/clients/rust/marginfi-cli#installhttps://docs.0.xyz/protocol-overview/risk-enginehttps://docs.0.xyz/guides/managing-your-accountmfi -h, mfi <command> -h,
mfi <command> <subcommand> -hWhen a user asks to earn yield, deposit, borrow, repay, withdraw, monitor health, or run a strategy on P0, follow this sequence.
For read-only planning, resolve the wallet address from the active CLI context or user-provided context. If you cannot determine the wallet address safely, ask the user.
Fetch holdings from:
GET https://ai.0.xyz/api/wallet/{address}Match each token's address field to bank mint values.
Fetch:
GET https://ai.0.xyz/api/banksGET https://ai.0.xyz/api/strategiesUse the APIs to build the plan.
deposit_apy descending.venue === "P0" and symbols in
[USDC, USDT, USDG, USDS, HYUSD], then sort by borrow_apy ascending.address to bank mint.supplyBank as the deposit bank and borrowBank as the
borrow bank.Rules:
venue === "P0".Always present a concrete plan with specific numbers before any state-changing action.
mfiBefore any state-changing action, verify:
mfi is installed and available on PATHmfi profile is the intended profileIf mfi is not on PATH, prefer installing a published release binary yourself
with the platform-specific curl download flow from the marginfi CLI README:
https://github.com/0dotxyz/marginfi-v2/tree/main/clients/rust/marginfi-cli#install.
Use a user-local install path when possible, verify with mfi --version or
mfi -h, then continue. Only ask the user if installation needs approval,
fails, or they prefer managing it themselves.
Do not default to gh release download. Prefer the README's direct curl
install flow because it does not require GitHub auth and is the intended
end-user install path.
Use the README install section to determine the latest published version, then
use the matching release-binary curl command for the current platform. Do not
hardcode an old version if the README shows a newer one.
Release install pattern:
MFI_VERSION=<latest-published-version>
Linux x86_64:
curl --proto '=https' --tlsv1.2 -sSfL -o mfi.tar.gz https://github.com/0dotxyz/marginfi-v2/releases/download/mfi-v${MFI_VERSION}/mfi-${MFI_VERSION}-x86_64-unknown-linux-gnu.tar.gz
tar -xzf mfi.tar.gz
mkdir -p ~/.local/bin
mv ./mfi ~/.local/bin/
~/.local/bin/mfi --version
macOS Apple Silicon:
curl --proto '=https' --tlsv1.2 -sSfL -o mfi.tar.gz https://github.com/0dotxyz/marginfi-v2/releases/download/mfi-v${MFI_VERSION}/mfi-${MFI_VERSION}-aarch64-apple-darwin.tar.gz
tar -xzf mfi.tar.gz
xattr -c ./mfi
mkdir -p ~/.local/bin
mv ./mfi ~/.local/bin/
~/.local/bin/mfi --version
macOS Intel:
curl --proto '=https' --tlsv1.2 -sSfL -o mfi.tar.gz https://github.com/0dotxyz/marginfi-v2/releases/download/mfi-v${MFI_VERSION}/mfi-${MFI_VERSION}-x86_64-apple-darwin.tar.gz
tar -xzf mfi.tar.gz
xattr -c ./mfi
mkdir -p ~/.local/bin
mv ./mfi ~/.local/bin/
~/.local/bin/mfi --version
On Windows, follow the PowerShell release install in the mfi README.
Install hierarchy:
mfi from PATH if already installed.curl command.Unix install pattern:
mkdir -p ~/.local/bin
mv ./mfi ~/.local/bin/
Make sure ~/.local/bin is on PATH.
Fallback source build:
marginfi-v2 repo path only if neededcargo build -p marginfi-v2-cli<repo>/target/debug/mfiUse:
mfi -h
mfi profile -h
mfi account -h
mfi bank -h
mfi profile show
mfi account list
Account rules:
mfi account use <ACCOUNT_PUBKEY> before
multi-step workflows.The agent should treat the active mfi profile as the execution context.
Inspect first:
mfi profile show
mfi profile list
If no suitable profile exists, create one:
mfi profile create --name mainnet --cluster mainnet --keypair-path <KEYPAIR_PATH> --rpc-url <RPC_URL>
mfi profile set mainnet
To create the profile, the agent needs these real values:
--rpc-url: ask the user for their Solana RPC URL if it is not already in an
existing profile--keypair-path: ask the user for the local path to their Solana keypair file
if it is not already in an existing profile--name: use mainnet by default unless the user prefers another nameDo not invent RPC URLs or keypair paths.
Execute only after the user approves the plan.
mfihttps://solscan.io/tx/<signature>Use the APIs for planning. No wallet, SDK, or RPC is required.
GET https://ai.0.xyz/api/banks
Fields used most often:
| Field | Meaning |
| --- | --- |
| bank_address | On-chain bank address; pass this directly to mfi |
| symbol | Token symbol |
| mint | Token mint address |
| mint_decimals | Token decimals |
| venue | P0, Kamino, Drift, or JupLend |
| asset_weight_init | Initial asset weight |
| asset_weight_maint | Maintenance asset weight |
| liability_weight_init | Initial liability weight |
| liability_weight_maint | Maintenance liability weight |
| deposit_apy | Effective deposit APY percentage |
| borrow_apy | Borrow APY percentage |
| usd_price | Oracle price in USD |
Notes:
deposit_apy is already precomputed.bank_address directly in CLI commands.usd_price to calculate account health.P0 venues.GET https://ai.0.xyz/api/strategies
Top-level shape:
asOf: ISO timestamp for the snapshot.sortBy: current upstream ranking key.nativeMaxAgeSec: freshness limit for native yield inputs.strategies: grouped non-directional strategies.directional: grouped directional strategies.strategies is an object keyed by category. Common categories include:
stablecoinssolLstEach category contains an array of strategy objects. Fields used most often:
| Field | Meaning |
| --- | --- |
| supplyMint | Mint deposited into the strategy |
| supplySymbol | Deposited asset symbol |
| borrowMint | Mint borrowed for the strategy |
| borrowSymbol | Borrowed asset symbol |
| supplyBank | Deposit bank address; pass this to mfi for deposits |
| borrowBank | Borrow bank address; pass this to mfi for borrows |
| supplyVenue | Lending venue for the supplied asset |
| borrowVenue | Borrow venue for the borrowed asset |
| lendApy | Base supply APY percentage before leverage |
| borrowApy | Base borrow APY percentage before leverage |
| nativeYield.supply.apy | Native asset yield on the supply side, if any |
| emissions.supply.apy | Emissions APY on the supply side, if any |
| netApyBase | Unlevered net APY percentage |
| maxLeverage | Maximum leverage multiplier |
| netApyAtMaxLeverage | Projected APY percentage at max leverage |
| availableStrategySizeUsd | Estimated remaining capacity in USD |
| bindingConstraint | What currently limits strategy size |
| emodeApplied | Whether e-mode assumptions are applied |
directional is an object keyed by asset, for example sol, btc, eth, or
jlp. Each asset may contain long and/or short strategy objects using the
same field shape as above.
Practical usage:
supplyBank as the deposit bank and borrowBank
as the borrow bank.netApyAtMaxLeverage when comparing headline leveraged opportunities.netApyBase when comparing the unlevered spread.availableStrategySizeUsd before recommending size.supplyVenue and borrowVenue; only P0 banks are valid for borrows
through mfi.GET https://ai.0.xyz/api/wallet/{address}
Returns:
wallettotal_usd_valuetokens[]Per token:
| Field | Meaning |
| --- | --- |
| address | Mint address; matches bank mint |
| symbol | Token symbol |
| decimals | Token decimals |
| balance | Human-readable amount |
| usd_price | Price per token |
| usd_value | Total USD value |
mfi OverviewUse mfi for installation verification, profile configuration, account
selection, and all P0 protocol actions.
Use built-in help as the source of truth for exact flags and newer subcommands:
mfi -h
mfi profile -h
mfi account -h
mfi bank -h
Install and profile setup are described in the workflow above. Core commands:
mfi --version
mfi profile show
mfi profile list
mfi account list
Use:
mfi account -h
mfi account list
mfi account get <ACCOUNT_PUBKEY>
mfi account use <ACCOUNT_PUBKEY>
mfi account create
Guidance:
Amounts are UI amounts.
For exact flags and newer subcommands, use:
mfi account deposit -h
mfi account withdraw -h
mfi account borrow -h
mfi account repay -h
mfi account pulse-health -h
Deposit:
mfi account deposit <BANK_PUBKEY> <UI_AMOUNT>
Withdraw specific amount:
mfi account withdraw <BANK_PUBKEY> <UI_AMOUNT>
Withdraw all:
mfi account withdraw <BANK_PUBKEY> 0 --all
Borrow:
mfi account borrow <BANK_PUBKEY> <UI_AMOUNT>
Repay specific amount:
mfi account repay <BANK_PUBKEY> <UI_AMOUNT>
Repay all:
mfi account repay <BANK_PUBKEY> 0 --all
Health check:
mfi account get
mfi account pulse-health
Preferred health workflow:
mfi account pulse-health -y
mfi account get
mfi account get --json
Health reporting rules:
mfi account pulse-health as the authoritative on-chain health refresh.mfi account get or mfi account get --json to report exact current
deposits and borrows.Health = Sum(Asset Value * Asset Weight) - Sum(Liability Value * Liability Weight).mfi account get --json for exact positions and sidesGET https://ai.0.xyz/api/banks for usd_price, asset_weight_maint, and
liability_weight_maintbank value from mfi account get --json to the banks
API bank_address.amount * usd_price * asset_weight_maint.amount * usd_price * liability_weight_maint.mfi mutating commands simulate first, then sign and send on success.mfi may prompt for confirmation on state-changing commands.-y / --skip-confirmation after the user has already approved the
exact action in chat.0.01 SOL in the wallet for fees.mfi bank inputs are bank pubkeys, not token symbols.bank_address values directly with mfi.mfi profile can silently change which account or group is used.mfi account use changes defaults for later commands.mfi is not on PATH, prefer self-installing the release binary first;
only fall back to an explicit binary path or local checkout if needed.Use the protocol health score semantics from the Risk Engine docs:
| Health | Status |
| --- | --- |
| > 0 | Healthy |
| = 0 | At the boundary |
| < 0 | Liquidatable |
testing
Create, edit, improve, or audit AgentSkills. Use when creating a new skill from scratch or when asked to improve, review, audit, tidy up, or clean up an existing skill or SKILL.md file. Also use when editing or restructuring a skill directory (moving files to references/ or scripts/, removing stale content, validating against the AgentSkills spec). Triggers on phrases like "create a skill", "author a skill", "tidy up a skill", "improve this skill", "review the skill", "clean up the skill", "audit the skill".
testing
Host security hardening and risk-tolerance configuration for OpenClaw deployments. Use when a user asks for security audits, firewall/SSH/update hardening, risk posture, exposure review, OpenClaw cron scheduling for periodic checks, or version status checks on a machine running OpenClaw (laptop, workstation, Pi, VPS).
testing
Create, edit, improve, or audit AgentSkills. Use when creating a new skill from scratch or when asked to improve, review, audit, tidy up, or clean up an existing skill or SKILL.md file. Also use when editing or restructuring a skill directory (moving files to references/ or scripts/, removing stale content, validating against the AgentSkills spec). Triggers on phrases like "create a skill", "author a skill", "tidy up a skill", "improve this skill", "review the skill", "clean up the skill", "audit the skill".
testing
Host security hardening and risk-tolerance configuration for OpenClaw deployments. Use when a user asks for security audits, firewall/SSH/update hardening, risk posture, exposure review, OpenClaw cron scheduling for periodic checks, or version status checks on a machine running OpenClaw (laptop, workstation, Pi, VPS).