Tooluck logoTooluck
SKILL.md

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)

plugins/blockchain-web3/skills/defi-protocol-templates/SKILL.md

MITFull file
1# DeFi Protocol Templates
2
3Production-ready templates for common DeFi protocols including staking, AMMs, governance, and flash loans.
4
5## When to Use This Skill
6
7- Building staking platforms with reward distribution
8- Implementing AMM (Automated Market Maker) protocols
9- Creating governance token systems
10- Integrating flash loan functionality
11
12## Staking Contract
13
14```solidity
15// SPDX-License-Identifier: MIT
16pragma solidity ^0.8.0;
17
18import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
19import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
20import "@openzeppelin/contracts/access/Ownable.sol";
21
22contract StakingRewards is ReentrancyGuard, Ownable {
23 IERC20 public stakingToken;
24 IERC20 public rewardsToken;
25
26 uint256 public rewardRate = 100; // Rewards per second
27 uint256 public lastUpdateTime;
28 uint256 public rewardPerTokenStored;
29
30 mapping(address => uint256) public userRewardPerTokenPaid;
31 mapping(address => uint256) public rewards;
32 mapping(address => uint256) public balances;
33
34 uint256 private _totalSupply;
35
36 event Staked(address indexed user, uint256 amount);
37 event Withdrawn(address indexed user, uint256 amount);
38 event RewardPaid(address indexed user, uint256 reward);
39
40 constructor(address _stakingToken, address _rewardsToken) {
41 stakingToken = IERC20(_stakingToken);
42 rewardsToken = IERC20(_rewardsToken);
43 }
44
45 modifier updateReward(address account) {
46 rewardPerTokenStored = rewardPerToken();
47…

Excerpt shown under the repository's MIT license.

More skills in agents

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates