Perpetual futures trading protocol with up to 100x leverage, built on Base with Account Abstraction (USDC gas payments) and privileged smart wallets integration.
- β‘ Instant Market Orders - Execute trades immediately at current oracle price
- π High Leverage - Up to 100x on BTC/ETH, 20x on altcoins
- π― Advanced Orders - Limit orders, stop-loss, take-profit, grid trading
- π΅ USDC Gas Payments - Pay transaction fees in USDC via Account Abstraction
- π Privy Smart Wallets - Embedded wallets with email/social login
- π Dual Token Economy - USDC for trading, DASH for governance & rewards
- Foundry installed
- Base Sepolia ETH for deployment (get from Base Sepolia Faucet)
- Private key with ETH for deployment
# Clone repository
git clone <your-repo-url>
cd dash-sc
# Install dependencies
forge install
# Compile contracts
forge build# Run all tests
forge test
# Run with gas report
forge test --gas-report
# Run with verbose output
forge test -vvvdash-sc/
βββ src/
β βββ token/
β β βββ DashToken.sol # DASH governance token (10M supply)
β β βββ MockUSDC.sol # Test USDC with faucet
β βββ risk/
β β βββ RiskManager.sol # Trade validation & risk checks
β βββ trading/
β β βββ PositionManager.sol # Position tracking & PnL calculation
β β βββ MarketExecutor.sol # Market order execution
β β βββ LimitExecutor.sol # Limit/stop-loss orders
β β βββ TapToTradeExecutor.sol # Fast tap-to-trade orders
β β βββ OneTapProfit.sol # Price prediction betting
β βββ treasury/
β β βββ StabilityFund.sol # Buffer first-loss, fee splitter, streaming
β βββ paymaster/
β β βββ USDCPaymaster.sol # Account Abstraction paymaster
β βββ staking/
β βββ DashStaking.sol # Stake DASH β Earn USDC
β βββ VaultPool.sol # LP vault (USDC shares)
βββ script/
β βββ FullDeploy.s.sol # Complete deployment script
βββ test/ # Foundry tests
βββ foundry.toml # Foundry configuration
| Contract | Description | Key Features |
|---|---|---|
| RiskManager | Trade validation & risk management | Leverage limits (100x BTC/ETH, 20x alts), Liquidation checks |
| PositionManager | Position tracking & PnL | Real-time PnL calculation, Position history |
| MarketExecutor | Market order execution | Instant fills, Signed price verification |
| LimitExecutor | Advanced orders | Limit orders, Stop-loss, Take-profit, Grid trading |
| StabilityFund | Buffer first-loss, fee splitter, pays wins before pool | Absorbs losses, pays wins, streams surplus to pool |
| Contract | Description | Purpose |
|---|---|---|
| DashToken | DASH governance token | 10M supply, Staking rewards, Governance |
| MockUSDC | Test USDC | Faucet (1,000 USDC/claim) for testing |
| USDCPaymaster | Account Abstraction | Pay gas fees with USDC |
| Contract | Description | Rewards |
|---|---|---|
| DashStaking | Stake DASH tokens | Earn 30% of trading fees in USDC |
| VaultPool | Provide USDC liquidity | Share-based LP pool backing trader payouts |
| Contract | Description | Features |
|---|---|---|
| TapToTradeExecutor | Fast order execution | Backend-managed instant trades |
| OneTapProfit | Price prediction betting | 30s-5min duration, 2x multiplier |
forge script script/FullDeploy.s.sol \
--rpc-url https://sepolia.base.org \
--private-key YOUR_PRIVATE_KEY \
--broadcastThis will:
- Deploy core contracts (VaultPool, StabilityFund, Market/Limit/Tap/OTP, token, staking, paymaster)
- Grant roles (SETTLER/KEEPER + backend signer)
- Initialize DashToken distribution
- Wire executors to StabilityFund and StabilityFund to VaultPool
- Save deployment addresses to
deployments/base-sepolia-latest.json
Base Sepolia (Testnet):
forge script script/FullDeploy.s.sol \
--rpc-url https://sepolia.base.org \
--private-key YOUR_PRIVATE_KEY \
--broadcastBase Mainnet (Production):
forge script script/FullDeploy.s.sol \
--rpc-url https://mainnet.base.org \
--private-key YOUR_PRIVATE_KEY \
--broadcast \
--verifyAfter deployment, you'll get a JSON file at deployments/base-sepolia-latest.json with all contract addresses. Copy these addresses to your backend .env file!
DASH Token (10,000,000 total):
- 50% (5M) β Staking Rewards
- 20% (2M) -> VaultPool liquidity allocation
- 20% (2M) β Team
- 10% (1M) β Treasury
Distribution is automatic during deployment via DashToken.initialize().
| Action | Fee | Recipient |
|---|---|---|
| Market Trade | 0.05% of position size | Protocol (split 50/30/20) |
| Limit Order Execution | 0.5 USDC | Keeper |
| Liquidation | 0.5% of position | Liquidator |
| Early Unstake (Staking) | 10% | Treasury |
| Early Withdrawal (LP) | 15% | Treasury |
Fee Distribution:
- 50% β Liquidity Pool (backs trader profits)
- 30% β DASH Stakers (via DashStaking)
- 20% β Protocol Treasury
The deployment script automatically grants these roles:
EXECUTOR_ROLEβ MarketExecutor, LimitExecutor, TapToTradeExecutor, OneTapProfitKEEPER_ROLEβ Backend keeper address (for liquidations)
KEEPER_ROLEβ Backend keeper address (for limit order execution)
PRICE_SIGNER_ROLEβ Backend price signer address
- β OpenZeppelin Contracts - Battle-tested security libraries
- β ReentrancyGuard - All state-changing functions protected
- β Access Control - Role-based permissions (RBAC)
- β SafeERC20 - Safe token transfers
- β Signed Prices - ECDSA verification (5-minute validity)
- β Immutable Contracts - No upgradability (trustless)
- β Oracle Validation - Price freshness checks
| Asset | Max Leverage | Min Collateral |
|---|---|---|
| BTC | 100x | 10 USDC |
| ETH | 100x | 10 USDC |
| SOL, AVAX, NEAR | 50x | 10 USDC |
| BNB, XRP, LINK, MATIC | 20x | 10 USDC |
| AAVE, ARB, DOGE | 20x | 10 USDC |
# Run all tests
forge test
# Test specific contract
forge test --match-contract PositionManagerTest
# Test with gas report
forge test --gas-report
# Test with coverage
forge coverageAfter deploying contracts:
-
Update Backend
- Copy contract addresses to
dash-be/.env - Grant PRICE_SIGNER_ROLE to backend signer
- Fund relay wallet with ETH
- Copy contract addresses to
-
Update Frontend
- Update contract addresses in frontend config
- Test market orders
- Test limit orders
-
Add Liquidity
- Fund StabilityFund (buffer) and VaultPool with USDC (mint/transfer for testing)
- Initial recommendation: 10,000 USDC minimum
-
Test Trading
- Claim Mock USDC from faucet
- Open test positions
- Verify PnL calculations
MIT License - see LICENSE file for details
Built with β€οΈ by Dash DEX Team using Foundry
For questions or support, please open an issue on GitHub.