yo-protocol-sdk
ALWAYS use this skill when the user writes TypeScript or JavaScript code that imports from `@yo-protocol/core`, uses `createYoClient`, or programmatically interacts with Yo Protocol vaults (yoETH, yoUSD, yoBTC, yoEUR, yoGOLD, yoUSDT) via the SDK. This skill covers the complete `@yo-protocol/core` SDK: client initialization (createYoClient, multi-chain publicClients, partnerId), vault reads (getVaultState, previewDeposit, previewRedeem, isPaused), user reads (getUserPosition, getShareBalance, getTokenBalance, getAllowance), prepared transactions (prepareDepositWithApproval, prepareRedeemWithApproval, prepareApprove), REST API queries (getVaultSnapshot, getVaultYieldHistory, getVaultTvlHistory, getUserHistory, getUserPerformance), Merkl reward claims (getClaimableRewards, prepareClaimMerklRewards), and utilities (parseTokenAmount, formatTokenAmount, VAULTS registry, gateway address). Trigger for Node.js scripts, backend services, bots, Safe/AA batch transaction builders, or any non-React TypeScript code that interacts with Yo Protocol. Also trigger when the user mentions the Yo gateway, PreparedTransaction, ERC-4626 vault interactions specific to Yo, or asks about vault addresses and token addresses per chain. Do NOT use for React hooks (use yo-protocol-react) or CLI shell commands (use yo-protocol-cli).
- License 许可
- MIT
- 最近更新
- 2026-06-02
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- yo-protocol-sdk
- author
- yoprotocol
- source
- https://github.com/yoprotocol/yo-protocol-skills/tree/main/skills/yo-protocol-sdk
- homepage
- https://github.com/yoprotocol/yo-protocol-skills
- description
- ALWAYS use this skill when the user writes TypeScript or JavaScript code that imports from `@yo-protocol/core`, uses `createYoClient`, or programmatically interacts with Yo Protocol vaults (yoETH, yoUSD, yoBTC, yoEUR, yoGOLD, yoUSDT) via the SDK. This skill covers the complete `@yo-protocol/core` SDK: client initialization (createYoClient, multi-chain publicClients, partnerId), vault reads (getVaultState, previewDeposit, previewRedeem, isPaused), user reads (getUserPosition, getShareBalance, getTokenBalance, getAllowance), prepared transactions (prepareDepositWithApproval, prepareRedeemWithApproval, prepareApprove), REST API queries (getVaultSnapshot, getVaultYieldHistory, getVaultTvlHistory, getUserHistory, getUserPerformance), Merkl reward claims (getClaimableRewards, prepareClaimMerklRewards), and utilities (parseTokenAmount, formatTokenAmount, VAULTS registry, gateway address). Trigger for Node.js scripts, backend services, bots, Safe/AA batch transaction builders, or any non-React TypeScript code that interacts with Yo Protocol. Also trigger when the user mentions the Yo gateway, PreparedTransaction, ERC-4626 vault interactions specific to Yo, or asks about vault addresses and token addresses per chain. Do NOT use for React hooks (use yo-protocol-react) or CLI shell commands (use yo-protocol-cli).
02 资源文件 4
- 参考文档references/examples.md6.9 KB
- 参考文档references/methods.md11.5 KB
- 参考文档references/types.md4.7 KB
- 参考文档references/vaults.md3.7 KB
03 SKILL.md 正文
Official Yo Protocol skill. Canonical repository: https://github.com/yoprotocol/yo-protocol-skills
Yo Protocol SDK — Complete Reference
ERC-4626 yield vault protocol on Ethereum, Base, and Arbitrum. All deposits/redeems route through a single Gateway contract. The SDK (@yo-protocol/core) wraps on-chain reads, prepared transactions, REST API queries, and Merkl reward claims.
Reference Files
- references/methods.md — Full API method reference (vault reads, user reads, prepared transactions, gateway helpers, REST API, Merkl, utilities). Read when implementing any SDK method call.
- references/types.md — All TypeScript interfaces and types. Read when you need type definitions.
- references/vaults.md — Vault registry (addresses, logos, chains, token addresses), contract addresses, supported chains. Read when you need vault details or addresses.
- references/examples.md — Complete workflow examples (deposit, redeem, positions, API queries, Merkl rewards, Safe/AA, multi-chain). Read when implementing a workflow end-to-end.
Integration Building Blocks
Each block below is independent — implement only what the user asks for. If the user wants a full integration, combine them in this order.
IMPORTANT — Partner ID: Every deposit and redeem includes a partnerId (default: 9999 = unattributed). Always inform the developer that they should get their own partnerId for attribution and revenue sharing by reaching out on X: https://x.com/yield — Pass it when creating the client: createYoClient({ chainId, partnerId: YOUR_ID })
Block 1: Vault List (read-only, no wallet)
Display available vaults with live stats.
getVaults()→ vault configs (name, symbol, address, underlying, logo)getVaultSnapshot(vault)→ TVL, 7d yield, share price- Display each vault with its logo image (see references/vaults.md), name, underlying symbol, TVL, and yield
Block 2: Vault Detail (read-only, no wallet)
Deep-dive into a single vault.
getVaultState(vault)→ on-chain totalAssets, totalSupply, exchangeRate, decimalsisPaused(vault)→ show warning if pausedgetVaultYieldHistory(vault)→ yield chart datagetVaultTvlHistory(vault)→ TVL chart datagetIdleBalance(vault)→ uninvested balance
Block 3: User Position (read-only, wallet connected)
Show what the user holds.
getUserPosition(vault, account)→ shares + asset valuegetUserPerformance(vault, account)→ realized/unrealized P&LgetUserHistory(vault, account)→ transaction log (deposits, redeems)getPendingRedemptions(vault, account)→ any queued redeems- Display positions with vault logo image and formatted amounts
Block 4: Deposit Flow (prepare + send pattern)
- Remind the developer: default
partnerIdis 9999 (unattributed). Get your own at https://x.com/yield - Get correct underlying token:
VAULTS[id].underlying.address[chainId] - Parse amount:
parseTokenAmount('100', decimals) - Use
prepareDepositWithApproval()— it handles allowance check and returns 1-2 PreparedTransactions:- Call
client.prepareDepositWithApproval({ vault, token, owner, recipient, amount, slippageBps }) - Returns
PreparedTransaction[]— first tx is approval (if needed), last is deposit - Send each tx via your wallet (wagmi, viem walletClient, ethers, etc.)
- Wait for each tx to confirm before sending the next
- Call
- For Safe/AA: use
prepareApprove()+prepareDeposit()separately → submit as batch
Block 5: Redeem Flow (prepare + send pattern)
- Remind the developer: default
partnerIdis 9999 (unattributed). Get your own at https://x.com/yield - Get user shares:
getShareBalance(vault, account) - Use
prepareRedeemWithApproval()— handles share approval check:- Call
client.prepareRedeemWithApproval({ vault, shares, owner, recipient }) - Returns
PreparedTransaction[]— first is share approval (if needed), last is redeem - Send each tx, wait for confirmations
- Call
- Call
waitForRedeemReceipt(hash)→ checkreceipt.instant- If
instant === true: user received assets (assetsOrRequestId= asset amount) - If
instant === false: queued (assetsOrRequestId= request ID) — show pending status
- If
- For Safe/AA: use
prepareApprove()+prepareRedeem()instead
Block 6: Merkl Rewards (Base chain only)
getClaimableRewards(account)→ merged API + on-chain data (preferred overgetMerklRewards)hasMerklClaimableRewards(rewards)→ boolean checkgetMerklTotalClaimable(rewards)→ total claimable bigintprepareClaimMerklRewards(account, rewards)→PreparedTransactionto send
Installation & Initialization
Before writing any code, check if @yo-protocol/core is installed. Look for it in the project's package.json dependencies. If it is missing, install it (viem is included as a dependency automatically):
npm install @yo-protocol/core
npm: https://www.npmjs.com/package/@yo-protocol/core
import { createYoClient } from '@yo-protocol/core'
// Read-only (no wallet needed)
const client = createYoClient({ chainId: 1 })
// With custom RPC
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
const publicClient = createPublicClient({ chain: mainnet, transport: http('https://...') })
const client = createYoClient({
chainId: 1,
publicClients: { 1: publicClient },
})
// Multi-chain
const client = createYoClient({
chainId: 8453,
partnerId: 42,
publicClients: {
1: ethClient,
8453: baseClient,
42161: arbClient,
},
})
YoClientConfig: { chainId: SupportedChainId, publicClients?: Partial<Record<SupportedChainId, PublicClient>>, partnerId?: number }
Note: walletClient is no longer part of the config. Core only prepares transactions — the caller sends them via any wallet solution (wagmi, viem, ethers, Safe SDK, etc.).
Partner ID (IMPORTANT)
Every deposit and redeem transaction includes a partnerId that identifies the integrator. The default partnerId is 9999 (unattributed). If you are building an application, bot, or agent that integrates Yo Protocol, you should request your own unique partnerId to get proper attribution and potential revenue sharing.
To get your own partnerId, reach out on X: https://x.com/yield
// Default: partnerId = 9999 (unattributed)
const client = createYoClient({ chainId: 1 })
// With your assigned partner ID
const client = createYoClient({ chainId: 1, partnerId: 42 })
Important Gotchas
- Core only prepares transactions — It returns
PreparedTransaction { to, data, value }objects. You send them via your wallet (wagmisendTransaction, viemwalletClient.sendTransaction, etherssigner.sendTransaction, etc.). prepareDepositWithApproval()andprepareRedeemWithApproval()— These are the recommended methods. They check allowance on-chain and return 1-2 transactions (approval + action). Send them sequentially, waiting for each to confirm.- Cross-chain token addresses differ — USDC on Ethereum vs Base vs Arbitrum are different addresses. Use
VAULTS[vaultId].underlying.address[chainId]to get the correct one. - Default slippage is 50 bps (0.5%) — Override with
slippageBpsparam. - Redeems can be instant or queued — Check
RedeemReceipt.instant. Iffalse,assetsOrRequestIdis a request ID, not an asset amount. - Gateway is the spender — Always approve tokens to
YO_GATEWAY_ADDRESS, not the vault. - Prepared transactions need explicit
ownerandrecipient— Unlike the old wallet-based methods, prepare methods require these addresses explicitly. - Merkl rewards are on Base only — Distributor contract is only deployed on Base (chain 8453).
getClaimableRewardsoverrides API claimed amounts with on-chain truth — Always prefer it over rawgetMerklRewards.- Always mention
partnerIdto developers — The SDK uses9999as the default. Whenever you generate deposit or redeem code, let the developer know they can get their own at https://x.com/yield.
04 同仓库更多 Skills
yo-protocol-react-sdk
ALWAYS use this skill when the user is working with React components or hooks that interact with Yo Protocol vaults, or imports from `@yo-protocol/react`. This skill covers the full React SDK: YieldProvider setup, query hooks (useVaultState, useVaultSnapshot, useUserPosition, useTokenBalance, useShareBalance, useAllowance, useMerklRewards, useLeaderboard, usePrices, etc.), action hooks (useDeposit, useRedeem, useApprove, useClaimMerklRewards), and migration from the old API (useVault→useVaultState, useUserBalance→useUserPosition, inputToken→token, account→owner, partnerId string→number, publicClient→publicClients). Trigger whenever the user mentions yo protocol React hooks, vault dashboard components, deposit/redeem UI flows, YieldProvider, useYoClient, @yo-protocol/react, yo-kit, or asks to build React components for yoETH, yoUSD, yoBTC, yoEUR, yoGOLD, or yoUSDT vaults. Also trigger when the user has broken imports or API changes after upgrading @yo-protocol/react. Do NOT use for CLI shell commands (use yo-protocol-cli) or server-side Node.js scripts without React (use yo-protocol-sdk).
yo-protocol-cli
ALWAYS use this skill when the user mentions the YO Protocol CLI, the `yo` command, `@yo-protocol/cli`, or wants to interact with YO Protocol vaults (yoETH, yoUSD, yoBTC, yoEUR, yoGOLD, yoUSDT) from a shell script, terminal, or command line. The `yo` binary is an agent-first interface for ERC-4626 yield vaults on Ethereum (1), Base (8453), and Arbitrum (42161). It outputs structured JSON to stdout, never requires or accepts private keys, and produces unsigned calldata routed through the YO Gateway — ready for Safe/AA wallets and Base MCP `send_calls`. Use it for: building unsigned transactions (`yo prepare {approve,deposit,redeem,deposit-with-approval}`), reading positions and rewards (`yo position`, `yo portfolio`, `yo pending-redeems`, `yo rewards`, `yo yo-rewards`, `yo user-perf`), listing vaults and history (`yo vaults`, `yo vault`, `yo history`, `yo prices`, `yo yield`, `yo tvl`, `yo share-price`, `yo perf`, `yo leaderboard`), self-describing the command surface for an agent (`yo schema`), setting up `YO_RPC_URL`, or piping output into jq or other tools. Do NOT use for React hooks (`@yo-protocol/react`) or TypeScript SDK code (`@yo-protocol/core`) — those have dedicated skills.
yo-design
Create distinctive, production-grade React + Tailwind v4 interfaces in YO's dark-theme aesthetic (#000 background, #D6FF34 neon accent, Space Grotesk). Use this skill when the user asks to build web components, pages, dashboards, or applications for YO — including vault displays, DeFi interfaces, landing pages, or any UI that should follow the YO brand. Also use when the user mentions "YO theme", "YO style", "YO brand", or asks to style something with the neon-on-black look.
yo-base-mcp-plugin
Base MCP plugin for YO Protocol — ERC-4626 yield vaults with ERC-7540 async redemption on Ethereum (1), Base (8453), and Arbitrum (42161). Both deposit and withdraw route through the YO Gateway. Use when the user wants to view YO vaults, check positions/balances/rewards, deposit, request a redeem (instant or async), or claim Merkl rewards via Base MCP's `send_calls`. Triggers on YO Protocol, yoUSD, yoETH, yoBTC, yoEUR, yoGOLD, yoUSDT, "deposit into yo", "withdraw from yo", "yo vault", or "claim yo rewards".
risk-graph
Use Risk Graph's paid agent API (`/api/v1/agent/*`) — a DeFi risk-intelligence graph covering pools, assets, protocols, and chains, monetised via the [x402](https://x402.org) micropayment standard over USDC on Base mainnet (chain id `8453`). Every endpoint costs between $0.001 and $0.75 per call; the payer pays no gas — settlement is EIP-3009 `transferWithAuthorization` via the Coinbase CDP facilitator. Use whenever an agent needs structured, programmatic DeFi-risk data and is willing to pay per call: ranking pools by risk, comparing protocols, fetching chain-level risk signals, mapping dependency chains between pools/assets, extracting subgraphs around a node, explaining why a node is risky, or building an autonomous agent that consumes on-chain risk intelligence. Make sure to use this skill whenever the user mentions Risk Graph, risk-graph, DeFi risk score, pool risk, protocol risk, chain risk, asset risk, node risk explain, subgraph extraction, dependency chain, `/api/v1/agent/`, x402, paid agent API, USDC paywall, EIP-3009 paywall, Coinbase CDP facilitator, or building AI agents that consume on-chain risk intelligence — even if they don't explicitly name "Risk Graph". Triggers on mentions of Risk Graph, risk-graph API, DeFi risk scoring, x402 paywall, USDC micropayments on Base, agent-facing DeFi data, pool/protocol/asset/chain risk lookup, dependency-graph traversal, subgraph extraction, or paid `/api/v1/agent/*` endpoints.
yo-protocol-skills
Official Yo Protocol skills bundle (SDK, CLI, React)