agents/skills/aptos/economic-design-audit/SKILL.md
Trigger Pattern MONETARY_PARAMETER flag (required) - Inject Into Breadth agents (merged via M4 hierarchy)
npx skillsauth add plamentsv/plamen economic-design-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Trigger Pattern: MONETARY_PARAMETER flag (required) Inject Into: Breadth agents (merged via M4 hierarchy) Purpose: Analyze admin-settable economic parameters (fees, rates, thresholds, emission schedules) for boundary violations, invariant breaks, interaction extremes, and fee formula correctness
For every monetary parameter setter (rate, rebase, supply, mint, burn, emission, inflation, peg, price cap/floor, fee, reward rate) in the protocol:
| Parameter | Setter Function | Min Value | Max Value | Enforced? | Impact at Min | Impact at Max | |-----------|----------------|-----------|-----------|-----------|---------------|---------------| | {param} | {set_fn} | {min} | {max} | YES/NO | {impact} | {impact} |
For each parameter: substitute min and max into ALL consuming functions. Tag: [BOUNDARY:param=val -> outcome]
Aptos-specific checks:
assert!() in the setter? If not, admin can set any value within the type range (u64::MAX, u128::MAX)u64 or u128 for monetary values? Check for overflow at max values.List all economic invariants the protocol must maintain:
| Invariant | Parameters Involved | Can Admin Break It? | Functions That Assume It | |-----------|-------------------|--------------------|-----------------------| | total_supply == sum(all_balances) | mint/burn params | YES/NO | {fn list} | | fees < principal | fee_rate | YES/NO | {fn list} | | collateral_ratio >= min_ratio | ratio_param | YES/NO | {fn list} | | rewards_distributed <= rewards_pool | emission_rate | YES/NO | {fn list} |
For each setter: can changing this parameter break an invariant that user-facing functions depend on? If yes -> finding.
Aptos-specific invariants:
FungibleAsset total supply tracking via supply() must match minted - burnedFor protocols with multiple monetary parameters that interact:
| Parameter A | Parameter B | Interaction | Can A*B Produce Extreme Output? | |-------------|-------------|-------------|-------------------------------| | {param_a} | {param_b} | {relationship} | YES/NO: {at what values} |
Check: can two independently-valid parameter settings combine to create an extreme or invalid economic state? (Rule 14 constraint coherence)
Examples:
For every fee-related computation (fee calculation, fee deduction, fee distribution):
Pick 3 representative fee rates (e.g., 1% = 100 BPS, 5% = 500 BPS, 10% = 1000 BPS) and trace through the actual code formula:
| Fee Param | Value | Formula | Input Amount | Expected Output | Actual Output | Match? | |-----------|-------|---------|-------------|----------------|---------------|--------| | {fee_bps} | 100 | {code formula} | 1_000_000_00 (1e8) | {expected} | {computed} | YES/NO | | {fee_bps} | 500 | {code formula} | 1_000_000_00 (1e8) | {expected} | {computed} | YES/NO | | {fee_bps} | 1000 | {code formula} | 1_000_000_00 (1e8) | {expected} | {computed} | YES/NO |
Tag: [BOUNDARY:fee_bps={val} -> effective_rate={computed_rate}]
Red flags:
amount * MAX / (MAX - fee) charges effective rate of fee/(MAX-fee), not fee/MAX. At 5% this is 5.26%, not 5%. Document whether this is intentional.amount * fee / 10000 always rounds DOWN (favoring user). Check if protocol uses (amount * fee + 9999) / 10000 for ceiling (favoring protocol).u64 at 1e8 scale (Aptos standard), do intermediate products overflow? u64::MAX = 18.4e18, so amount * fee overflows if both are large. Check for u128 intermediate or math::mul_div usage.For protocols with multiple fee types:
| Fee A | Fee B | A Output Feeds B Input? | Combined Effective Rate | Independent Rate Sum | Discrepancy? | |-------|-------|------------------------|------------------------|---------------------|-------------|
If the protocol uses share-based accounting (vaults, LP tokens):
For every fee computation, trace the base amount (the value the fee is computed on) through ALL subsequent code paths:
| Fee Site | Base Amount Variable | Modified After Fee? | Modified How | Fee Recomputed? | Overcharge? | |----------|---------------------|--------------------:|-------------|-----------------|-------------|
Methodology:
amount, deposit_amount)fee = amount * fee_rate / MAX, then amount is reduced to leftover (e.g., remaining allocation), the user paid fee on amount but only leftover was processed -- overcharge of fee * (1 - leftover/amount)For protocols with emission/inflation/rebase mechanics:
| Check | Value | Sustainable? | Impact if Unsustainable | |-------|-------|-------------|----------------------| | Max emission rate per day | {amount} | YES/NO | {impact} | | Max emission rate per year | {amount} | YES/NO | {impact} | | Supply cap exists? | YES/NO | N/A | {impact if no cap} | | Can cap be bypassed by param changes? | YES/NO | N/A | {how} | | Reward pool sufficient for emission schedule? | YES/NO | N/A | {what happens when depleted} |
Aptos-specific emission checks:
timestamp::now_seconds() for emission calculations? Verify time-based math is correct.{CONTRACTS} -- Move modules to analyze
{MONETARY_PARAMS} -- Admin-settable economic parameters
{FEE_FUNCTIONS} -- Functions containing fee calculations
{INVARIANTS} -- Expected economic invariants
{EMISSION_MECHANICS} -- Emission/inflation/rebase mechanics (if any)
**ID**: [ED-N]
**Severity**: [based on fund impact at boundary/extreme values]
**Step Execution**: checkmark1,2,3,4,5 | x(reasons) | ?(uncertain)
**Rules Applied**: [R10:Y, R14:Y]
**Location**: module::function:LineN
**Title**: [Parameter/invariant/fee] issue in [function] enables [attack/failure]
**Description**: [Specific economic design issue with concrete boundary values]
**Impact**: [Quantified impact at boundary conditions]
| Field | Required | Description | |-------|----------|-------------| | parameter_boundaries | yes | All monetary parameters with min/max analysis | | invariants | yes | Economic invariants and whether they can break | | fee_verification | yes | Fee formula verification at normal values | | interaction_matrix | yes | Parameter interaction analysis | | finding | yes | CONFIRMED / REFUTED / CONTESTED | | evidence | yes | Code locations with line numbers | | step_execution | yes | Status for each step |
| Section | Required | Completed? | Notes | |---------|----------|------------|-------| | 1. Parameter Boundary Analysis | YES | Y/N/? | | | 2. Economic Invariant Identification | YES | Y/N/? | | | 3. Rate/Supply Interaction Matrix | IF >1 monetary param | Y/N(N/A)/? | | | 4a. Fee Formula Verification (concrete examples) | IF fee parameters detected | Y/N(N/A)/? | | | 4b. Fee Interaction Matrix | IF multiple fee types | Y/N(N/A)/? | | | 4c. Fee Impact on Share Price | IF share-based accounting | Y/N(N/A)/? | | | 4d. Fee-Base Consistency | IF fee parameters detected | Y/N(N/A)/? | | | 5. Emission/Inflation Sustainability | IF emission/rebase detected | Y/N(N/A)/? | |
development
Prepare Solidity projects for a security audit — test coverage, test quality, NatSpec docs, code hygiene, dependency health, best-practice enforcement, deployment readiness, and project documentation checks. Generates a scored Audit Readiness Report and optionally runs static analysis. Trigger on: "prepare for audit", "audit readiness", "pre-audit check", "audit prep", "NatSpec check", or any request to review a Solidity codebase before a security review.
development
Launch the Plamen deterministic Web3 security audit pipeline
development
Run the Plamen smart-contract audit wizard in Codex
testing
Launch the Plamen deterministic L1 infrastructure audit pipeline