SKILL

defi-amm-security

Security checklist for Solidity AMM contracts, liquidity pools, and swap flows. Covers reentrancy, CEI ordering, donation or inflation attacks, oracle manipulation, slippage, admin controls, and integer math.

Machine translation
Read the original Chinese text

Solidity AMM 合约、流动性池和交换流程的安全检查清单。涵盖重入、CEI 排序、捐赠或通胀攻击、预言机操纵、滑点、管理员控制和整数数学。

Target: Cloud, operations & security. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Chinese text

Topics in the source

  • DeFi AMM 安全
  • 适用场景
  • 工作原理
  • 执行安全
  • 示例
  • 重入攻击:强制遵循 CEI 顺序
  • 捐赠或通胀攻击
  • 预言机操纵

Solidity AMM 合约、LP 金库和交换函数的关键漏洞模式及强化实现。 编写或审计 Solidity AMM 或流动性池合约 实现持有代币余额的交换、存款、提款、铸造或销毁流程 审查任何在份额或储备金计算中使用 token.balanceOf(address(this)) 的合约 向 DeFi 协议添加费用设置器、暂停器、预言机更新或其他管理功能 将其作为检查清单加模式库使用。对照以下类别审查每个用户入口点,并优先使用强化示例而非自行编写的变体。 本技能中的 shell 命令是本地审计示例。仅在受信任的代码检出或一次性沙箱中运行,不要将不受信任的合约名称、路径、RPC URL、私钥或用户提供的标志拼接到 shell 命令中。在安装工具或运行可能消耗大量本地或付费资源的长时间模糊测试/静态分析任务前,请先询问。 切勿在命令示例、日志或报告中包含机密信息、私钥、助记词、API 令牌或主网签名凭证。 存在漏洞: 安全: 当存在经过验证的库时,不要自行编写防护措施。 直接使用 token.balanceOf(address(this)) 进行份额计算,会让攻击者通过向合约发送代币(绕过预期路径)来操纵分母。 跟踪内部会计并衡量实际收到的代币。 现货价格可通过闪电贷操纵。优先使用 TWAP。 每个交换路径都需要调用者提供的滑点和截止时间。 对于大型储备金计算,当存在溢出风险时,避免使用简单的 a b / c。 所有权转移应优先使用显式接受,并对每个特权路径设置门控。 暴露于重入攻击的入口点使用 nonReentrant 遵循 CEI 顺序 份额计算不依赖原始的 balanceOf(address(this)) ERC-20 转账使用 SafeERC20 存款衡量实际收到的代币 预言机读取使用 TWAP 或其他抗操纵源 交换需要 amountOutMin 和 deadline 对溢出敏感的储备金计算使用安全原语,如 mulDiv 管理函数受访问控制 存在紧急暂停功能并经过测试 在生产前运行静态分析和模糊测试

Source repository
affaan-m/ECC
Source file
docs/zh-CN/skills/defi-amm-security/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:50.310Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.