defi-protocol-templates
Build DeFi protocol contracts faster
You need solid DeFi contract templates but do not want to start from scratch. This skill provides ready-to-use structures for staking, AMMs, governance, and lending protocols that you can adapt quickly.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "defi-protocol-templates". Explain the AMM template and list the main functions.
Expected outcome:
- The AMM tracks two token reserves and issues liquidity shares to providers.
- Main functions are addLiquidity, removeLiquidity, and swap.
- Prices follow a constant product model with a 0.3 percent fee on swaps.
Using "defi-protocol-templates". What does the staking contract reward calculation look like?
Expected outcome:
- The contract uses rewardPerTokenStored to track accumulated rewards per staked token.
- When users stake or withdraw, pending rewards are calculated and distributed.
- The formula multiplies time elapsed by reward rate divided by total supply.
Using "defi-protocol-templates". How do I create a governance proposal?
Expected outcome:
- Call the propose function with a description string.
- You must hold tokens above the proposal threshold.
- The proposal enters a voting period that lasts approximately three days.
Security Audit
SafePure documentation skill containing only Solidity code examples in markdown. No executable scripts, network calls, file system access, or environment variable harvesting detected. All 74 static findings are false positives caused by the scanner misinterpreting Solidity code syntax and markdown formatting as security threats.
Risk Factors
🌐 Network access (1)
⚡ Contains scripts (16)
⚙️ External commands (7)
Quality Score
What You Can Build
Prototype a DeFi MVP
Adapt staking and AMM templates to validate a new protocol idea quickly.
Plan protocol scope
Review governance and flash loan examples to define product requirements.
Compare baseline patterns
Use templates as a baseline to spot missing controls in custom code.
Try These Prompts
Summarize the staking rewards template and list the key state variables and events.
Explain how addLiquidity and swap work in the AMM template and note any math assumptions.
Outline the governance proposal lifecycle in the template and list where custom logic should go.
Identify security checks in the flash loan template and suggest two additional safeguards.
Best Practices
- Add comprehensive unit tests before deploying any adapted template
- Use audited OpenZeppelin libraries for token and access control logic
- Review math for overflow and rounding edge cases in production
Avoid
- Deploying templates without a professional security audit
- Skipping access control and pause mechanisms for critical functions
- Ignoring token decimal handling and fee edge cases
Frequently Asked Questions
What platforms are compatible?
What are the limits of these templates?
How do I integrate this with my project?
Does this skill access my data?
What if compilation fails?
How does this compare to full DeFi frameworks?
Developer Details
Author
wshobsonLicense
MIT
Repository
https://github.com/wshobson/agents/tree/main/plugins/blockchain-web3/skills/defi-protocol-templatesRef
main
File structure
📄 SKILL.md