agents/skills/sui/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 economic design of monetary parameters in Sui Move protocols for boundary violations, invariant breaks, and fee formula errors
For every monetary parameter setter (rate, supply, mint, burn, emission, inflation, peg, price cap/floor, fee, reward rate) in the protocol:
Enumerate all admin-settable monetary parameters stored in shared config objects:
| Parameter | Setter Function | Required Cap | Min Value | Max Value | Enforced? | Impact at Min | Impact at Max | |-----------|----------------|-------------|-----------|-----------|-----------|---------------|---------------| | {param} | {module::set_param} | {AdminCap} | {min} | {max} | {YES/NO} | {trace impact} | {trace impact} |
For each parameter: substitute min and max into ALL consuming functions. Tag: [BOUNDARY:param=val -> outcome]
Sui-specific: Parameters are typically stored in shared objects (e.g., Config, Registry, Pool). Check:
assert!(value >= MIN && value <= MAX))force_set function)Move arithmetic model: Move uses unsigned integers only (u8, u64, u128, u256). No native BPS type.
u64 max: 18,446,744,073,709,551,615 (~1.8e19). SUI has 9 decimals, so max u64 represents ~18.4 billion SUI.amount * fee_bps where amount is large: e.g., 1e18 * 10000 = 1e22 which OVERFLOWS u64. Check for u128 intermediate casts.List all economic invariants the protocol must maintain:
| Invariant | Parameters Involved | Can Admin Break It? | Functions That Assume It | |-----------|-------------------|--------------------|-----------------------| | total_supply == sum(user_balances) | supply, balances | {YES/NO via mint/burn cap} | {list} | | fee_rate <= MAX_FEE | fee_rate, MAX_FEE | {YES/NO} | {list} | | collateral_value >= debt_value | collateral_ratio, prices | {YES/NO via param change} | {list} |
For each setter: can changing this parameter break an invariant that user-facing functions depend on? If yes -> finding.
Sui invariant patterns:
TreasuryCap<T> controls minting -- does unlimited minting break a peg or backing invariant?balance::value(&pool.token_a) * balance::value(&pool.token_b) >= k (AMM invariant)total_shares * price_per_share <= total_assets (no unbacked shares)For protocols with multiple monetary parameters that interact:
| Parameter A | Parameter B | Interaction | Can A*B Produce Extreme Output? | |-------------|-------------|-------------|--------------------------------| | {reward_rate} | {total_supply} | reward_per_token = rate / supply | YES if supply -> 0 while rate > 0 | | {fee_rate_A} | {fee_rate_B} | compound fee = A then B | YES if both at max -> excessive total fee | | {mint_cap} | {burn_rate} | net supply = minted - burned | YES if mint >> burn -> inflation spiral |
Check: can two independently-valid parameter settings combine to create an extreme or invalid economic state? (Rule 14 constraint coherence)
Sui-specific interactions:
TreasuryCap mint + admin fee rate: can mint + fee combine to extract more than pool holds?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_000 | {expected} | {computed} | YES/NO | | {fee_bps} | 500 | {code formula} | 1_000_000_000 | {expected} | {computed} | YES/NO | | {fee_bps} | 1000 | {code formula} | 1_000_000_000 | {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 / MAX rounds down (user-favorable). Is (amount * fee + MAX - 1) / MAX used for protocol-favorable rounding?u64 math, do intermediate products overflow? Sui Move aborts on overflow -- is u128 used for intermediate calculations? Check for (amount as u128) * (fee as u128) / (MAX as u128) patterns.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:
| Emission Param | Max Rate | Over 1 Day | Over 1 Week | Over 1 Year | Sustainable? | |---------------|---------|-----------|------------|------------|-------------| | {reward_rate} | {max} | {computed} | {computed} | {computed} | {analysis} |
TreasuryCap or explicit checks? Can it be bypassed by parameter changes?**ID**: [ED-N]
**Severity**: [based on fund impact and parameter reachability]
**Step Execution**: check1,2,3,4,5 | x(reasons) | ?(uncertain)
**Rules Applied**: [R10:check, R14:check]
**Location**: module::function:LineN
**Title**: [Parameter/invariant issue] in [function] enables [impact]
**Description**: [Specific economic design issue with parameter trace]
**Impact**: [Quantified impact at boundary values]
{CONTRACTS} -- Move modules to analyze
{CONFIG_OBJECTS} -- Shared config/registry objects
{MONETARY_PARAMS} -- Admin-settable monetary parameters
{FEE_FUNCTIONS} -- Functions computing or deducting fees
{INVARIANTS} -- Known economic invariants
{EMISSION_PARAMS} -- Emission/inflation parameters
{CAP_TYPES} -- Capability types required for parameter changes
| Field | Required | Description | |-------|----------|-------------| | parameter_boundaries | yes | All monetary params with min/max analysis | | invariants | yes | Economic invariants and breakability | | interaction_matrix | yes | Cross-parameter interactions | | fee_verification | yes | Fee formula correctness at normal values | | finding | yes | CONFIRMED / REFUTED / CONTESTED | | evidence | yes | Code locations with line numbers | | step_execution | yes | Status for each step |
| Section | Required | Completed? | |---------|----------|------------| | 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)/? | | 4. Fee Formula Verification at Normal Values | IF fee parameters detected | 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