# Build Safer DeFi Protocol Prototypes

DeFi contracts are difficult to design and secure. This skill provides Solidity starting points for staking, AMMs, governance, and flash loans, with validation guidance.

## Install

```bash
npx skillstore add sickn33/defi-protocol-templates
```

## Metadata

- Status: approved
- Slug: sickn33-defi-protocol-templates
- Skillstore revision: r2
- Version status: missing
- Tree hash: dc03c77116ea19ea66cd72f74394fbb5edea2f6972e0bf4bd072e77789d14ae5
- Author: sickn33
- GitHub username: sickn33
- License: MIT
- Repository: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/defi-protocol-templates
- Ref: f9e2c34b4f19c7f3e6b0a1e93227b5f77cc12526
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: confirmation\_required
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: scripts, external\_commands
- Quality score: 38
- Quality tier: warning
- Public page: https://skillstore.pages.dev/skills/sickn33-defi-protocol-templates
- Manifest: https://skillstore.pages.dev/api/skills/sickn33-defi-protocol-templates/manifest

## Capabilities

- Draft staking reward accounting with ERC20 token interfaces.
- Outline constant-product AMM liquidity and swap calculations.
- Create a governance token and basic proposal voting flow.
- Illustrate flash-loan provider and receiver callback structures.
- Recommend testing, monitoring, audits, timelocks, multisignature controls, and emergency stops.

## Use Cases

- Prototype a DeFi Contract: Adapt a staking or AMM example into an initial design for local testing.
- Compare Protocol Components: Review reward, liquidity, voting, and callback patterns before selecting an architecture.
- Plan a Security Review: Identify missing controls and create a hardening checklist before implementation.

## Prompt Templates

### Choose a Template

```
Explain which included template best fits [protocol idea]. List required inputs, key assumptions, and the first tests to write.
```

### Adapt a Staking Design

```
Adapt the staking example for [staking token] and [reward token]. Define reward funding, duration, withdrawal rules, and test cases without claiming production readiness.
```

### Review an AMM

```
Review the AMM template for slippage, token compatibility, reserve accounting, reentrancy, and economic attacks. Return prioritized changes and verification steps.
```

### Create a DeFi Threat Model

```
Create a threat model for [protocol design]. Cover trust boundaries, privileged roles, oracle risks, governance capture, token behavior, invariants, and incident controls.
```

## Limitations

- The examples are educational starting points, not audited production contracts.
- No lending contract is included despite lending references in the stated scope.
- OpenZeppelin imports and overrides may require changes for the selected dependency version.
- Templates omit important token compatibility, slippage, authorization, oracle, and governance protections.

## Best Practices

- Treat every template as a starting point and require independent security review before deployment.
- Add safe token transfers, explicit access control, slippage limits, timelocks, and emergency controls where appropriate.
- Test standard, fee-charging, rebasing, callback-enabled, and malicious token behavior against documented invariants.

## Anti Patterns

- Deploy the examples unchanged or describe them as audited contracts.
- Assume every ERC20 transfer succeeds or delivers the requested amount.
- Add protocol features before defining trust boundaries, economic invariants, and failure recovery.

## Security Audit

- Audited at: 2026-07-23T21:50:08.276\+00:00
- Summary: All 26 static findings are false positives caused by Solidity require statements and Markdown backticks, not dynamic loading, command execution, or reconnaissance. Semantic review found exploitable token-handling and receiver-authorization flaws, missing slippage protections, and a broken flash-loan repayment flow in examples described as production-ready.

## Stats

- Views: 99
- Downloads: 9
- Favorites: 0
- Popularity score: 0
