This project implements a collateralized stablecoin protocol on Solana, inspired by MakerDAO and other DeFi lending models.
Users can deposit SOL as collateral and mint a protocol-native stablecoin, with on-chain health factor and liquidation logic.
- β Deposit SOL as collateral
- β Mint stablecoins against collateral
- β Redeem collateral by burning stablecoins
- β Liquidate undercollateralized positions
- β On-chain health factor enforcement
- β Configurable risk parameters (liquidation threshold, bonus, etc.)
- β Mocked price feed using Pyth PriceUpdateV2
- β Full PDA-driven state management
- β Built with Rust + Anchor Framework
| Account | Purpose |
|---|---|
| Config | Stores global risk parameters & mint PDA |
| Collateral | Per-user collateral state (SOL balance, debt) |
| SOL Account (PDA) | PDA holding userβs deposited SOL (collateral) |
| Mint Account | PDA minting the protocol stablecoin |
| Token Account | Userβs ATA for receiving stablecoins |
| Instruction | Purpose |
|---|---|
initialize_config |
Set up protocol config & mint |
update_config |
Authority can update risk params |
deposit_collateral_and_mint_tokens |
Deposit SOL + Mint stablecoins |
redeem_collateral_and_burn_tokens |
Burn stablecoins + Redeem SOL |
liquidate |
Liquidate unhealthy positions |
- β Local testing with mocked Pyth oracles
- β Health factor & liquidation edge cases
- β Token balances & mint authority checks
You can run:
anchor test --skip-build(Make sure LiteSVM or local validator is set up)
- Rust
- Anchor
- Solana Program Library (SPL Token2022)
- Pyth Oracles (Mocked for testing)
- Anchor LiteSVM (for fast in-memory testing)
This is a learning-focused project built for educational purposes only. It is NOT audited, NOT production-ready, and has incomplete safety checks. Do NOT deploy this on Solana Mainnet.
programs/
βββ stablecoin/
βββ src/
βββ instructions/
β βββ admin/
β β βββ initialize_config.rs
β β βββ update_config.rs
β β βββ mod.rs
β βββ deposit/
β β βββ deposit_collateral_and_mint_tokens.rs
β β βββ utils.rs
β β βββ mod.rs
β βββ withdraw/
β β βββ redeem_collateral_and_burn_tokens.rs
β β βββ liquidate.rs
β β βββ utils.rs
β β βββ mod.rs
β βββ mod.rs
βββ state.rs
βββ constants.rs
βββ error.rs
βββ lib.rs
βββ mod.rs
- Improve interest rate & debt modeling
- Add real Pyth testnet feeds
- Build a frontend (Next.js / React) for UI
- Explore permissionless minting models
MIT License (For educational use only)