मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)41k · #6646

defi-protocol-templates

यह क्या करती है

यह टेम्पलेट डिसेंट्रलाइज़्ड फ़ाइनेंस (DeFi) सिस्टम के कुछ हिस्से बनाने में मदद करता है। इसमें स्टेकिंग (सिक्के जमा करके इनाम कमाना), AMM (अपने-आप सिक्के बदलने वाला सिस्टम) और गवर्नेंस (फ़ैसलों पर वोट देना) जैसे फ़ीचर के लिए तैयार टेम्पलेट मिलते हैं।

कब इस्तेमाल करें

  • ✓ऐसा प्लेटफ़ॉर्म बनाना जहाँ यूज़र ब्याज कमाने के लिए सिक्के जमा कर सकें।
  • ✓ऐसा सिस्टम लागू करना जो एक डिजिटल करेंसी को दूसरी में अपने-आप बदल दे।
  • ✓किसी प्रोजेक्ट के अंदर फ़ैसलों के लिए वोटिंग सिस्टम बनाना।

Skill का लिंक

https://github.com/wshobson/agents/blob/main/plugins/blockchain-web3/skills/defi-protocol-templates/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/wshobson/agents/blob/main/plugins/blockchain-web3/skills/defi-protocol-templates/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“एक स्टेकिंग सिस्टम के लिए स्मार्ट कॉन्ट्रैक्ट बनाओ जो यूज़र्स को सिक्कों से इनाम दे।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह उदाहरण कोड (स्मार्ट कॉन्ट्रैक्ट) देता है, जिसे आप अपनी शुरुआत के लिए आधार बना सकते हैं। इन कोड में बुनियादी काम पहले से तैयार होते हैं, इसलिए डेवलपमेंट में समय और मेहनत दोनों बचते हैं।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

DeFi Protocol Templates

Production-ready templates for common DeFi protocols including staking, AMMs, governance, and flash loans.

When to Use This Skill

  • Building staking platforms with reward distribution
  • Implementing AMM (Automated Market Maker) protocols
  • Creating governance token systems
  • Integrating flash loan functionality

Staking Contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract StakingRewards is ReentrancyGuard, Ownable {
    IERC20 public stakingToken;
    IERC20 public rewardsToken;

    uint256 public rewardRate = 100; // Rewards per second
    uint256 public lastUpdateTime;
    uint256 public rewardPerTokenStored;

    mapping(address => uint256) public userRewardPerTokenPaid;
    mapping(address => uint256) public rewards;
    mapping(address => uint256) public balances;

    uint256 private _totalSupply;

    event Staked(address indexed user, uint256 amount);
    event Withdrawn(address indexed user, uint256 amount);
    event RewardPaid(address indexed user, uint256 reward);

    constructor(address _stakingToken, address _rewardsToken) {
        stakingToken = IERC20(_stakingToken);
        rewardsToken = IERC20(_rewardsToken);
    }

    modifier updateReward(address account) {
        rewardPerTokenStored = rewardPerToken();
        lastUpdateTime = block.timestamp;

        if (account != address(0)) {
            rewards[account] = earned(account);
            userRewardPerTokenPaid[account] = rewardPerTokenStored;
        }
        _;
    }

    function rewardPerToken() public view returns (uint256) {
        if (_totalSupply == 0) {
            return rewardPerTokenStored;
        }
        return rewardPerTokenStored +
            ((block.timestamp - lastUpdateTime) * rewardRate * 1e18) / _totalSupply;
    }

    function earned(address account) public view returns (uint256) {
        return (balances[account] *
            (rewardPerToken() - userRewardPerTokenPaid[account])) / 1e18 +
            rewards[account];
    }

    function stake(uint256 amount) external nonReentrant updateReward(msg.sender) {
        require(amount > 0, "Cannot stake 0");
        _totalSupply += amount;
        balances[msg.sender] += amount;
        stakingToken.transferFrom(msg.sender, address(this), amount);
        emit Staked(msg.sender, amount);
    }

    function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) {
        require(amount > 0, "Cannot withdraw 0");
        _totalSupply -= amount;
        balances[msg.sender] -= amount;
        stakingToken.transfer(msg.sender, amount);
        emit Withdrawn(msg.sender, amount);
    }

    function getReward() public nonReentrant updateReward(msg.sender) {
        uint256 reward = rewards[msg.sender];
        if (reward > 0) {
            rewards[msg.sender] = 0;
            rewardsToken.transfer(msg.sender, reward);
            emit RewardPaid(msg.sender, reward);
        }
    }

    function exit() external {
        withdraw(balances[msg.sender]);
        getReward();
    }
}

AMM (Automated Market Maker)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract SimpleAMM {
    IERC20 public token0;
    IERC20 public token1;

    uint256 public reserve0;
    uint256 public reserve1;

    uint256 public totalSupply;
    mapping(address => uint256) public balanceOf;

    event Mint(address indexed to, uint256 amount);
    event Burn(address indexed from, uint256 amount);
    event Swap(address indexed trader, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out);

    constructor(address _token0, address _token1) {
        token0 = IERC20(_token0);
        token1 = IERC20(_token1);
    }

    function addLiquidity(uint256 amount0, uint256 amount1) external returns (uint256 shares) {
        token0.transferFrom(msg.sender, address(this), amount0);
        token1.transferFrom(msg.sender, address(this), amount1);

        if (totalSupply == 0) {
            shares = sqrt(amount0 * amount1);
        } else {
            shares = min(
                (amount0 * totalSupply) / reserve0,
                (amount1 * totalSupply) / reserve1
            );
        }

        require(shares > 0, "Shares = 0");

…
अक्सर पूछे जाने वाले सवाल

'स्टेकिंग' क्या है?

यह कुछ-कुछ बचत खाते में पैसे रखने जैसा है, बस यहाँ डिजिटल सिक्के होते हैं। आप अपने सिक्के सिस्टम में जमा करते हैं और बदले में इनाम के तौर पर और सिक्के पाते हैं।

'AMM' क्या है?

AMM का मतलब है Automated Market Maker। यह एक ऐसा सिस्टम है जो एल्गोरिदम की मदद से बिना किसी इंसानी खरीदार या विक्रेता के डिजिटल करेंसी की अदला-बदली करवाता है।

'स्मार्ट कॉन्ट्रैक्ट' क्या होते हैं?

ये ब्लॉकचेन पर चलने वाले कंप्यूटर प्रोग्राम हैं। जब कुछ शर्तें पूरी होती हैं, तो ये समझौते के नियमों को अपने-आप लागू कर देते हैं, जैसे ट्रेडिंग या इनाम वाले सिस्टम में।

जानकारी

लेखक का मूल विवरण

Implement DeFi protocols with production-ready templates for staking, AMMs, governance, and flash loans. Use when building decentralized finance applications or smart contract protocols.

repo: wshobson/agents

लोकप्रियता

GitHub स्टार
41k
रैंकिंग में स्थान
#6646
लाइसेंस
MIT
अपडेट की गई
15/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills