A collection of decentralized finance (DeFi) programs built on the Solana blockchain using the Anchor framework. This repository contains production-ready smart contracts for various DeFi primitives.
A robust AMM implementation supporting both SPL Token and Token-2022 standards.
Features:
- Dual token standard support (SPL Token & Token-2022)
- Constant product formula (x * y = k)
- Configurable fee rates
- Liquidity provider rewards
- Slippage protection
Instructions:
initialize_pool- Create new trading poolsadd_liquidity- Provide liquidity and earn feesremove_liquidity- Withdraw liquidity and rewardsswap- Trade tokens with minimal slippage
A secure vault system for SOL deposits and withdrawals with PDA-based ownership.
Features:
- Secure SOL storage using PDAs
- User-specific vault isolation
- Rent-exempt validation
- Error handling for edge cases
Instructions:
deposit- Securely deposit SOL into personal vaultwithdraw- Withdraw SOL from personal vault
A trustless escrow system for secure peer-to-peer token exchanges.
Features:
- Trustless token swaps
- Escrow state management
- Automated settlement
- Refund mechanisms
Instructions:
make- Create new escrow agreementtake- Accept and complete escrowrefund- Cancel and refund escrow
- Blockchain: Solana
- Framework: Anchor 0.31.1
- Language: Rust
- Testing: TypeScript with Mocha/Chai
- Token Standards: SPL Token, Token-2022
- Rust 1.70+
- Solana CLI 1.18+
- Anchor CLI 0.31+
- Node.js 18+
- Yarn or npm
# Clone the repository
git clone https://github.com/Shradhesh71/Solana-DeFi-Programs.git
cd Solana-DeFi-Programs
# Install Anchor dependencies
anchor build
# Install Node.js dependencies for testing
npm installEach program includes comprehensive test suites covering happy paths, edge cases, and error scenarios.
# Test all programs
anchor test
# Test specific program
cd anchor_vault && anchor test
cd anchor-AMM/anchor && anchor test
cd anchor_escrow && anchor testSolana-DeFi-Programs/
├── anchor-AMM/ # AMM Program
│ ├── anchor/
│ │ ├── programs/amm/
│ │ └── tests/
├── anchor_vault/ # Vault Program
│ ├── programs/
│ └── tests/
├── anchor_escrow/ # Escrow Program
│ ├── programs/
│ └── tests/
└── governance/ # Governance utilities
Programs are deployed on Solana Devnet for testing:
- AMM Program:
FqzkXZdwYjurnUKetJCAvaUw5WAqbwzU6gZEwydeEfqS - Vault Program: Available in program artifacts
- Escrow Program: Available in program artifacts
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Shradhesh - @Shradhesh71
Project Link: https://github.com/Shradhesh71/Solana-DeFi-Programs