defi-amm-security

defi-amm-security is a skill for Claude Code, Codex from majiang213/OpenClaw-MAS. It costs 48 tokens per session (1,123 once invoked), scanned A, a copy of defi-amm-security, MIT.

A security checklist and code-pattern library for Solidity contracts that run automated market makers, liquidity pools, swaps, deposits, and withdrawals. Automated market makers are exchanges that set prices from pool balances instead of an order book.

In plain words
What is it for?
Use it when writing or auditing pool and swap contracts, share calculations, oracle updates, fees, pause controls, and other administrator functions.
Why use it?
It helps find common ways these contracts can lose funds or miscalculate balances, including reentrancy, price manipulation, unsafe token transfers, and integer-math errors.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or auditing pool and swap contracts, share calculations, oracle updates, fees, pause controls, and other administrator functions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/majiang213/openclaw-mas/defi-amm-security
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add majiang213/OpenClaw-MAS --skill defi-amm-security
Clone the repo
git clone --depth 1 https://github.com/majiang213/OpenClaw-MAS

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for defi-amm-security

README.md
[![agentmods](https://agentmods.dev/badge/skills/majiang213/openclaw-mas/defi-amm-security/github.svg)](https://agentmods.dev/skills/majiang213/openclaw-mas/defi-amm-security)
Your own site
<a href="https://agentmods.dev/skills/majiang213/openclaw-mas/defi-amm-security"><img src="https://agentmods.dev/badge/skills/majiang213/openclaw-mas/defi-amm-security/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for defi-amm-security

Your own site · 80×15
<a href="https://agentmods.dev/skills/majiang213/openclaw-mas/defi-amm-security"><img src="https://agentmods.dev/badge/skills/majiang213/openclaw-mas/defi-amm-security.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,123 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 86% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00048 $0.01123
Opus 5 $0.00024 $0.00562
Sonnet 5 $0.00010 $0.00225
Haiku 4.5 $0.00005 $0.00112

Measured 11d ago against content hash 0d3fd55d9536, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

defi-amm-security scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

86% identical to defi-amm-security — 34 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

ecc-skills/defi-amm-security/SKILL.md · 161 lines

How it starts

The opening of the file, as written. The whole thing — 161 lines — stays where its author put it; the contents beside it link to each section on GitHub.

DeFi AMM Security

Critical vulnerability patterns and hardened implementations for Solidity AMM contracts, LP vaults, and swap functions.

When to Use

  • Writing or auditing a Solidity AMM or liquidity-pool contract
  • Implementing swap, deposit, withdraw, mint, or burn flows that hold token balances
  • Reviewing any contract that uses token.balanceOf(address(this)) in share or reserve math
  • Adding fee setters, pausers, oracle updates, or other admin functions to a DeFi protocol

How It Works

Use this as a checklist-plus-pattern library. Review every user entrypoint against the categories below and prefer the hardened examples over hand-rolled variants.

Examples

Reentrancy: enforce CEI order

Vulnerable:

function withdraw(uint256 amount) external {
    require(balances[msg.sender] >= amount);
    token.transfer(msg.sender, amount);
    balances[msg.sender] -= amount;
}

Safe:

import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

using SafeERC20 for IERC20;

function withdraw(uint256 amount) external nonReentrant {
    require(balances[msg.sender] >= amount, "Insufficient");
    balances[msg.sender] -= amount;
    token.safeTransfer(msg.sender, amount);
}

Do not write your own guard when a hardened library exists.

Donation or inflation attacks

Using token.balanceOf(address(this)) directly for share math lets attackers manipulate the denominator by sending tokens to the contract outside the intended path.

// Vulnerable
function deposit(uint256 assets) external returns (uint256 shares) {
    shares = (assets * totalShares) / token.balanceOf(address(this));
}
// Safe
uint256 private _totalAssets;

function deposit(uint256 assets) external nonReentrant returns (uint256 shares) {
    uint256 balBefore = token.balanceOf(address(this));
    token.safeTransferFrom(msg.sender, address(this), assets);
    uint256 received = token.balanceOf(address(this)) - balBefore;

    shares = totalShares == 0 ? received : (received * totalShares) / _totalAssets;
    _totalAssets += received;
    totalShares += shares;
}

Read the full file on GitHub · 161 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 161 lines · 48 tokens per session scan A 0d3fd55d9536

Subscribe to this mod's changes

defi-amm-security is a skill published in the GitHub repository majiang213/OpenClaw-MAS (5 stars, last pushed 5mo ago), licensed MIT. It adds 48 tokens to every session and 1,123 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. It is 86% identical to defi-amm-security, differing in 34 lines, and is treated as a copy.

Related

Other skills, from other repositories

blockchain-web3-expert

Expert guide for Web3 and blockchain dApp integration — viem, wagmi v2, ethers.js v6, RainbowKit, smart contract interactions, and EVM wallet state / Panduan ahli integrasi Web3 dan blockchain.

roedyrustam/vibes-plug · 54 tokens

crypto-skill-creator

Step-by-step guide for creating enriched CryptoSkills agent skills. Use when building new protocol skills, contributing to the directory, or understanding the enriched skill pattern. Covers SKILL.md structure, YAML frontmatter, examples, docs, resources, templates, marketplace registration, and validation. Triggers…

aomi-labs/skills · 85 tokens

goat

GOAT (Great Onchain Agent Toolkit) — 200+ protocol integrations across 30+ chains. Tool creation, framework adapters (AI SDK/LangChain/Eliza), DeFi actions (swap/bridge/transfer), wallet management, and modular plugin architecture for building onchain AI agents.

aomi-labs/skills · 63 tokens

x402

HTTP 402 payment protocol for AI agent commerce — three-actor model (Client, Resource Server, Facilitator), ERC-3009 transferWithAuthorization, server middleware (@x402/express), client patterns in TypeScript and Python, facilitator integration, agent-to-agent payments, pricing strategies, and replay protection. Works…

aomi-labs/skills · 84 tokens

brian-api

Brian API — natural language to executable Web3 transactions. Convert text intents into swap, bridge, transfer, deposit, withdraw, and borrow transactions across multiple chains. REST API, LangChain integration, and knowledge queries for DeFi protocol data.

aomi-labs/skills · 52 tokens

coinbase-agentkit

Coinbase AgentKit — build AI agents with onchain capabilities. Wallet creation/management, token transfers, swaps, contract deployment, NFT minting, and ENS registration. Framework integrations with LangChain and Vercel AI SDK. Supports Base, Ethereum, Arbitrum, and Polygon.

aomi-labs/skills · 63 tokens