⚠️ CRITICAL: This application handles user funds. All contributions must follow strict security practices.
Thank you for your interest in contributing to Sweep! This guide will help you get started.
- Code of Conduct
- Getting Started
- Development Workflow
- Pull Request Process
- Code Style
- Commit Conventions
- Security Guidelines
- Review Checklist
- Be respectful and inclusive
- Accept constructive criticism gracefully
- Focus on what is best for the community
- Show empathy towards other contributors
- Harassment, discrimination, or offensive comments
- Publishing others' private information
- Trolling or insulting/derogatory comments
- Any conduct inappropriate in a professional setting
- Read the DEVELOPMENT.md guide
- Set up your local environment
- Familiarize yourself with the codebase
- Check GitHub Issues
- Look for
good first issuelabels for beginner-friendly tasks - Check
help wantedfor issues needing contributors - Review
prioritylabels for important work
| Label | Description |
|---|---|
bug |
Something isn't working |
enhancement |
New feature or improvement |
good first issue |
Beginner-friendly |
help wanted |
Extra attention needed |
security |
Security-related issue |
contracts |
Smart contract related |
frontend |
Frontend application |
backend |
API and services |
# Fork the repository on GitHub, then:
git clone https://github.com/YOUR_USERNAME/sweep.git
cd sweep
git remote add upstream https://github.com/nirholas/sweep.git# Update main
git checkout main
git pull upstream main
# Create feature branch
git checkout -b feat/your-feature-name| Prefix | Usage |
|---|---|
feat/ |
New feature |
fix/ |
Bug fix |
docs/ |
Documentation |
refactor/ |
Code refactoring |
test/ |
Test additions/updates |
chore/ |
Maintenance tasks |
Examples:
feat/add-solana-supportfix/quote-expiry-validationdocs/update-api-reference
# Install dependencies
npm install
# Start development server
npm run dev
# Run tests continuously
npm run test:watch# Run all tests
npm test
# Run specific test suite
npm run test:unit
npm run test:integration
npm run test:api
# Check coverage
npm run test:coverage
# Type check
npm run typecheck
# Lint
npm run lint# Stage changes
git add .
# Commit with conventional message
git commit -m "feat: add Solana dust scanning support"# Push to your fork
git push origin feat/your-feature-name
# Create PR via GitHub UI- Code follows project style guidelines
- All tests pass (
npm test) - Coverage thresholds met (
npm run test:coverage) - No TypeScript errors (
npm run typecheck) - No lint errors (
npm run lint) - Documentation updated if needed
- Commit messages follow conventions
## Description
Brief description of changes.
## Type of Change
- [ ] Bug fix (non-breaking change fixing an issue)
- [ ] New feature (non-breaking change adding functionality)
- [ ] Breaking change (fix or feature causing existing functionality to change)
- [ ] Documentation update
## Related Issues
Closes #123
## Testing
Describe tests added or modified.
## Checklist
- [ ] Tests pass locally
- [ ] Code follows style guidelines
- [ ] Self-reviewed my code
- [ ] Commented complex code
- [ ] Updated documentation
- [ ] No security vulnerabilities introduced- Automated Checks - CI runs tests, linting, and type checking
- Code Review - Maintainers review the code
- Feedback - Address any requested changes
- Approval - At least one maintainer must approve
- Merge - Maintainer merges to main
- Simple fixes: 1-2 days
- Features: 3-5 days
- Complex changes: 1-2 weeks
// ✅ Good: Explicit types, clear naming
interface SweepResult {
sweepId: string;
status: "pending" | "confirmed" | "failed";
txHash: string;
}
async function executeSweep(params: SweepParams): Promise<SweepResult> {
// Implementation
}
// ❌ Bad: Implicit types, unclear naming
async function doIt(p) {
// What is this?
}// ✅ Good: Single responsibility, documented
/**
* Calculates the net value after fees for a sweep operation.
* @param grossValue - Total USD value of tokens
* @param gasCost - Estimated gas cost in USD
* @param protocolFee - Protocol fee in USD
* @returns Net value in USD (minimum 0)
*/
function calculateNetValue(
grossValue: number,
gasCost: number,
protocolFee: number
): number {
const net = grossValue - gasCost - protocolFee;
return Math.max(0, net);
}
// ❌ Bad: Multiple responsibilities, no documentation
function calc(a, b, c, d, e, f) {
// What does this do?
return a - b - c + d * e / f;
}// ✅ Good: Specific error types, context
class QuoteExpiredError extends Error {
constructor(public quoteId: string, public expiredAt: Date) {
super(`Quote ${quoteId} expired at ${expiredAt.toISOString()}`);
this.name = "QuoteExpiredError";
}
}
try {
await executeSweep(params);
} catch (error) {
if (error instanceof QuoteExpiredError) {
return { success: false, error: "Quote expired, please request a new one" };
}
throw error;
}
// ❌ Bad: Generic errors, no context
try {
await doStuff();
} catch (e) {
console.log("error");
}// ✅ Good: Organized imports
// 1. External packages
import { Hono } from "hono";
import { eq } from "drizzle-orm";
// 2. Internal absolute imports
import { getDb } from "@/db";
import { logger } from "@/utils/logger";
// 3. Relative imports
import { validateQuote } from "./validation";
import type { SweepParams } from "./types";// ✅ Good file structure
// 1. Imports
import { ... } from "...";
// 2. Types/Interfaces
interface MyInterface { ... }
// 3. Constants
const MAX_RETRIES = 3;
// 4. Helper functions (private)
function helperFunction() { ... }
// 5. Main exports
export function mainFunction() { ... }
export class MainClass { ... }We use Conventional Commits.
<type>(<scope>): <description>
[optional body]
[optional footer]
| Type | Description |
|---|---|
feat |
New feature |
fix |
Bug fix |
docs |
Documentation only |
style |
Formatting, missing semicolons, etc. |
refactor |
Code change that neither fixes a bug nor adds a feature |
perf |
Performance improvement |
test |
Adding or updating tests |
chore |
Build process or auxiliary tool changes |
ci |
CI/CD configuration changes |
revert |
Revert a previous commit |
| Scope | Description |
|---|---|
api |
API routes and middleware |
contracts |
Smart contracts |
frontend |
Frontend application |
db |
Database schema/migrations |
queue |
Background job workers |
dex |
DEX aggregator integrations |
bridge |
Bridge integrations |
defi |
DeFi protocol integrations |
auth |
Authentication |
config |
Configuration |
# Feature
feat(api): add Solana sweep endpoint
# Bug fix
fix(queue): prevent duplicate sweep jobs
# Documentation
docs(api): update quote endpoint examples
# Breaking change
feat(contracts)!: change fee structure
BREAKING CHANGE: Fee calculation now uses basis points instead of percentage.
# With body
fix(price): handle CoinGecko rate limiting
Added exponential backoff retry logic and fallback to DefiLlama
when CoinGecko returns 429 status.
Closes #456- Never commit secrets - API keys, private keys, passwords
- Never log sensitive data - Addresses are OK, private keys are NOT
- Validate all inputs - Use Zod schemas for all external data
- Use parameterized queries - Never interpolate SQL
- Check token approvals - Verify amounts and recipients
- Test edge cases - Empty arrays, max values, etc.
Before submitting a PR that touches:
Smart Contracts:
- No reentrancy vulnerabilities
- Proper access control
- Safe math operations
- Gas limit considerations
- Reviewed by second person
API Endpoints:
- Input validation (Zod)
- Authentication checked
- Rate limiting considered
- Error messages don't leak info
Database:
- Parameterized queries only
- Indexes for new queries
- No sensitive data logged
Price/Value Calculations:
- Multiple oracle sources
- Slippage protection
- Overflow protection
DO NOT open a public issue for security vulnerabilities.
Instead:
- Email security@sweep.bank
- Include detailed reproduction steps
- Allow 72 hours for initial response
- Branch is up to date with main
- All tests pass
- Coverage thresholds met
- No TypeScript errors
- No lint errors
- PR description is complete
- Commit messages follow conventions
- Documentation updated
- No console.log statements (use logger)
- No hardcoded values (use config)
- Code solves the stated problem
- Implementation is correct
- Tests cover the changes
- No security issues
- No performance regressions
- Code is maintainable
- Documentation is adequate
- Breaking changes documented
- Questions: Open a Discussion
- Bugs: Open an Issue
- Security: Email security@sweep.bank
- Chat: Join our Discord (link in README)
Contributors are recognized in:
- GitHub Contributors page
- CHANGELOG.md release notes
- Project documentation
Thank you for contributing to Sweep! 🐷
Please read and follow our Code of Conduct.