CEX Wallets Guide
This guide provides comprehensive information about Centralized Exchange (CEX) wallets, their setup, management, and maintenance procedures.
What are CEX Wallets?
CEX wallets are accounts that depend on centralized exchanges such as:
- KuCoin
- HTX
- Binance
These wallets are essential for managing cryptocurrency operations through centralized exchanges. Each CEX wallet can be either a main wallet or a sub-wallet, and can serve different purposes like vault operations or deposits.
Wallet Structure
Types of Wallets
Main Wallets
- Primary wallets for each exchange
- Used for core exchange operations
- Required for updating coin and blockchain information
- Used as the primary connection point for exchange API operations
Sub Wallets
- Secondary wallets that can be linked to main wallets
- Can be used for specific purposes like vault operations
- May have different permissions and capabilities
- Often used for specific business functions like vault partnerships
Wallet Properties
Each CEX wallet contains:
- Unique ID (combination of exchange and origin wallet ID)
- Exchange type (KuCoin, HTX, Binance)
- Wallet type (main or sub)
- Encrypted API credentials (API key and secret)
- Wallet purpose (vault, deposit, etc.)
- Vault partner information (if applicable)
- Associated email
- Active status
Wallet Management
Initial Setup
- Create CEX wallets using the Deposit functionality
- Run the VanRan Deposit within the Database folder
- This sets up the basic wallet structure for each exchange
Managing Exchange Coins and Blockchains
In the admin interface, under CexWalletCoins, you can perform the following operations:
- Update available coins for each exchange
- This process brings all supported coins with their respective blockchains for each exchange
- Examples of supported combinations:
- AAVE on Ethereum
- AAVE on BSC
- USDT on Tron
- USDT on BSC
- USDT on Ethereum
The system uses the CexCoinsBlockchainsUpdater service to:
- Fetch all available coins from the system
- Retrieve network information from the exchange
- Create and save
CexCoinBlockchainentities for each supported combination
Coin Status Management
Under CexWalletCoinsCurrentStatuses, you can:
- Update the status of each coin for every exchange and blockchain
- View and manage:
- Withdrawal availability
- Deposit availability
- Transaction fees
- Minimum withdrawal amounts
- Deposit limits
The system uses the CexCoinBlockchainStatusUpdater service to:
- Fetch existing coin-blockchain combinations
- Retrieve network status information from the exchange
- Update or create
CexCoinBlockchainStatusentities with current fees and limits
Wallet Balance Management
Each wallet has associated coin wallets that:
- Track balances for different coins
- Aggregate balances across different blockchains
- Example: If you have 5 USDT on Tron and 5 USDT on BSC, the total balance will show as 10 USDT
The system uses the CexAccountCoinWalletsUpdater service to:
- Fetch current balances from the exchange
- Create or update
CexAccountCoinWalletentities - Track both available and locked balances for each coin
Deposit Addresses
- Access through
CexWalletAccountsDepositAddresses - Use the Update function to:
- View deposit addresses for each coin-blockchain combination
- Manage deposit address configurations
The system uses the CexAccountCoinBlockchainAddressUpdater service to:
- Identify active coin-blockchain combinations with deposit enabled
- Fetch deposit addresses from the exchange
- Create and save
CexAccountCoinBlockchainAddressentities - Handle rate limiting by processing addresses sequentially
Local Development Setup
For local development, you can use the database seeding feature to create basic CEX wallets automatically.
Prerequisites
- Access to the project's database package
- Local environment variables configured properly
SECRETS_KEYfor decrypting the API keys (request this from the dev leader)
Steps to Set Up Local CEX Wallets
- Navigate to the database package directory:
cd /path/to/database-package- Make sure your environment has the correct
SECRETS_KEYvariable set:
export SECRETS_KEY="your-secret-key" # Request the actual key from dev leader- Run the database seed with the CEX wallets flag enabled:
bun run db:seedSecurity Considerations
- API keys are encrypted using the
SECRETS_KEY - Different wallet types have different permission levels
- Main wallets are required for certain operations
- API keys should never be stored in plain text
- Each wallet's purpose and vault partner information is tracked for security
- The system uses value objects and domain entities to ensure data integrity
Troubleshooting
If you encounter issues with the CEX wallets:
- Verify you have the correct
SECRETS_KEY - Check database connection settings
- Ensure the seeding process completed successfully
- Review logs for any errors during the seeding process
- Verify that all update processes (coins, statuses, wallets, deposit addresses) completed successfully
- Check if the main wallet exists for the exchange you're working with
- Verify API key permissions and encryption
- Check for rate limiting issues when fetching deposit addresses
- Ensure the exchange API is accessible and responding correctly
For additional assistance, contact the development team lead.
