Skip to content

Security & Configuration

1. Overview

Security and configuration are essential for running Definitely Not efficiently. This section covers:

  • Security Measures – How we handle user data, rate limits, and bot protection.
  • Configuration Options – All environment variables and settings you can tweak.
  • Performance & Caching Settings – How the bot optimizes performance using connection pools and caching.

2. Security Measures

Not only do we not guarantee profitable trades, but we also don't guarantee your bot won't get spammed—so we built in some protections.

User Data Protection

Wallet Security – Wallets are generated and stored in MySQL.

Rate Limiting – API calls are limited per user to prevent spam and abuse. ✔ Database Security – Uses MySQL & Redis with authentication for storing user and transaction data.

Spam & Flood Control

Anti-Flooding Measures – Prevents excessive requests from users.

3. Configuration Options

You can customize the bot's behavior using environment variables and pre-defined settings.

1. Bot Configuration (.env)

VariableDescription
BOT_TOKENTelegram Bot Token (required).
BOT_HOSTBot server host address.
BOT_PORTPort on which the bot runs.
BOT_API_SERVERCustom Telegram API server (if applicable).
BOT_REPORT_ADMIN_IDAdmin Telegram ID for bot alerts.
RATES_CHANNEL_USERNAMETelegram channel username for broadcasting rates.

2. Database Configuration (.env)

VariableDescription
MYSQL_DB_USERMySQL database username.
MYSQL_DB_PASSMySQL database password.
MYSQL_DB_HOSTMySQL server host address.
MYSQL_DB_NAMEMySQL database name.
REDIS_HOSTRedis server host address.
REDIS_PORTRedis server port.
REDIS_PASSRedis password (if authentication is used).
REDIS_DBRedis database index.

3. Controller Configuration (.env)

VariableDescription
CONTROLLER_HOSTController backend host address.
CONTROLLER_PORTController backend port.

4. General Network Configuration (.env)

VariableDescription
NETWORKBlockchain network (testnet or mainnet).
TONCENTER_TESTNET_KEYAPI key for Toncenter testnet.
TONCENTER_MAINNET_KEYAPI key for Toncenter mainnet.
TONCONSOLE_KEYAPI key for TonConsole.

5. Wallet Configuration (bun.config.ts)

By default, the bot pre-generates wallets for users. You can configure how many wallets are created in advance.

SettingDescriptionDefault Value
PRE_GENERATED_TON_WALLETSNumber of pre-generated TON wallets.5
PRE_GENERATED_SOL_WALLETSNumber of pre-generated Solana wallets.5

4. Performance & Caching Settings

To ensure high performance, Definitely Not uses caching, connection pooling, and optimized processing.

1. Worker & Reactor Threads (config.php)

SettingDescriptionDefault Value
PROCESS_WORKER_NUMNumber of worker processes for OpenSwoole.4
PROCESS_REACTOR_NUMNumber of reactor threads for OpenSwoole.4

2. Database Connection Pooling (config.php)

SettingDescriptionDefault Value
MYSQL_CONNECTION_POOL_SIZE_MAXMaximum MySQL connections in the pool.8
REDIS_CONNECTION_POOL_SIZE_MAXMaximum Redis connections in the pool.8

3. Caching Configuration (config.php)

SettingDescriptionDefault Value
CACHE_TABLE_BALANCE_SIZECache size for balance storage.1024
CACHE_TABLE_BALANCE_TIMECache expiration time for balance (seconds).30
CACHE_TABLE_ASSETS_BALANCE_SIZECache size for asset balance storage.2048
CACHE_TABLE_ASSETS_BALANCE_TIMECache expiration time for asset balance (seconds).30
TABLE_JETTONS_SIZEMaximum number of jettons stored in cache.128
TABLE_TOKENS_SIZEMaximum number of tokens stored in cache.128

4. Alerts & Trading Conditions (config.php)

SettingDescriptionDefault Value
TABLE_ALERTS_SIZEMax number of alerts stored.1024
TABLE_CONDITIONS_SIZEMax number of trade conditions stored.1024
TRADE_CONDITIONS_PENDING_MAXMaximum pending trade conditions per user.10
ALERTS_ACTIVE_MAXMaximum active alerts per user.10

5. Summary

  • Security? ✅ We rate-limit users, and restrict API abuse.
  • Customizable? ✅ Configure network, database, and API settings easily.
  • Wallet Pre-Generation? ✅ Yes, set how many wallets are created in advance.
  • Performance Optimized? ✅ OpenSwoole workers, connection pooling, and caching ensure efficiency.
  • Flooding the bot with spam? ❌ Won’t work, we got that covered.

Now that you know how to configure and secure the bot, check out TON APIs to see how it all works behind the scenes!