본문으로 건너뛰기
cccskills
무료GitHub에 공개

1k-defi-module-integration

Interactive guide for integrating new DeFi modules or protocols into OneKey. Use when adding new DeFi features like staking protocols, lending markets, or entirely new DeFi modules. Triggers on DeFi, protocol, integration, Earn, Borrow, staking, lending, supply, borrow, withdraw, repay, claim, new module, Pendle, Aave, Compound.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md10.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

DeFi Module Integration Guide

This skill provides interactive guidance for integrating new DeFi modules or protocols into OneKey.

Quick Start

Before starting, determine your integration scenario:

ScenarioDescriptionGuide
New Protocol in EarnAdding a staking/yield protocol (e.g., Lido, Rocket Pool)earn-module-guide.md
New Protocol in BorrowAdding a lending market (e.g., Aave, Compound)borrow-module-guide.md
Entirely New ModuleCreating a new DeFi category (e.g., Pendle, GMX)new-module-guide.md

Integration Layers

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                                    │
└─────────────────────────────────────────────────────────────┘

Scenario Identification

When to ask the user

Ask for clarification when:

  1. The protocol type is ambiguous (could be Earn or Borrow)
  2. The operation types are not standard
  3. Special UI/UX requirements are mentioned
  4. The protocol has unique features not covered by existing patterns

Scenario characteristics

Earn Protocol (Staking/Yield):

  • Operations: Stake, Unstake, Claim
  • Data: APY, staked amount, rewards
  • Examples: Lido, Rocket Pool, Babylon

Borrow Protocol (Lending):

  • Operations: Supply, Withdraw, Borrow, Repay
  • Data: Health factor, collateral, debt, APY
  • Examples: Aave, Compound, Morpho
  • Advanced features: Repay with Collateral (swap-based repayment)
  • See: borrow-module-guide.md - Repay with Collateral

New Module:

  • Operations differ significantly from Earn/Borrow
  • Requires independent Tab or unique UI
  • Examples: Pendle (PT/YT), GMX (perpetuals)

Time-Based Protocol (Fixed-rate yield):

  • Operations: Buy, Sell, Redeem (conditional on maturity)
  • Data: Maturity date, implied APY, underlying asset, discount rate
  • Special features: Maturity status, conditional operations, multi-variant assets
  • Examples: Pendle PT
  • Integration: As sub-module of Earn Tab (Fixed-rate category)
  • See: earn-module-guide.md - Time-Based Protocols

Key Decision Points

DecisionOptionsDefault
Integration typeEarn / Borrow / New ModuleAsk user
Tab placementExisting Earn Tab / New TabEarn Tab
Operation count2-3 (Earn) / 4 (Borrow) / CustomBased on type
Risk warningsLiquidation / Slashing / NoneBased on type
Token selectionSingle / MultipleSingle
ChartsAPY history / Interest model / NoneBased on type
Share featureYes / NoYes
Multi-token listYes / NoBased on token count
Time-based featuresMaturity date / Conditional ops / NoneBased on protocol
Multi-variant assetsGroup by underlying / Flat listBased on protocol
Operation tabsSingle op / Tab switching (Buy/Sell/Redeem)Based on protocol
Repay with collateralWallet balance only / With collateral optionBased on protocol
Dual amount inputSingle input / Bidirectional syncBased on operation
Slippage settingsNot needed / Auto / CustomBased on swap involvement

State Management Decision

When integrating a new DeFi module, analyze the state requirements and ask the user:

State TypeRecommendationExamples
Needs Persistence (across page navigation)Use Jotai atomsPortfolio data, user preferences, cached investments
Page-scoped (no persistence needed)Use React ContextCurrent operation state, form data, temporary UI state

When using this skill, you should:

  1. Analyze the state requirements of the new module
  2. Ask the user whether the state needs to persist across page navigation
  3. Recommend Jotai for persistent state, Context for page-scoped state

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"

Quick Reference

Key File Paths

ModulePath
Earnpackages/kit/src/views/Earn/
Borrowpackages/kit/src/views/Borrow/
Staking (shared)packages/kit/src/views/Staking/
Routespackages/shared/src/routes/
Modal Routerpackages/kit/src/routes/Modal/router.tsx
Tab Routerpackages/kit/src/routes/Tab/router.ts

Common Components

ComponentLocationUsage
StakingAmountInputStaking/components/Amount input with validation
StakingFormWrapperStaking/components/Form layout wrapper
EarnTextStaking/components/ProtocolDetails/Styled text with color support
EarnTooltipStaking/components/ProtocolDetails/Info tooltips
PendingIndicatorStaking/components/StakingActivityIndicator/Pending tx indicator
ManagePositionContentStaking/pages/ManagePosition/Shared manage position UI
ManagePositionBorrow/components/ManagePosition/Unified Borrow operation component (Supply/Withdraw/Borrow/Repay)

State Management Patterns

PatternUse CaseReference
IAsyncData<T>Unified async data formatstate-management-guide.md
DataGateData orchestrationstate-management-guide.md
PendingBridgeExternal pending statestate-management-guide.md
Tag SystemPending tx identificationstate-management-guide.md

Workflow

Step 1: Identify Scenario

  • Determine if it's Earn, Borrow, or New Module
  • Read the corresponding guide

Step 2: Plan Layers

  • Decide which layers to implement (Home + Modal required)
  • Identify optional layers needed

Step 3: Implement Layer by Layer

  • Follow the guide for each layer
  • Use the checklist to verify completion

Step 4: Test and Verify

  • Test all operation types
  • Verify pending state handling
  • Check responsive layout

Related Skills

This skill works best when combined with these other OneKey skills:

SkillUse For
1k-i18nAdding translations, using ETranslations, useIntl()
1k-coding-patternsReact patterns, error handling, TypeScript best practices
1k-cross-platformPlatform-specific code, platformEnv checks
page-and-routeRoute configuration, deep links, navigation

i18n Quick Reference

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:

  1. Add key to ETranslations enum in packages/shared/src/locale/enum.ts
  2. Add translations in locale JSON files
  3. Never hardcode user-facing strings

Reference Documents

DocumentContent
earn-module-guide.mdEarn module architecture, files, operations
borrow-module-guide.mdBorrow module architecture, 4 operations, health factor
new-module-guide.mdCreating new modules, Provider design
routing-guide.mdModal routes, Tab routes, navigation utilities, deep links
state-management-guide.mdIAsyncData, Pending, Tag system, refresh strategies
checklist.mdIntegration checklist with required/optional markers

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

在每次回复中使用固定前缀并列出本次实际参考的指令/文件,便于校验是否遵循上下文与规则。

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

[00] META. Orchestrate skills into dynamic chains for complex tasks. Analyzes the task, discovers available skills, builds an optimal chain, explains why each skill is needed, and executes step-by-step with user confirmation. Use for any complex task requiring multiple thinking/research/analysis steps. Triggers on "plan this", "how to approach", "what's the strategy", "build a plan", or any multi-step problem requiring skill orchestration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

MikeCheng1208의 스킬 모두 보기

이 스킬의 문제 신고