用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-blockchain --skill defi-protocols命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Master blockchain fundamentals including consensus, cryptography, and distributed systems
Master Ethereum development including EVM, gas optimization, and client interactions
Master NFT development with token standards, metadata, marketplaces, and on-chain art
基于 SOC 职业分类
| name | defi-protocols |
| description | Master DeFi protocol development including AMMs, lending, yield, and oracles |
| sasmp_version | 1.3.0 |
| version | 2.0.0 |
| updated | 2025-01 |
| bonded_agent | 04-defi-specialist |
| bond_type | PRIMARY_BOND |
| atomic | true |
| single_responsibility | defi_development |
| parameters | {"protocol_type":{"type":"string","required":true,"enum":["amm","lending","yield","oracle","flash_loan"]},"chain":{"type":"string","default":"ethereum"}} |
| retry_config | {"max_attempts":3,"backoff":"exponential","initial_delay_ms":1000} |
| logging | {"level":"info","include_timestamps":true,"track_usage":true} |
Master DeFi protocol development including AMM mechanics, lending systems, yield optimization, and oracle integration.
# Invoke this skill for DeFi development
Skill("defi-protocols", protocol_type="amm", chain="ethereum")
Build decentralized exchanges:
Create lending markets:
Maximize returns:
Secure price feeds:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
library SwapMath {
uint256 constant FEE_NUMERATOR = 997;
uint256 constant FEE_DENOMINATOR = 1000;
/// @notice Calculate output amount for constant product AMM
function getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut
) internal pure returns (uint256) {
uint256 amountInWithFee = amountIn * FEE_NUMERATOR;
uint256 numerator = amountInWithFee * reserveOut;
uint256 denominator = reserveIn * FEE_DENOMINATOR + amountInWithFee;
return numerator / denominator;
}
/// @notice Calculate price impact percentage (basis points)
function getPriceImpact(
uint256 amountIn,
uint256 reserveIn
) internal pure returns (uint256) {
return (amountIn * 10000) / (reserveIn + amountIn);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract PriceOracle {
AggregatorV3Interface public immutable priceFeed;
uint256 public constant STALENESS_THRESHOLD = 1 hours;
error StalePrice();
error InvalidPrice();
constructor(address feed) {
priceFeed = AggregatorV3Interface(feed);
}
function getPrice() external view returns (uint256) {
(, int256 price,, uint256 updatedAt,) = priceFeed.latestRoundData();
if (block.timestamp - updatedAt > STALENESS_THRESHOLD) {
revert StalePrice();
}
if (price <= 0) revert InvalidPrice();
return uint256(price);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@aave/v3-core/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol";
contract Arbitrage is FlashLoanSimpleReceiverBase {
function executeOperation(
address asset,
uint256 amount,
uint256 premium,
address,
bytes calldata
) external override returns (bool) {
// Execute arbitrage logic here
// Repay: amount + premium
IERC20(asset).approve(address(POOL), amount + premium);
return true;
}
}
Invariant: x * y = k
Output: dy = y - k/(x + dx)
Price: p = y/x
Slippage: dx/(x + dx) * 100%
Utilization: U = borrows / (deposits + borrows)
Borrow Rate: R = base + slope * U (when U < optimal)
Supply Rate: R_supply = R_borrow * U * (1 - reserve_factor)
HF = (collateral * liquidation_threshold) / debt
Liquidation when HF < 1
| Pitfall | Risk | Prevention |
|---|---|---|
| Spot price oracle | Flash loan manipulation | Use TWAP |
| No slippage check | Sandwich attacks | Enforce min output |
| Stale prices | Wrong liquidations | Check updatedAt |
| Reentrancy | Fund drainage | CEI + guards |
# Compare oracle vs DEX price
cast call $ORACLE "latestRoundData()" --rpc-url $RPC
cast call $POOL "slot0()" --rpc-url $RPC
Add minimum output enforcement:
require(amountOut >= minAmountOut, "Slippage exceeded");
| Protocol | Contract |
|---|---|
| Uniswap V3 Router | 0xE592427A0AEce92De3Edee1F18E0157C05861564 |
| Aave V3 Pool | 0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2 |
| Chainlink ETH/USD | 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 |
04-defi-specialistsolidity-development, smart-contract-security| Version | Date | Changes |
|---|---|---|
| 2.0.0 | 2025-01 | Production-grade with math, security |
| 1.0.0 | 2024-12 | Initial release |