Project 0 - DeFi Native Prime Broker
通过 Project 0 (P0) 协议在 Solana 上实现无需许可的 DeFi 收益和信贷。 存入资金即可在 Solana 收益最高的场所赚取收益。 以存入的抵押品借入稳定币,而不是出售加密货币。 通过利率套利和循环执行高级收益策略。 所有操作都是在链上且无需许可的——没有账户,没有审批流程。 注意:此技能需要钱包密钥对来签署交易。使用专用的 资金有限的钱包——永远不要暴露你的主私钥。代理将 签字前务必要求确认。只读操作不需要密钥对。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw install totalclaw:borcherd~project-0cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Aborcherd~project-0/file -o project-0.mdGit 仓库获取源码
git clone https://github.com/openclaw/skills/commit/787b3dfe928b62b3773a663c8537acfd30aa9b44## 概述(中文)
通过 Project 0 (P0) 协议在 Solana 上实现无需许可的 DeFi 收益和信贷。
存入资金即可在 Solana 收益最高的场所赚取收益。
以存入的抵押品借入稳定币,而不是出售加密货币。
通过利率套利和循环执行高级收益策略。
所有操作都是在链上且无需许可的——没有账户,没有审批流程。
注意:此技能需要钱包密钥对来签署交易。使用专用的
资金有限的钱包——永远不要暴露你的主私钥。代理将
签字前务必要求确认。只读操作不需要密钥对。
## 原文
# Project 0 Skill
## What is Project 0?
P0 is a permissionless DeFi prime broker on Solana. It provides unified margin
accounts that span multiple lending venues (P0 native, Kamino, Drift), giving
agents access to the best yields and deepest liquidity across the ecosystem.
All operations are on-chain, non-custodial, and require no signup.
**Documentation:**
- Protocol overview: https://docs.0.xyz/
- TypeScript SDK: https://docs.0.xyz/typescript-sdk/overview
### Use Case 1: Yield + Credit
Deposit funds to earn the best yield across DeFi. When the user needs
liquidity (e.g. to make a purchase), borrow stablecoins against deposited
collateral instead of selling crypto. The user keeps earning yield while
accessing cash.
**Flow:** Deposit -> Earn yield -> Borrow stablecoins when needed -> Repay.
**Example prompts:**
- "Deposit my SOL on P0 for the best yield."
- "I need $500 USDC but don't want to sell my SOL."
- "What is the cheapest stablecoin to borrow on P0?"
### Use Case 2: Advanced Yield Strategies
Find the absolute best yields on Solana, which often come from rate arbitrage
and looping strategies. These involve depositing one asset, borrowing another,
and managing the leveraged position. Higher yields, but requires active health
monitoring.
**Flow:** Identify strategy -> Deposit collateral -> Borrow -> Monitor health.
**Example prompts:**
- "What are the highest-yield strategies on P0 right now?"
- "Set up a bbSOL/SOL rate arb on P0."
- "Put my funds to work on P0 for the best yield."
---
## Agent Workflow
When a user asks to earn yield, deposit, borrow, or manage positions on P0,
follow these steps in order. Do NOT skip ahead to writing code.
### Step 1: Check wallet balances
Resolve the wallet address: check `.env` for `WALLET_ADDRESS`, or derive
it from the keypair if `WALLET_KEYPAIR` is set, or ask the user.
Fetch the wallet's token holdings from the wallet API (see Wallet endpoint
below). No credentials needed. Use the `address` field from each token to
match against P0 banks by `mint`.
### Step 2: Fetch P0 data
Fetch banks and strategies from the P0 APIs (see Read-Only APIs below).
### Step 3: Recommend optimal action
Determine which use case fits the user's request:
- If the user wants to **earn yield or access credit**, recommend the best
deposit opportunity and mention borrowing as an option (Use Case 1).
- If the user wants the **highest possible yield** or mentions strategies,
rate arbs, or looping, recommend the best strategy and explain the
deposit + borrow setup required (Use Case 2).
Match wallet holdings to available bank yields. For each token the wallet
holds, find the best deposit APY from the banks data. Compare across all
holdings to find the highest overall yield.
If the wallet holds tokens that have no corresponding P0 bank (e.g.
memecoins), suggest swapping them into a supported token.
If swapping to a different token would yield significantly more, recommend
the swap and explain the tradeoff.
Consider depositing multiple assets if the wallet holds several supported
tokens -- not just the single highest-yield one.
**Present the plan to the user with specific numbers before executing.**
Example: _"Your wallet holds 0.09 bbSOL (~$18) and 0.10 SOL (~$15). bbSOL
earns 15.2% APY on P0 vs SOL at 4.9%. I recommend depositing your bbSOL
for the higher yield. Shall I proceed?"_
### Step 4: Collect credentials
Before executing on-chain operations, the agent needs an RPC URL and a
wallet keypair.
**RPC URL:** Check `.env` for `RPC_URL`, `SOLANA_RPC_URL`, or `HELIUS_RPC_URL`.
If not found, ask the user: _"I need a paid Solana RPC URL to execute
transactions. (Helius has a free tier at https://www.helius.dev)"_
**Wallet address:** Check `.env` for `WALLET_ADDRESS`. If set, use it for
read-only operations (wallet balances, account discovery) without needing
the keypair. The keypair is only required when signing transactions.
**Wallet keypair:** If the user provided a keypair path in their message,
use it directly. Otherwise check `.env` for `WALLET_KEYPAIR`. If neither,
ask: _"I need a Solana keypair to sign transactions. Set `WALLET_KEYPAIR`
in your `.env` to the file path, or tell me where your keypair JSON file
is."_
**P0 account (optional):** Check `.env` for `P0_ACCOUNT`. If set, use it
directly when loading the account (skip discovery/prompt). If not set,
follow the account discovery logic in "Create or load account" below.
Do not fabricate URLs, file paths, or account addresses. Wait for the user
to provide real values.
### Step 5: Collect swap credentials (only if needed)
If the plan from step 3 involves swapping tokens, the agent needs a Jupiter
API key.
Check for an existing key in the environment:
- Look for `JUPITER_API_KEY` or `JUP_API_KEY` in the environment variables
or `.env` file
- If found, use it and skip the prompt
If no key is found, ask the user:
_"I need a Jupiter API key for the token swap. Get a free one at
https://portal.jup.ag (60 req/min)"_
If no swap is needed, skip this step entirely.
### Step 6: Execute
Execute the plan from step 3. Swap first if needed (see Swapping Tokens
section), then deposit, borrow, etc. Report results with Solscan links:
`https://solscan.io/tx/${signature}`
---
## Read-Only: Fetching Data from P0
Use the public HTTP APIs for read-only tasks. No SDK, no wallet, no RPC needed.
### Banks endpoint
`GET https://ai.0.xyz/api/banks`
Returns every lending pool (bank) with rates, metadata, and pricing. Only
collateral-tier banks are included (isolated banks are filtered out). The
response is a lightweight projection (9 fields per bank) with deposit APY
pre-computed.
```typescript
const res = await fetch("https://ai.0.xyz/api/banks");
const banks = await res.json();
```
**Fields per bank:**
| Field | Description |
| --------------- | ----------------------------------------------------------------------------- |
| `bank_address` | On-chain bank address (use with SDK `client.getBank()`) |
| `symbol` | Token symbol (SOL, USDC, JitoSOL, ...) |
| `mint` | Token mint address |
| `mint_decimals` | Token decimal places (9 for SOL, 6 for USDC) |
| `venue` | Lending venue (P0, Kamino, Drift) |
| `deposit_apy` | Effective deposit APY as percentage (pre-computed, includes underlying yield) |
| `borrow_apy` | Borrow APY as percentage |
| `usd_price` | Oracle price in USD |
| `token_program` | Token program (TOKEN_PROGRAM_ID or TOKEN_2022) |
The `deposit_apy` field already includes underlying token yield (e.g. LST staking
rates). No manual computation needed -- just sort by `deposit_apy` descending.
**Borrowing is only available on P0 venue banks.** Kamino and Drift banks are
deposit-only -- you can earn yield on them but cannot borrow from them. When
looking for borrow opportunities, filter to `venue === "P0"`.
**Finding best deposit yields:**
Sort banks by `deposit_apy` descending.
**Finding cheapest stablecoin borrows:**
Filter where `venue` is `"P0"` and `symbol` is in `[USDC, USDT, USDG, USDS, HYUSD]`,
sort by `borrow_apy` ascending.
**Matching wallet holdings to banks:** Use the `mint` field to match tokens in
the wallet to available banks. A wallet token account's mint address corresponds
to a bank's `mint` field.
### Strategies endpoint
`GET https: