
defi-protocols
Master DeFi protocol development including AMMs, lending, yield, and oracles
- Installs
- 69
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-blockchain --skill defi-protocols- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads defi-protocols automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
DeFi Protocols Skill
Master DeFi protocol development including AMM mechanics, lending systems, yield optimization, and oracle integration.
Quick Start
# Invoke this skill for DeFi development
Skill("defi-protocols", protocol_type="amm", chain="ethereum")
Topics Covered
1. AMM (Automated Market Makers)
Build decentralized exchanges:
- Constant Product: x * y = k (Uniswap V2)
- Concentrated Liquidity: Tick-based (Uniswap V3)
- Stable Swaps: Curve invariant
- TWAP: Time-weighted average price
2. Lending Protocols
Create lending markets:
- Overcollateralized: Aave/Compound model
- Interest Rates: Utilization-based curves
- Liquidation: Health factor, incentives
- Isolated Markets: Risk segmentation
3. Yield Optimization
Maximize returns:
- Auto-compounding: Vault strategies
- Liquidity Mining: Reward distribution
- veTokens: Vote-escrowed governance
- Bribes: Gauge voting incentives
4. Oracle Integration
Secure price feeds:
- Chainlink: Decentralized oracles
- TWAP: Manipulation resistant
- Staleness Checks: Price freshness
- Fallbacks: Multi-oracle setups
Code Examples
AMM Swap Calculation
// 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);
}
}
Chainlink Oracle
// 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);
}
}
Flash Loan Callback
// 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;
}
}
DeFi Math Formulas
Constant Product AMM
Invariant: x * y = k
Output: dy = y - k/(x + dx)
Price: p = y/x
Slippage: dx/(x + dx) * 100%
Interest Rates
Utilization: U = borrows / (deposits + borrows)
Borrow Rate: R = base + slope * U (when U < optimal)
Supply Rate: R_supply = R_borrow * U * (1 - reserve_factor)
Health Factor
HF = (collateral * liquidation_threshold) / debt
Liquidation when HF < 1
Common Pitfalls
| 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 |
Security Checklist
- Oracle staleness validation
- Slippage protection
- Flash loan attack resistance
- Reentrancy guards
- Access control on admin
- Emergency pause mechanism
- Timelock on parameters
Troubleshooting
"Oracle price deviation"
# Compare oracle vs DEX price
cast call $ORACLE "latestRoundData()" --rpc-url $RPC
cast call $POOL "slot0()" --rpc-url $RPC
"Sandwich attack detected"
Add minimum output enforcement:
require(amountOut >= minAmountOut, "Slippage exceeded");
Protocol Addresses (Mainnet)
| Protocol | Contract |
|---|---|
| Uniswap V3 Router | 0xE592427A0AEce92De3Edee1F18E0157C05861564 |
| Aave V3 Pool | 0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2 |
| Chainlink ETH/USD | 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 |
Cross-References
- Bonded Agent:
04-defi-specialist - Related Skills:
solidity-development,smart-contract-security
Version History
| Version | Date | Changes |
|---|---|---|
| 2.0.0 | 2025-01 | Production-grade with math, security |
| 1.0.0 | 2024-12 | Initial release |
FAQ
What does the defi-protocols skill do?
Master DeFi protocol development including AMMs, lending, yield, and oracles
How do I install defi-protocols?
Run npx skills add https://github.com/pluginagentmarketplace/custom-plugin-blockchain --skill defi-protocols in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/defi-protocols/ (personal) or .claude/skills/defi-protocols/ (project).
Which AI agents can use defi-protocols?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is defi-protocols safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains defi-protocols?
It is published by pluginagentmarketplace in pluginagentmarketplace/custom-plugin-blockchain. It has 69 recorded installs.
More from pluginagentmarketplace/custom-plugin-blockchain
smart-contract-security
pluginagentmarketplace/custom-plugin-blockchain
Master smart contract security with auditing, vulnerability detection, and incident response
web3-frontend
pluginagentmarketplace/custom-plugin-blockchain
Master Web3 frontend development with wallet integration, viem/wagmi, and dApp UX
solidity-development
pluginagentmarketplace/custom-plugin-blockchain
Master Solidity smart contract development with patterns, testing, and best practices
blockchain-basics
pluginagentmarketplace/custom-plugin-blockchain
Master blockchain fundamentals including consensus, cryptography, and distributed systems
ethereum-development
pluginagentmarketplace/custom-plugin-blockchain
Master Ethereum development including EVM, gas optimization, and client interactions
nft-development
pluginagentmarketplace/custom-plugin-blockchain
Open the skill to read its SKILL.md instructions.
Popular business & finance skills
sales-enablement
coreyhaines31/marketingskills
When the user wants to create sales collateral, pitch decks, one-pagers, objection handling docs, or demo scripts. Also use when the user mentions 'sales deck,' 'pitch deck,' 'one-pager,' 'leave-behind,' 'objection handling,' 'deal-specific ROI analysis,' 'demo script,' 'talk track,' 'sales playbook,' 'proposal template,' 'buyer persona card,' 'battle card,' 'battlecard,' 'competitive one-pager,' 'win-loss analysis,' 'why are we losing deals,' 'loss reasons,' 'how do I respond to this objection,' 'prospect just said,' 'help my sales team,' 'sales materials,' or 'what should I give my sales reps,' 'cold call script,' or 'voicemail script.' Use this for any document or asset that helps a sales team close deals. For public competitor comparison pages, see competitors. For running buyer interviews or churn research, see customer-research. For marketing website copy, see copywriting. For cold outreach emails, see cold-email. For the offer being sold (bonuses, guarantees, pricing structure),
revops
coreyhaines31/marketingskills
When the user wants help with revenue operations, lead lifecycle management, or marketing-to-sales handoff processes. Also use when the user mentions 'RevOps,' 'revenue operations,' 'lead scoring,' 'outbound pipeline stages,' 'lead routing,' 'MQL,' 'SQL,' 'pipeline stages,' 'deal desk,' 'CRM automation,' 'marketing-to-sales handoff,' 'data hygiene,' 'leads aren't getting to sales,' 'pipeline management,' 'lead qualification,' or 'when should marketing hand off to sales.' Use this for anything involving the systems and processes that connect marketing to revenue. For cold outreach emails, see cold-email. For email drip campaigns, see emails. For pricing decisions, see pricing.
sales-funnel-blueprint
autonnel/autonnel-skills
Turn an offer into a concrete multi-step sales funnel spec - page-by-page structure, price ladder, copy outline and the metrics each step must hit. Use when asked to build a sales funnel, marketing funnel, landing page flow, lead magnet funnel, webinar funnel, tripwire or VSL funnel, when planning a product launch page flow, or when someone asks "what pages do I need" for selling something online.
pricing
coreyhaines31/marketingskills
When the user wants help with pricing decisions, packaging, or monetization strategy. Also use when the user mentions 'pricing,' 'pricing tiers,' 'freemium,' 'free trial,' 'packaging,' 'price increase,' 'value metric,' 'Van Westendorp,' 'willingness to pay,' 'monetization,' 'how much should I charge,' 'my pricing is wrong,' 'pricing page,' 'annual vs monthly,' 'per seat pricing,' 'should I offer a free plan,' 'pricing page teardown,' 'pricing page audit,' 'is my pricing page AI-readable,' or 'can AI read my pricing.' Use this whenever someone is figuring out what to charge, how to structure their plans, or wants to audit a pricing page (for humans and for the AI agents that shortlist tools). For in-app upgrade screens, see paywalls. For offer construction (bonuses, guarantees, value framing, naming) on services/courses/coaching/high-ticket B2B, see offers.
cross-border-ecommerce
nexscope-ai/ecommerce-skills
Cross-border e-commerce expansion advisor. Scores target markets on 8 weighted dimensions (market size, ecommerce penetration, competition, regulatory complexity, logistics infrastructure, payment ecosystem, cultural distance, IP protection), compares 5 fulfillment models with cost and transit data, provides country-by-country tax/duty compliance guides (EU VAT/IOSS, UK VAT, US sales tax, CA GST, AU GST, JP consumption tax), maps local payment preferences by market, and builds a phased expansion roadmap. No API key required.
pricing-strategy
coreyhaines31/marketingskills
When the user wants help with pricing decisions, packaging, or monetization strategy. Also use when the user mentions 'pricing,' 'pricing tiers,' 'freemium,' 'free trial,' 'packaging,' 'price increase,' 'value metric,' 'Van Westendorp,' 'willingness to pay,' 'monetization,' 'how much should I charge,' 'my pricing is wrong,' 'pricing page,' 'annual vs monthly,' 'per seat pricing,' or 'should I offer a free plan.' Use this whenever someone is figuring out what to charge or how to structure their plans. For in-app upgrade screens, see paywall-upgrade-cro.