Skip to content

darrendc26/capstone-stealth-swap

Repository files navigation

Stealth Swap

An intent-based swap protocol with Dutch auction mechanics on Solana

A production-ready DeFi protocol that enables users to express swap intents while solvers compete through Dutch auctions to provide optimal execution. Built with Rust and Anchor framework, demonstrating advanced Solana development patterns.

Features

Core Protocol Intent-Based Trading: Users express swap intentions without immediate execution

Dutch Auction Mechanics: Price discovery through linear decay over time

Solver Competition: First-come-first-served claiming with economic incentives

Atomic Settlement: All-or-nothing transaction execution with bond protection

MEV Protection: Reduced front-running through time-delayed price discovery

Technical Highlights

PDA Architecture: Secure program-derived addresses for escrow and auction management

Bond System: Anti-griefing mechanism with solver collateral and slashing

Cross-Program Invocations: Safe token transfers with proper authority delegation

Event Emission: Complete off-chain indexing support for solver bots

Rent Optimization: Automatic escrow cleanup and rent recovery

Technology Stack

Language: Rust

Framework: Anchor 0.31

Blockchain: Solana

Testing: TypeScript with Mocha/Chai

Token Standard: SPL Token Program

Deployment

This project is deployed on Solana's devnet. Signature: 2NuQeQ392wkKdvKaVWiVkxUkt6TvMTVmnkceaDMktb2RHwVgk2V57LxBvVGyeUKG9gVb7zh8ax5ffccFhHRZf7rX

Prerequisites

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

# Install Anchor
npm install -g @coral-xyz/anchor-cli

# Install Node dependencies
npm install

Build & Deploy

# Build the program
anchor build

# Run tests
anchor test

# Deploy to localnet
anchor deploy --provider.cluster localnet

# Deploy to devnet
anchor deploy --provider.cluster devnet

Technical Documentation

Key Design Decisions

Intent-Based Architecture: Separates user expression from execution timing

Dutch Auctions: Provides fair price discovery through time-based decay

Solver Competition: Creates MEV-positive environment with proper incentives

Atomic Settlement: Ensures transaction safety through Solana's execution model

Rust/Solana Patterns Demonstrated

Advanced PDA design and seed management

Cross-program invocation (CPI) safety

Event-driven architecture for off-chain integration

Token program interaction patterns

Rent optimization and account lifecycle management

About

An intent based swap implementation with Dutch auction mechanics on Solana. Demonstrates atomic settlement, solver competition and anti-MEV protection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors