Skip to content
🎉 Welcome to atWallets Ecosystem! Visit AirDrop Rewards
Maker

Maker

Symbol Synchronization

  • SyncBinanceSymbolTaskFirstStart() runs when the application is started for the first time and fetches the symbols.
  • It retrieves all available trading pairs from the exchange’s API and matches them with the assets in the database.
  • If there are missing symbols in the database, the syncBinanceSymbol() function is called to add the missing ones.
  • After this process is complete, SyncBinanceSymbolsTask() updates the symbols weekly.

Wallet Synchronization

  • SyncBinanceWallet(): Runs every second to check the current balances.
  • syncBalances(): Fetches and updates the user’s balances from the Binance API.
  • saveBalances(): Saves or updates the user’s balances in the database.

Order Synchronization

  • CheckBinanceOrdersStatus(): Checks the status of open orders.
  • CheckBinanceOpenOrders(): Updates the open orders.
  • syncOrders(): Updates the user’s orders by fetching them from the exchange’s API.
    • If an order is completed, the syncTrades() function is called to update the related trades.

Trade Synchronization

  • syncTrades(): Matches spot, margin, and futures trades.
  • saveTrades(): Saves or updates the user’s buy-sell trades in the database.
    • If a trade is updated, the wallet balances are refreshed with the SyncBinanceWallet() function.

Deposit & Withdrawal Transactions

  • syncDepositWithdrawals(): Fetches deposit and withdrawal transactions from the exchange. The user’s wallet balance is updated, and the transaction history is added.
  • saveDepositWithdrawals(): Saves the user’s deposit and withdrawal transactions.
  • saveFiatBUYSELL(): Saves fiat buy-sell transactions.
  • saveTransferINOUT(): Saves transfer transactions.
  • calculateTotalDepositWithdrawalCommission(): Calculates the user’s total deposit, withdrawal, and commissions.

Automatic Balance Updates

  • syncBalancesAuto(): Updates the user’s balances at specified intervals.
  • checkTradingAssets(): Checks the assets being traded.
  • checkTradingSymbols(): Synchronizes the updated trading pairs on the exchange.

Scheduled Tasks

  • CheckBinanceOrdersStatus() → Runs every minute to check the order statuses.
  • SyncBinanceSymbolTaskFirstStart() → Runs once at startup to fetch the symbols.
  • SyncBinanceSymbolsTask() → Updates Binance symbols once a week.
  • SyncBinanceWallet() → Runs every second to ensure wallet synchronization.
  • CheckBinanceOpenOrders() → Runs every second to synchronize open orders.
  • CheckAutoBalances() → Runs every second to manage automatic balance updates.

System Features and Functions

  • Catches and logs any errors that occur during transactions.
  • Uses goroutines and channels to perform concurrent operations.
  • Manages database operations using the GORM library.
  • Fetches necessary data by communicating with the exchange’s API.
  • Tracks synchronization and transaction counts. This allows for analysis of user activities.
  • Synchronization operations can be restricted based on the user’s membership type.
  • Frequently used data is cached using systems like Redis.
  • Automatic tasks run at specific intervals to execute synchronization processes, keeping user data up to date.
  • Secure authentication is ensured with the exchange API. User API keys are encrypted and stored securely for safe usage.