A decentralized curve-based Automated Market Maker (AMM) protocol built on Stacks that enables efficient trading of stablecoins and similar assets while distributing rewards to wBTC holders.
CurveDEX implements a StableSwap-style AMM that uses curve mathematics to minimize slippage for trades between assets with similar values. The protocol generates trading fees that are split between liquidity providers (70%) and wBTC holders (30%), creating an innovative reward distribution mechanism.
- Curve-Based AMM: Optimized for low-slippage trading between similar-value assets
- Dual Reward System: Trading fees distributed between liquidity providers and wBTC holders
- Multi-Market Support: Support for multiple trading pairs with independent configurations
- SIP-010 Compatible: Works with any SIP-010 compliant fungible tokens
- Trading Markets: Independent liquidity pools with configurable curve parameters
- Liquidity Provision: Users can provide liquidity to earn fees and LP tokens
- Reward Distribution: Automated fee splitting and reward accumulation
- wBTC Holder Registry: Tracks wBTC holders for reward distribution
- Trading Fee: 0.3% (3 basis points) on all trades
- Provider Share: 70% of fees go to liquidity providers
- wBTC Reward Share: 30% of fees distributed to registered wBTC holders
create-market: Create a new trading market (admin only)get-market-info: View market details and reserves
execute-trade: Swap tokens with slippage protectionprovide-liquidity: Add liquidity to earn fees and LP tokenswithdraw-liquidity: Remove liquidity and burn LP tokens
register-wbtc-participant: Register wBTC holder for rewards (admin only)claim-distribution: Claim accumulated trading fee rewards
get-wbtc-holdings: Check registered wBTC holdingsparticipant-exists: Verify if address is registered for rewards
(contract-call? .curvedex create-market
'SP1H1733V5MZ3SZ9XRW9FKYGEZT0JDGEB8Y634C7R.usdc-token
'SP1H1733V5MZ3SZ9XRW9FKYGEZT0JDGEB8Y634C7R.usdt-token
u100 ;; curve factor
u1) ;; market ID(contract-call? .curvedex provide-liquidity
u1 ;; market ID
.usdc-token
.usdt-token
u1000000 ;; 1 USDC (6 decimals)
u1000000 ;; 1 USDT (6 decimals)
u900000) ;; minimum LP tokens(contract-call? .curvedex execute-trade
u1 ;; market ID
.usdc-token
.usdt-token
u1000000 ;; 1 USDC input
u990000) ;; minimum 0.99 USDT output| Code | Name | Description |
|---|---|---|
| u100 | ERR_ADMIN_ONLY | Function restricted to protocol admin |
| u101 | ERR_BALANCE_TOO_LOW | Insufficient token balance |
| u102 | ERR_RESERVES_TOO_LOW | Insufficient market reserves |
| u103 | ERR_SLIPPAGE_TOO_HIGH | Trade exceeds slippage tolerance |
| u104 | ERR_INVALID_INPUT | Invalid input parameters |
| u105 | ERR_RESERVES_IMBALANCED | Market reserves are imbalanced |
| u110 | ERR_INVALID_MARKET_ID | Market does not exist |
| u113 | ERR_INVALID_ADDRESS | Invalid principal address |
- Input Validation: Comprehensive validation of all parameters
- Slippage Protection: Minimum output amounts prevent sandwich attacks
- Access Control: Admin-only functions for market creation and registrations
- Safe Math: Overflow protection in mathematical operations
- Principal Validation: Prevents zero-address interactions
CurveDEX uses a modified constant product formula with amplification factor:
D = invariant(x, y, A)
Where:
x,yare token reservesAis the amplification/curve factor- Higher
Avalues create flatter curves (less slippage)
- Stacks blockchain compatible environment
- SIP-010 fungible tokens for trading pairs
- Admin account for market creation and wBTC holder registration