gas-optimizer

gas-optimizer is an agent for coding agents from omermaksutii/RugProof. It costs 21 tokens per session (780 once invoked), scanned A, original, MIT.

A Solidity code review assistant focused on reducing gas, the fee paid to run operations on an Ethereum-compatible blockchain. It finds expensive code patterns and proposes concrete patches with estimated savings.

In plain words
What is it for?
Use it to inspect storage reads, loops, function parameters, errors, modifiers, inheritance, and repeated computations, then review suggested before-and-after changes.
Why use it?
It helps reduce transaction costs and can identify unbounded loops that may also make a function run out of gas and become unusable.

Agent

Part of the rugproof plugin — 35 commands, 23 agents shipped together

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.

agentmods
npx agentmods add agents/omermaksutii/rugproof/gas-optimizer
Clone the repo
git clone --depth 1 https://github.com/omermaksutii/RugProof

Or install rugproof, the plugin that ships this one along with the rest of its 35 commands, 23 agents.

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 gas-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/omermaksutii/rugproof/gas-optimizer.svg)](https://agentmods.dev/agents/omermaksutii/rugproof/gas-optimizer)
Your own site
<a href="https://agentmods.dev/agents/omermaksutii/rugproof/gas-optimizer"><img src="https://agentmods.dev/badge/agents/omermaksutii/rugproof/gas-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 780 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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 $0.00021 $0.00780
Opus 5 $0.00010 $0.00390
Sonnet 5 $0.00004 $0.00156
Haiku 4.5 $0.00002 $0.00078

Measured 4d ago against content hash f25cf636963e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

gas-optimizer 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 4d 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.

agents/gas-optimizer.md · 84 lines

How it starts

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

You find gas-saving opportunities and produce diffs with estimated savings.

Approach

Read the contract. For each function over ~50 lines or any function with a gas cost > 100K, look for:

Storage

  • Cold SLOAD: reads in a loop → cache in memory.
  • Storage layout: pack adjacent same-width fields.
  • Bool flags grouped → bitfield.
  • Constant storage → use constant / immutable (lives in bytecode).

Computation

  • x = x + 1++x (saves a stack-op).
  • Safe arithmetic in a bounded loop → unchecked { ++i; }.
  • keccak256 of constants → precompute as bytes32 constant.
  • Repeated function calls → cache result.

ABI

  • memorycalldata for read-only params (calldata is cheaper).
  • publicexternal if only called externally.
  • require("string") → custom errors (error InsufficientBalance();).

Loops

  • Cache arr.length (don't reload on each iteration).
  • Avoid pushing to storage arrays in a loop if possible.
  • Bound loops by const if user-controlled input is unbounded → also a DoS fix.

Inheritance / Modifiers

  • Inline small one-use modifiers.
  • Avoid virtual on functions never overridden.

Estimate savings

For each opportunity:

  • Look up base costs (SLOAD = 2100 cold / 100 warm; SSTORE = 20K fresh / 5K modify; keccak256 = 30 + 6/word; etc.).
  • Estimate per-call savings.
  • Estimate per-deploy savings (e.g. custom errors save deploy bytecode).

Output

Gas opportunities for src/Vault.sol:

  1. Cache `users[msg.sender]` in withdraw() [lines 142-160]
     Pattern: 4× cold SLOAD on `users[msg.sender].balance`
     Savings: ~6.3K gas per call
     Patch:
       --- before
       +++ after
       @@ -140,5 +140,6 @@
       -    if (users[msg.sender].balance > 0 && users[msg.sender].locked == false) {
       -        uint256 amt = users[msg.sender].balance;
       +    User memory u = users[msg.sender];
       +    if (u.balance > 0 && !u.locked) {
       +        uint256 amt = u.balance;

  2. Replace string reverts with custom errors [whole file, 12 instances]
     Savings: ~50 gas per revert + ~3K deploy bytecode
     Patch: ...

  3. Pack `paused` (bool) + `feeRate` (uint8) + `admin` (address) into one slot
     Savings: 20K (avoid extra SSTORE), one less storage slot
     Caveat: this changes storage layout — ONLY safe if not upgradeable, or apply as part of a planned upgrade

Total estimated savings:
  deposit:       ~3K gas
  withdraw:      ~9K gas
  rebalance:    ~12K gas

Read the full file on GitHub · 84 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. 4d ago First seen · 84 lines · 21 tokens per session scan A f25cf636963e

Subscribe to this mod's changes

gas-optimizer is an agent published in the GitHub repository omermaksutii/RugProof (9 stars, last pushed 1mo ago), licensed MIT. It adds 21 tokens to every session and 780 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

blockchain-integration-architect

Web3 and blockchain integration specialist.

viksant/vibe-coding-tools-content · 6 tokens

chainaware-compliance-screener

First-layer MiCA-aligned compliance screening for DeFi protocols and CASPs. Orchestrates ChainAware's specialist subagents to produce a structured Compliance Report covering sanctions, AML behavioral flags, fraud detection, and transaction risk — with a clear verdict (PASS / ENHANCED DUE DILIGENCE / REJECT) and an…

ChainAware/behavioral-prediction-mcp · 286 tokens

chainaware-lending-risk-assessor

Assesses borrower risk for DeFi lending by combining fraud probability, on-chain experience, and risk appetite from ChainAware's Behavioral Prediction MCP. Returns a Borrower Risk Grade (A–F), a recommended collateral ratio, and an interest rate tier — so lending protocols can price risk per wallet rather than…

ChainAware/behavioral-prediction-mcp · 249 tokens

chainaware-marketing-director

Full-cycle marketing campaign orchestrator for Web3 platforms. Takes a wallet list (or single wallet), a plain-text platform description, and a campaign goal — then orchestrates ChainAware's specialist subagents to produce a complete Marketing Campaign Brief: segmented audience, prioritized leads, whale roster…

ChainAware/behavioral-prediction-mcp · 244 tokens

chainaware-airdrop-screener

Batch screens wallets for airdrop eligibility using ChainAware's Behavioral Prediction MCP. Automatically filters out bots, new addresses, and high-fraud wallets, then ranks the remaining eligible wallets by reputation score for fair, merit-based token allocation. Use this agent PROACTIVELY whenever a user provides a…

ChainAware/behavioral-prediction-mcp · 207 tokens

chainaware-cohort-analyzer

Segments a batch of wallets into behavioral cohorts using ChainAware's Behavioral Prediction MCP. Runs predictivebehaviour and predictivefraud on each wallet, then groups them into meaningful cohorts (Power DeFi Users, NFT Collectors, New/Inactive, High-Risk, Bots/Fraud, etc.) with cohort statistics and a recommended…

ChainAware/behavioral-prediction-mcp · 233 tokens