Copyright (c) 2025 BTB Finance. All Rights Reserved.
PROPRIETARY AND CONFIDENTIAL - DO NOT COPY
A bonding curve token implementation on Sui where users can mint BTB tokens by depositing SUI and burn BTB tokens to receive SUI back. The contract maintains SUI reserves as backing for the tokens.
This code is proprietary and confidential. Unauthorized copying, forking, modification, or distribution is strictly prohibited and will result in legal action. This includes:
- ❌ Creating forks or copies of this repository
- ❌ Using this code in other projects
- ❌ Modifying or adapting this code
- ❌ Commercial use without license
- ❌ Reverse engineering the algorithms
Permitted: Viewing for educational purposes and interacting with deployed contracts only.
See LICENSE file for complete terms.
- Bonding Curve Pricing: Token price follows the formula
tokens = (sui * supply) / backing - SUI Backing: All BTB tokens are backed by SUI reserves held by the contract
- Fee Structure: 0.1% total fee (0.05% to fee collector, 0.05% increases backing)
- Price Safety: Enforces that token price can only increase (anti-manipulation)
- Real-time Queries: Get current price, supply, and backing information
tokens_to_mint = (net_sui * current_supply) / current_backing
- Users send SUI to mint BTB tokens
- 0.05% fee goes to fee collector
- 0.05% fee stays in backing (increases reserves)
- Remaining SUI goes to backing reserves
sui_to_return = (tokens * current_backing) / current_supply
- Users burn BTB tokens to receive SUI
- 0.05% fee goes to fee collector
- 0.05% fee stays in backing reserves
- User receives remaining SUI
├── sources/
│ └── btb_finance.move # Main contract implementation
├── tests/
│ └── btb_finance_tests.move # Comprehensive test suite
├── scripts/
│ ├── deploy.sh # Deployment script
│ └── test.sh # Testing script
├── Move.toml # Package manifest
└── README.md # This file
- Sui CLI
- Git
# Clone the repository
git clone <your-repo-url>
cd btb_finance
# Install Sui CLI (if not already installed)
cargo install --locked --git https://github.com/MystenLabs/sui.git --branch mainnet sui# Run the test script
./scripts/test.sh
# Or run tests directly
sui move testsui move build# Make sure you have a Sui wallet configured for testnet
sui client switch --env testnet
# Run deployment script
./scripts/deploy.shAfter deployment, initialize the configuration with a fee collector address:
sui client call \
--function init_config \
--module btb_finance \
--package <PACKAGE_ID> \
--args <CONFIG_OBJECT_ID> <FEE_COLLECTOR_ADDRESS># Mint BTB tokens by sending 1 SUI (1,000,000,000 MIST)
sui client call \
--function mint_with_backing \
--module btb_finance \
--package <PACKAGE_ID> \
--args <CONFIG_OBJECT_ID> \
--coin <SUI_COIN_ID> \
--gas-budget 10000000# Burn BTB tokens to receive SUI back
sui client call \
--function burn_for_backing \
--module btb_finance \
--package <PACKAGE_ID> \
--args <CONFIG_OBJECT_ID> <BTB_COIN_ID> \
--gas-budget 10000000# Get current system state (price, supply, backing)
sui client call \
--function get_system_info \
--module btb_finance \
--package <PACKAGE_ID> \
--args <CONFIG_OBJECT_ID>init_config(config, fee_collector)- Initialize protocol configurationmint_with_backing(config, payment)- Mint BTB tokens with SUIburn_for_backing(config, btb_tokens)- Burn BTB tokens for SUI
get_system_info(config)- Get complete system informationtotal_supply(config)- Get total BTB token supplytotal_backing(config)- Get total SUI backing amountcurrent_price(config)- Get current token pricefee_collector(config)- Get fee collector addresstotal_fees_collected(config)- Get total fees collected
- Token Management: Uses Sui's
Coin<T>andTreasuryCap<T>instead of SPL tokens - State Storage: Uses shared objects instead of PDAs
- Native Currency: Uses SUI instead of SOL
- Entry Functions: Direct function calls instead of instruction-based architecture
- Error Handling: Move's built-in assertion system instead of custom error codes
- Minimum Trade Amount: Prevents spam with 1000 MIST minimum
- Price Safety Check: Ensures price can only increase
- Input Validation: Comprehensive validation of all inputs
- Overflow Protection: Safe arithmetic operations
- Access Control: Proper permission checks for administrative functions
| Action | Total Fee | Fee Collector | Backing Increase |
|---|---|---|---|
| Mint | 0.1% | 0.05% | 0.05% |
| Burn | 0.1% | 0.05% | 0.05% |
The contract emits the following events:
TokensMinted- When BTB tokens are mintedTokensBurned- When BTB tokens are burned