LumiFi Token Builder is a smart contract project built using Soroban SDK on the Stellar blockchain. It enables users to create custom tokens, manage liquidity pools, and perform token swaps efficiently. This project offers a powerful toolset for decentralized finance (DeFi) applications and token-based ecosystems.
✅ Deployed Contract ID: CBSZTRZYLMZI4PMU34MBO5KRCBQ3P4CSLIPV3QSHUITO7TTXFYOVK3QO
- Token Creation: Easily create custom tokens with specified names, symbols, and decimals.
- Minting and Transfers: Admins can mint tokens to users, and users can transfer tokens securely.
- Liquidity Pools: Add and withdraw liquidity in pools to facilitate decentralized trading.
- Token Swaps: Swap one token for another with minimal slippage, ensuring smooth transactions.
- Secure Authorization: Ensures that only authorized users can perform specific actions, like minting or transfers.
Token
Contract:- Handles token creation, minting, and transferring.
LiquidityPool
Contract:- Manages liquidity addition and removal, enabling decentralized trading.
Swap
Contract:- Allows users to swap one token for another securely.
Make sure you have the following installed:
- Rust: Install Rust
- Soroban CLI: Install Soroban CLI
Clone the repository:
git clone https//www.github.com/kunaldhongade/stellar-token-builder
cd stellar-token-builder
Compile the smart contracts:
soroban contract build
Deploy the contracts using the Soroban CLI:
soroban contract deploy --wasm target/wasm32-unknown-unknown/release/lumifi_token_laucher.wasm
-
Create Token
Token::create_token(env, admin_address, 18, "MyToken".into(), "MTK".into());
- Creates a new token with specified name, symbol, and decimals.
-
Mint Tokens
Token::mint(env, user_address, 1000);
- Mints
1000
tokens to the specified user.
- Mints
-
Transfer Tokens
Token::transfer(env, from_address, to_address, 100);
- Transfers
100
tokens from one user to another.
- Transfers
-
Check Balance
let balance = Token::balance(env, user_address); println!("User balance: {}", balance);
- Retrieves the balance of a specific user.
-
Initialize Pool
LiquidityPool::initialize_liquidity(env, token_a_address, token_b_address);
- Sets up a new liquidity pool for two tokens.
-
Deposit Liquidity
LiquidityPool::deposit(env, user_address, 500, 500);
- Adds liquidity to the pool.
-
Withdraw Liquidity
let (amount_a, amount_b) = LiquidityPool::withdraw(env, user_address, 100); println!("Withdrawn: {} Token A, {} Token B", amount_a, amount_b);
- Perform Swap
Swap::swap(env, user_address, buy_token_address, sell_token_address, 100, 90);
- Swaps
100
units ofsell_token
forbuy_token
with a minimum required90
.
- Swaps
- Create a Token: Use the
Token::create_token()
function to deploy a new token. - Mint Tokens: Mint tokens for yourself or users.
- Add Liquidity: Add liquidity to a pool for decentralized trading.
- Swap Tokens: Swap between tokens using the
Swap
contract. - Withdraw Liquidity: Withdraw liquidity from the pool when needed.
- Slippage Exceeded: The buy amount is less than the minimum specified during the swap.
- Insufficient Balance: The user doesn't have enough tokens to complete a transaction.
- Unauthorized Access: The action requires admin authorization (e.g., minting tokens).
- Authorization: Uses Stellar’s native
require_auth()
to ensure only authorized users can perform sensitive operations. - Slippage Protection: Prevents swaps that result in unfavorable rates for users.
- Safe Storage: Token balances are stored securely using the Soroban SDK's storage.
We welcome contributions to enhance the LumiFi Token Builder! Feel free to submit a pull request or open an issue.
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to the Stellar Development Foundation for the amazing Soroban SDK, and the open-source community for their valuable contributions!