This repository contains three main modules: an Automated Market Maker (AMM), a yield aggregator (Kai Finance), and a token distribution protocol.
This repository provides a suite of DeFi primitives and applications built specifically for the Sui blockchain using the Move programming language. Each module is designed to be composable, secure, and production-ready, following Sui's object-centric programming model.
- Modular Design: Each module can be used independently or composed together
- Production Ready: Battle-tested contracts with comprehensive test coverage
- Sui Optimized: Built specifically for Sui's unique object model and capabilities
- Composable: Modules are designed to work together seamlessly
- Secure: Implements best practices for smart contract security
A UniswapV2-style Automated Market Maker implementation in idiomatic Sui Move.
Features:
- Constant product curve (A × B = k)
- Swap between any
Coin<A>andCoin<B> - Deposit and withdraw liquidity
- Permissionless and dynamic pool creation for any
Coinpair - LP and admin fee support
- Slippage protection
Key Components:
Pool<A, B>: Represents an AMM pool for token pair A and BLP<A, B>: Liquidity provider tokens for the poolPoolRegistry: Manages pool creation and ensures one pool per token pairAdminCap: Administrative capabilities for fee management
Implementation Notes:
- Uses approach (1) for pool creation: one pool per token pair
- LP tokens are non-fungible between different pools
- Supports configurable LP fees and admin fees
- Implements proper slippage protection
A sophisticated yield aggregator for Sui that optimizes returns across multiple DeFi strategies.
Features:
- Multi-strategy yield optimization
- Dynamic strategy allocation and rebalancing
- Time-locked profit distribution to prevent sandwich attacks
- Performance fee collection
- TVL caps for risk management
- Strategy-specific borrowing limits
Key Components:
Vault<T, YT>: Main vault contract managing multiple strategiesVaultAccess: Authorization for strategies to interact with vaultWithdrawTicket: Manages withdrawal process across strategiesStrategyState: Tracks strategy performance and allocation
Supported Strategies:
- Scallop Protocol integration (lending/borrowing)
- Yield-bearing token strategies
- Cross-protocol yield optimization
Architecture:
- Vault manages free balance and allocated funds across strategies
- Strategies can borrow funds from vault based on allocation weights
- Profits are distributed over time using time-locked balances
- Withdrawals are processed through tickets to ensure atomicity
A highly composable, flexible, and modular token distribution protocol for various use cases.
Primitives:
- Locks tokens with configurable unlock rate per second
- Supports cliff periods and dynamic unlock parameters
- Basic building block for vesting mechanisms
- Distributes tokens over time to multiple beneficiaries
- Weight-based proportional distribution
- Dynamic member management and weight adjustment
- O(n) operations - suitable for smaller beneficiary sets
- Instant proportional distribution to beneficiaries
- O(1) operations - scales to unlimited beneficiaries
- Multi-token support
- Share-based distribution system
Farm System:
Farm: Manages reward distribution across poolsPool: Represents liquidity mining pools- Multi-farm membership for pools
- Dynamic reward token management
Use Cases:
- Token vesting schedules
- Liquidity mining programs
- Team token allocations
- Community reward distribution
- Sui CLI installed
- Move toolchain set up
- Basic understanding of Sui and Move programming
- Clone the repository:
git clone https://github.com/skc951201/Sui_Smart_Contracts.git
cd sui-smart-contracts- Navigate to the specific module you want to work with:
cd amm # or kai-finance, or token-distribution- Build the module:
sui move build- Run tests:
sui move test- Object-Centric: Leverages Sui's object model for better composability
- Modular: Each component is self-contained and reusable
- Composable: Modules can be combined to create complex DeFi applications
- Secure: Implements defense-in-depth security patterns
- Gas Efficient: Optimized for Sui's gas model
- Capability-Based Access Control: Uses capability objects for administrative functions
- Event-Driven: Comprehensive event emission for off-chain monitoring
- Error Handling: Detailed error codes for better debugging
- Upgrade Safety: Proper upgrade mechanisms where applicable
- AMM ↔ Token Distribution: AMM pools can be used in liquidity mining farms
- Kai Finance ↔ AMM: Vault strategies can interact with AMM pools
- Cross-Module Composability: All modules designed to work together
- Input Validation: Comprehensive validation of all inputs
- Access Control: Capability-based permission system
- Slippage Protection: Built-in slippage controls for swaps
- Reentrancy Protection: Move's linear type system prevents reentrancy
- Overflow Protection: Safe math operations throughout
- All modules have undergone security reviews
- Comprehensive test coverage
- Production deployment on Sui mainnet
- Always verify contract addresses before interaction
- Use appropriate slippage tolerances
- Monitor for events and state changes
- Follow Sui's security guidelines
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Copyright 2023 Kuna Labs
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
- Follow Move best practices
- Write comprehensive tests
- Document public functions
- Use meaningful variable names
- Handle errors gracefully
Each module includes comprehensive test suites:
- Unit tests for individual functions
- Integration tests for complex workflows
- Edge case testing
- Gas optimization tests
- Documentation: Check individual module READMEs for detailed documentation
- Issues: Report bugs and feature requests via GitHub issues
- Discord: Join our community Discord for discussions
- Website: Visit kai.finance for Kai Finance specific information
Built with ❤️ by the Kuna Labs team for the Sui ecosystem.