[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M731XGXGXC7RY5G3J39853AJ":3,"skill-same:01M731XGXGXC7RY5G3J39853AJ":49},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M731XGXGXC7RY5G3J39853AJ","defi-amm-security",null,"Solidity AMM 合约、流动性池和交换流程的安全检查清单。涵盖重入、CEI 排序、捐赠或通胀攻击、预言机操纵、滑点、管理员控制和整数数学。","SriramGandhiS\u002FSkills","SriramGandhiS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F211849986?v=4","01M72WQCW12BYX71C6WN584TTA","Sriram S","01M72WQCWTJ2RD0ET1X31AF1RC",1,"MIT","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fdefi-amm-security\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: defi-amm-security\ndescription: Solidity AMM 合约、流动性池和交换流程的安全检查清单。涵盖重入、CEI 排序、捐赠或通胀攻击、预言机操纵、滑点、管理员控制和整数数学。\norigin: ECC direct-port adaptation\nversion: \"1.0.0\"\n---\n\n# DeFi AMM 安全\n\nSolidity AMM 合约、LP 金库和交换函数的关键漏洞模式及强化实现。\n\n## 适用场景\n\n* 编写或审计 Solidity AMM 或流动性池合约\n* 实现持有代币余额的交换、存款、提款、铸造或销毁流程\n* 审查任何在份额或储备金计算中使用 `token.balanceOf(address(this))` 的合约\n* 向 DeFi 协议添加费用设置器、暂停器、预言机更新或其他管理功能\n\n## 工作原理\n\n将其作为检查清单加模式库使用。对照以下类别审查每个用户入口点，并优先使用强化示例而非自行编写的变体。\n\n## 执行安全\n\n本技能中的 shell 命令是本地审计示例。仅在受信任的代码检出或一次性沙箱中运行，不要将不受信任的合约名称、路径、RPC URL、私钥或用户提供的标志拼接到 shell 命令中。在安装工具或运行可能消耗大量本地或付费资源的长时间模糊测试\u002F静态分析任务前，请先询问。\n\n切勿在命令示例、日志或报告中包含机密信息、私钥、助记词、API 令牌或主网签名凭证。\n\n## 示例\n\n### 重入攻击：强制遵循 CEI 顺序\n\n存在漏洞：\n\n```solidity\nfunction withdraw(uint256 amount) external {\n    require(balances[msg.sender] >= amount);\n    token.transfer(msg.sender, amount);\n    balances[msg.sender] -= amount;\n}\n```\n\n安全：\n\n```solidity\nimport {ReentrancyGuard} from \"@openzeppelin\u002Fcontracts\u002Futils\u002FReentrancyGuard.sol\";\nimport {SafeERC20} from \"@openzeppelin\u002Fcontracts\u002Ftoken\u002FERC20\u002Futils\u002FSafeERC20.sol\";\n\nusing SafeERC20 for IERC20;\n\nfunction withdraw(uint256 amount) external nonReentrant {\n    require(balances[msg.sender] >= amount, \"Insufficient\");\n    balances[msg.sender] -= amount;\n    token.safeTransfer(msg.sender, amount);\n}\n```\n\n当存在经过验证的库时，不要自行编写防护措施。\n\n### 捐赠或通胀攻击\n\n直接使用 `token.balanceOf(address(this))` 进行份额计算，会让攻击者通过向合约发送代币（绕过预期路径）来操纵分母。\n\n```solidity\n\u002F\u002F Vulnerable\nfunction deposit(uint256 assets) external returns (uint256 shares) {\n    shares = (assets * totalShares) \u002F token.balanceOf(address(this));\n}\n```\n\n```solidity\n\u002F\u002F Safe\nuint256 private _totalAssets;\n\nfunction deposit(uint256 assets) external nonReentrant returns (uint256 shares) {\n    uint256 balBefore = token.balanceOf(address(this));\n    token.safeTransferFrom(msg.sender, address(this), assets);\n    uint256 received = token.balanceOf(address(this)) - balBefore;\n\n    shares = totalShares == 0 ? received : (received * totalShares) \u002F _totalAssets;\n    _totalAssets += received;\n    totalShares += shares;\n}\n```\n\n跟踪内部会计并衡量实际收到的代币。\n\n### 预言机操纵\n\n现货价格可通过闪电贷操纵。优先使用 TWAP。\n\n```solidity\nuint32[] memory secondsAgos = new uint32[](2);\nsecondsAgos[0] = 1800;\nsecondsAgos[1] = 0;\n(int56[] memory tickCumulatives,) = IUniswapV3Pool(pool).observe(secondsAgos);\nint24 twapTick = int24(\n    (tickCumulatives[1] - tickCumulatives[0]) \u002F int56(uint56(30 minutes))\n);\nuint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(twapTick);\n```\n\n### 滑点保护\n\n每个交换路径都需要调用者提供的滑点和截止时间。\n\n```solidity\nfunction swap(\n    uint256 amountIn,\n    uint256 amountOutMin,\n    uint256 deadline\n) external returns (uint256 amountOut) {\n    require(block.timestamp \u003C= deadline, \"Expired\");\n    amountOut = _calculateOut(amountIn);\n    require(amountOut >= amountOutMin, \"Slippage exceeded\");\n    _executeSwap(amountIn, amountOut);\n}\n```\n\n### 安全的储备金计算\n\n```solidity\nimport {FullMath} from \"@uniswap\u002Fv3-core\u002Fcontracts\u002Flibraries\u002FFullMath.sol\";\n\nuint256 result = FullMath.mulDiv(a, b, c);\n```\n\n对于大型储备金计算，当存在溢出风险时，避免使用简单的 `a * b \u002F c`。\n\n### 管理控制\n\n```solidity\nimport {Ownable2Step} from \"@openzeppelin\u002Fcontracts\u002Faccess\u002FOwnable2Step.sol\";\n\ncontract MyAMM is Ownable2Step {\n    function setFee(uint256 fee) external onlyOwner { ... }\n    function pause() external onlyOwner { ... }\n}\n```\n\n所有权转移应优先使用显式接受，并对每个特权路径设置门控。\n\n## 安全检查清单\n\n* 暴露于重入攻击的入口点使用 `nonReentrant`\n* 遵循 CEI 顺序\n* 份额计算不依赖原始的 `balanceOf(address(this))`\n* ERC-20 转账使用 `SafeERC20`\n* 存款衡量实际收到的代币\n* 预言机读取使用 TWAP 或其他抗操纵源\n* 交换需要 `amountOutMin`和`deadline`\n* 对溢出敏感的储备金计算使用安全原语，如 `mulDiv`\n* 管理函数受访问控制\n* 存在紧急暂停功能并经过测试\n* 在生产前运行静态分析和模糊测试\n\n## 审计工具\n\n```bash\npip install slither-analyzer\nslither . --exclude-dependencies\n\nechidna-test . --contract YourAMM --config echidna.yaml\n\nforge test --fuzz-runs 10000\n```\n","# DeFi AMM 安全\n\nSolidity AMM 合约、LP 金库和交换函数的关键漏洞模式及强化实现。\n\n## 适用场景\n\n* 编写或审计 Solidity AMM 或流动性池合约\n* 实现持有代币余额的交换、存款、提款、铸造或销毁流程\n* 审查任何在份额或储备金计算中使用 `token.balanceOf(address(this))` 的合约\n* 向 DeFi 协议添加费用设置器、暂停器、预言机更新或其他管理功能\n\n## 工作原理\n\n将其作为检查清单加模式库使用。对照以下类别审查每个用户入口点，并优先使用强化示例而非自行编写的变体。\n\n## 执行安全\n\n本技能中的 shell 命令是本地审计示例。仅在受信任的代码检出或一次性沙箱中运行，不要将不受信任的合约名称、路径、RPC URL、私钥或用户提供的标志拼接到 shell 命令中。在安装工具或运行可能消耗大量本地或付费资源的长时间模糊测试\u002F静态分析任务前，请先询问。\n\n切勿在命令示例、日志或报告中包含机密信息、私钥、助记词、API 令牌或主网签名凭证。\n\n## 示例\n\n### 重入攻击：强制遵循 CEI 顺序\n\n存在漏洞：\n\n```solidity\nfunction withdraw(uint256 amount) external {\n    require(balances[msg.sender] >= amount);\n    token.transfer(msg.sender, amount);\n    balances[msg.sender] -= amount;\n}\n```\n\n安全：\n\n```solidity\nimport {ReentrancyGuard} from \"@openzeppelin\u002Fcontracts\u002Futils\u002FReentrancyGuard.sol\";\nimport {SafeERC20} from \"@openzeppelin\u002Fcontracts\u002Ftoken\u002FERC20\u002Futils\u002FSafeERC20.sol\";\n\nusing SafeERC20 for IERC20;\n\nfunction withdraw(uint256 amount) external nonReentrant {\n    require(balances[msg.sender] >= amount, \"Insufficient\");\n    balances[msg.sender] -= amount;\n    token.safeTransfer(msg.sender, amount);\n}\n```\n\n当存在经过验证的库时，不要自行编写防护措施。\n\n### 捐赠或通胀攻击\n\n直接使用 `token.balanceOf(address(this))` 进行份额计算，会让攻击者通过向合约发送代币（绕过预期路径）来操纵分母。\n\n```solidity\n\u002F\u002F Vulnerable\nfunction deposit(uint256 assets) external returns (uint256 shares) {\n    shares = (assets * totalShares) \u002F token.balanceOf(address(this));\n}\n```\n\n```solidity\n\u002F\u002F Safe\nuint256 private _totalAssets;\n\nfunction deposit(uint256 assets) external nonReentrant returns (uint256 shares) {\n    uint256 balBefore = token.balanceOf(address(this));\n    token.safeTransferFrom(msg.sender, address(this), assets);\n    uint256 received = token.balanceOf(address(this)) - balBefore;\n\n    shares = totalShares == 0 ? received : (received * totalShares) \u002F _totalAssets;\n    _totalAssets += received;\n    totalShares += shares;\n}\n```\n\n跟踪内部会计并衡量实际收到的代币。\n\n### 预言机操纵\n\n现货价格可通过闪电贷操纵。优先使用 TWAP。\n\n```solidity\nuint32[] memory secondsAgos = new uint32[](2);\nsecondsAgos[0] = 1800;\nsecondsAgos[1] = 0;\n(int56[] memory tickCumulatives,) = IUniswapV3Pool(pool).observe(secondsAgos);\nint24 twapTick = int24(\n    (tickCumulatives[1] - tickCumulatives[0]) \u002F int56(uint56(30 minutes))\n);\nuint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(twapTick);\n```\n\n### 滑点保护\n\n每个交换路径都需要调用者提供的滑点和截止时间。\n\n```solidity\nfunction swap(\n    uint256 amountIn,\n    uint256 amountOutMin,\n    uint256 deadline\n) external returns (uint256 amountOut) {\n    require(block.timestamp \u003C= deadline, \"Expired\");\n    amountOut = _calculateOut(amountIn);\n    require(amountOut >= amountOutMin, \"Slippage exceeded\");\n    _executeSwap(amountIn, amountOut);\n}\n```\n\n### 安全的储备金计算\n\n```solidity\nimport {FullMath} from \"@uniswap\u002Fv3-core\u002Fcontracts\u002Flibraries\u002FFullMath.sol\";\n\nuint256 result = FullMath.mulDiv(a, b, c);\n```\n\n对于大型储备金计算，当存在溢出风险时，避免使用简单的 `a * b \u002F c`。\n\n### 管理控制\n\n```solidity\nimport {Ownable2Step} from \"@openzeppelin\u002Fcontracts\u002Faccess\u002FOwnable2Step.sol\";\n\ncontract MyAMM is Ownable2Step {\n    function setFee(uint256 fee) external onlyOwner { ... }\n    function pause() external onlyOwner { ... }\n}\n```\n\n所有权转移应优先使用显式接受，并对每个特权路径设置门控。\n\n## 安全检查清单\n\n* 暴露于重入攻击的入口点使用 `nonReentrant`\n* 遵循 CEI 顺序\n* 份额计算不依赖原始的 `balanceOf(address(this))`\n* ERC-20 转账使用 `SafeERC20`\n* 存款衡量实际收到的代币\n* 预言机读取使用 TWAP 或其他抗操纵源\n* 交换需要 `amountOutMin`和`deadline`\n* 对溢出敏感的储备金计算使用安全原语，如 `mulDiv`\n* 管理函数受访问控制\n* 存在紧急暂停功能并经过测试\n* 在生产前运行静态分析和模糊测试\n\n## 审计工具\n\n```bash\npip install slither-analyzer\nslither . --exclude-dependencies\n\nechidna-test . --contract YourAMM --config echidna.yaml\n\nforge test --fuzz-runs 10000\n```\n",{"name":5,"origin":24,"version":25,"description":7},"ECC direct-port adaptation","1.0.0","master","d6ca01da0f24a3b0e26e4a8b7b66cbd25d429f5d","web-assets\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fdefi-amm-security",0,"https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills","https:\u002F\u002Fgithub.com\u002FSriramGandhiS","https:\u002F\u002Fsriram.website\u002F","Curious guy who keeps tinkering until something works","2026-05-20 16:21:34",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add SriramGandhiS\u002FSkills --skill defi-amm-security",{"tool":41,"command":42},"bunx","bunx skills add SriramGandhiS\u002FSkills --skill defi-amm-security",{"tool":44,"command":45},"pnpm","pnpm dlx skills add SriramGandhiS\u002FSkills --skill defi-amm-security","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fdefi-amm-security\u002FSKILL.md",true,[],[50,57,62,68,75,82],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M732609EPJWV13PVTX3GT4TM","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":58,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7325XM47AGWB6K6C4VXKE6B","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7325WP6DES69JKC840VMFEP","verification-loop","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7325TFQF1DZTQ6J3WGQQ1VR","tdd-workflow","Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Ftdd-workflow\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7325RGV9AY9PK92D2V8KKPW","strategic-compact","Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fstrategic-compact\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7325MZC28SE86E7NMCNEFS4","security-review","Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment\u002Fsensitive features. Provides comprehensive security checklist and patterns.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fsecurity-review\u002FSKILL.md",[],[]]