What does this skill do?

The AMM DeFi Security Skill provides a library of vulnerability patterns and hardened countermeasures for AMM contracts, liquidity pools, and swap flows in Solidity. It covers reentrancy, donation attacks, oracle manipulation, slippage protection, and administrator controls, integrating proven libraries such as OpenZeppelin and Uniswap to reduce the risk of exploits in production.

Recess and CEI Order
Check entry points that are vulnerable to reentrancy and apply the Checks-Effects-Interactions pattern using OpenZeppelin guards.
Donation Attacks
Replace the calculation of shares based on the crude oil balance sheet with internal accounting that measures the tokens actually received.
TWAP-Resistant Oracles
Replace spot prices that can be manipulated using flash loans with TWAP readings from Uniswap V3 or other reliable sources.
Slippage and Admin Controls
Require `amountOutMin` and `deadline` for each swap, and protect privileged functions with `Ownable2Step` and emergency pauses.

Usage examples

🔒 Recursion Audit
Check my AMM contract for reentrancy attacks and apply the CEI pattern to it using OpenZeppelin's ReentrancyGuard.
💰 Donation Protection
My deposit function uses `balanceOf(this)` to calculate shares. Review it and add internal accounting to prevent donation attacks.
📊 TWAP Oracle
I'm using the Uniswap spot price for my calculations. Replace it with the Uniswap V3 TWAP using a 30-minute window.
🛡️ Complete Checklist
Please run the complete security checklist on my liquidity pool contract before deploying to mainnet.

Features

CEI and ReentrancyGuard Patterns Apply the Checks-Effects-Interactions order and non-reentrant guards at all exposed entry points.
Internal Reserve Accounting It counts the tokens actually received in deposits rather than relying on the raw `balanceOf(address(this))` value.
Anti-manipulation TWAP oracles It integrates Uniswap V3 TWAP price feeds that are resistant to flash loans and spot market manipulation.
Mandatory slippage and deadline Requires `amountOutMin` and `deadline` in each swap to protect the caller against slippage.
Secure Administrator Controls Use Ownable2Step for explicit ownership transfer and emergency pauses in privileged functions.

Frequently asked questions

It is not required, but the skill recommends performing static analysis and fuzzing with Slither, Echidna, and Forge before deploying to mainnet. The skill includes the reference commands.
It relies on OpenZeppelin (ReentrancyGuard, SafeERC20, Ownable2Step) and Uniswap V3 (TWAP, FullMath, TickMath) as hardened, production-proven references.
It is optimized for AMM contracts, liquidity pools, and swap flows, but many patterns (re-entry, CEI, admin controls) are applicable to any Solidity contract.
No. The skill explicitly states that the analysis tools must be run in a sandbox or trusted checkout, without private keys or mainnet credentials.
AMM DeFi Security — Hard-Coded Patterns for Solidity Contracts

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.