ワンクリックで
1k-defi-module-integration
Guide for integrating new DeFi modules or protocols (staking, lending, Earn, Borrow) into OneKey.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Guide for integrating new DeFi modules or protocols (staking, lending, Earn, Borrow) into OneKey.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Analytics event tracking for OneKey. Use when adding tracking events, logging to server, user behavior tracking, or business metrics. Covers the @LogToServer decorator pattern, logger scope/scene architecture, and common pitfalls. Triggers on "埋点", "统计", "打点", "数据追踪", "日志", "analytics", "tracking event", "Mixpanel", "LogToServer", "trackEvent", "defaultLogger".
Create test versions to verify app auto-update functionality and version migration.
Release branch management — checkout from release, prepare builds, pre-release diff checks, publish tracking, and sync back to x. Use this skill when managing release branches, creating branches for bundle releases, running pre-release diff checks, finalizing releases, or syncing release changes to x. Triggers on "bundle release", "release diff", "release publish", "release sync", "release checkout", "发布管理", "release 分支", "release management", "bundle-release", "bundle branch".
Code quality standards — lint (eslint/oxlint), type check (tsc), pre-commit hooks, and comment conventions. All comments must be in English.
Comprehensive PR code review for OneKey monorepo. Use when reviewing PRs, code changes, or diffs — covers security (secrets/PII leakage, supply-chain, AuthN/AuthZ), code quality (hooks, race conditions, null safety, concurrent requests), and OneKey-specific patterns (Fabric crashes, MIUI, BigNumber). Triggers on "review PR", "review this PR", "code review", "check this diff", "审查 PR", "代码审查", "review
Coding patterns and best practices — React components, promise handling, and TypeScript conventions.
| name | 1k-defi-module-integration |
| description | Guide for integrating new DeFi modules or protocols (staking, lending, Earn, Borrow) into OneKey. |
This skill provides interactive guidance for integrating new DeFi modules or protocols into OneKey.
Before starting, determine your integration scenario:
| Scenario | Description | Guide |
|---|---|---|
| New Protocol in Earn | Adding a staking/yield protocol (e.g., Lido, Rocket Pool) | earn-module-guide.md |
| New Protocol in Borrow | Adding a lending market (e.g., Aave, Compound) | borrow-module-guide.md |
| Entirely New Module | Creating a new DeFi category (e.g., Pendle, GMX) | new-module-guide.md |
Each DeFi module consists of 4 layers. Home and Modal are required; Details and List are optional.
┌─────────────────────────────────────────────────────────────┐
│ Layer 1: HOME PAGE (Required) │
│ - Overview data (total value, APY, health factor) │
│ - Asset cards/tables │
│ - Pending transaction tracking │
├─────────────────────────────────────────────────────────────┤
│ Layer 2: OPERATION MODALS (Required) │
│ - Earn: Stake, Unstake, Claim (2-3 types) │
│ - Borrow: Supply, Withdraw, Borrow, Repay (4 types) │
│ - Amount input, validation, risk warnings │
├─────────────────────────────────────────────────────────────┤
│ Layer 3: DETAILS PAGE (Optional) │
│ - Charts (APY history, interest rate model) │
│ - Detailed protocol information │
│ - Share functionality │
├─────────────────────────────────────────────────────────────┤
│ Layer 4: PROTOCOL LIST (Optional, for multi-token) │
│ - List of available protocols/assets │
│ - Filtering and sorting │
│ - Navigation to details │
└─────────────────────────────────────────────────────────────┘
Ask for clarification when:
Earn Protocol (Staking/Yield):
Borrow Protocol (Lending):
New Module:
Time-Based Protocol (Fixed-rate yield):
| Decision | Options | Default |
|---|---|---|
| Integration type | Earn / Borrow / New Module | Ask user |
| Tab placement | Existing Earn Tab / New Tab | Earn Tab |
| Operation count | 2-3 (Earn) / 4 (Borrow) / Custom | Based on type |
| Risk warnings | Liquidation / Slashing / None | Based on type |
| Token selection | Single / Multiple | Single |
| Charts | APY history / Interest model / None | Based on type |
| Share feature | Yes / No | Yes |
| Multi-token list | Yes / No | Based on token count |
| Time-based features | Maturity date / Conditional ops / None | Based on protocol |
| Multi-variant assets | Group by underlying / Flat list | Based on protocol |
| Operation tabs | Single op / Tab switching (Buy/Sell/Redeem) | Based on protocol |
| Repay with collateral | Wallet balance only / With collateral option | Based on protocol |
| Dual amount input | Single input / Bidirectional sync | Based on operation |
| Slippage settings | Not needed / Auto / Custom | Based on swap involvement |
When integrating a new DeFi module, analyze the state requirements and ask the user:
| State Type | Recommendation | Examples |
|---|---|---|
| Needs Persistence (across page navigation) | Use Jotai atoms | Portfolio data, user preferences, cached investments |
| Page-scoped (no persistence needed) | Use React Context | Current operation state, form data, temporary UI state |
When using this skill, you should:
Example question to ask:
"Does this module's data need to persist when the user navigates away and returns? For example:
- If yes (like portfolio data that should be cached): Use Jotai atoms
- If no (like form state that resets on page exit): Use React Context"
| Module | Path |
|---|---|
| Earn | packages/kit/src/views/Earn/ |
| Borrow | packages/kit/src/views/Borrow/ |
| Staking (shared) | packages/kit/src/views/Staking/ |
| Routes | packages/shared/src/routes/ |
| Modal Router | packages/kit/src/routes/Modal/router.tsx |
| Tab Router | packages/kit/src/routes/Tab/router.ts |
| Component | Location | Usage |
|---|---|---|
StakingAmountInput | Staking/components/ | Amount input with validation |
StakingFormWrapper | Staking/components/ | Form layout wrapper |
EarnText | Staking/components/ProtocolDetails/ | Styled text with color support |
EarnTooltip | Staking/components/ProtocolDetails/ | Info tooltips |
PendingIndicator | Staking/components/StakingActivityIndicator/ | Pending tx indicator |
ManagePositionContent | Staking/pages/ManagePosition/ | Shared manage position UI |
ManagePosition | Borrow/components/ManagePosition/ | Unified Borrow operation component (Supply/Withdraw/Borrow/Repay) |
| Pattern | Use Case | Reference |
|---|---|---|
IAsyncData<T> | Unified async data format | state-management-guide.md |
DataGate | Data orchestration | state-management-guide.md |
PendingBridge | External pending state | state-management-guide.md |
| Tag System | Pending tx identification | state-management-guide.md |
This skill works best when combined with these other OneKey skills:
| Skill | Use For |
|---|---|
1k-i18n | Adding translations, using ETranslations, useIntl() |
1k-coding-patterns | React patterns, error handling, TypeScript best practices |
1k-cross-platform | Platform-specific code, platformEnv checks |
page-and-route | Route configuration, deep links, navigation |
All user-facing strings must use internationalization. See 1k-i18n skill for full details.
Basic Usage:
import { useIntl } from 'react-intl';
import { ETranslations } from '@onekeyhq/shared/src/locale';
function MyComponent() {
const intl = useIntl();
return (
<Text>
{intl.formatMessage({ id: ETranslations.defi_net_worth })}
</Text>
);
}
Common DeFi Translation Keys:
ETranslations.defi_net_worth - "Net Worth"ETranslations.defi_net_apy - "Net APY"ETranslations.defi_health_factor - "Health Factor"ETranslations.defi_platform_bonus - "Platform Bonus"ETranslations.defi_claimable_rewards - "Claimable Rewards"ETranslations.global_history - "History"Adding New Keys:
ETranslations enum in packages/shared/src/locale/enum.ts| Document | Content |
|---|---|
| earn-module-guide.md | Earn module architecture, files, operations |
| borrow-module-guide.md | Borrow module architecture, 4 operations, health factor |
| new-module-guide.md | Creating new modules, Provider design |
| routing-guide.md | Modal routes, Tab routes, navigation utilities, deep links |
| state-management-guide.md | IAsyncData, Pending, Tag system, refresh strategies |
| checklist.md | Integration checklist with required/optional markers |