defi-protocol-templates
Agent skill fromwshobson/agents
Implement DeFi protocols with production-ready templates for staking, AMMs, governance, and flash loans. Use when building decentralized finance applications or smart contract protocols.
How to install defi-protocol-templates
install defi-protocol-templates
# install the agents pack with the skills CLI
npx skills add wshobson/agents# or add only this skill to Claude Code: copy the folder
plugins/blockchain-web3/skills/defi-protocol-templates/
# into
~/.claude/skills/defi-protocol-templates/ (all projects)
.claude/skills/defi-protocol-templates/ (one project)
1# DeFi Protocol Templates23Production-ready templates for common DeFi protocols including staking, AMMs, governance, and flash loans.45## When to Use This Skill67- Building staking platforms with reward distribution8- Implementing AMM (Automated Market Maker) protocols9- Creating governance token systems10- Integrating flash loan functionality1112## Staking Contract1314```solidity15// SPDX-License-Identifier: MIT16pragma solidity ^0.8.0;1718import "@openzeppelin/contracts/token/ERC20/IERC20.sol";19import "@openzeppelin/contracts/security/ReentrancyGuard.sol";20import "@openzeppelin/contracts/access/Ownable.sol";2122contract StakingRewards is ReentrancyGuard, Ownable {23 IERC20 public stakingToken;24 IERC20 public rewardsToken;2526 uint256 public rewardRate = 100; // Rewards per second27 uint256 public lastUpdateTime;28 uint256 public rewardPerTokenStored;2930 mapping(address => uint256) public userRewardPerTokenPaid;31 mapping(address => uint256) public rewards;32 mapping(address => uint256) public balances;3334 uint256 private _totalSupply;3536 event Staked(address indexed user, uint256 amount);37 event Withdrawn(address indexed user, uint256 amount);38 event RewardPaid(address indexed user, uint256 reward);3940 constructor(address _stakingToken, address _rewardsToken) {41 stakingToken = IERC20(_stakingToken);42 rewardsToken = IERC20(_rewardsToken);43 }4445 modifier updateReward(address account) {46 rewardPerTokenStored = rewardPerToken();47…
Excerpt shown under the repository's MIT license.
