Skip to content

Database Schema

1. Overview

The Definitely Not trading bot stores user data, alerts, wallets, and trade conditions in a MySQL database.
This section provides a detailed breakdown of each table, its structure, and its relationships.


2. Database Tables

1. users Table

Stores user information, including their Telegram details and language preferences.

ColumnTypeDescription
idint(11)Primary key (Auto Increment).
user_idbigint(20)Unique Telegram user ID.
first_namevarchar(64)User's first name.
last_namevarchar(64)User's last name (nullable).
usernamevarchar(32)Telegram username (nullable).
localevarchar(6)User's preferred language (default: 'en').
created_attimestampTimestamp when the user was added.
updated_attimestampTimestamp of the last update.

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY (user_id)

2. wallets Table

Stores blockchain wallets associated with users.

ColumnTypeDescription
idint(11)Primary key (Auto Increment).
user_idbigint(20)User ID (nullable, links to users.user_id).
typevarchar(3)Blockchain type (TON or SOL).
addressvarchar(128)Unique wallet address.
public_keyvarchar(128)Wallet public key.
secret_keyvarchar(128)Wallet secret key.
mnemonictextWallet mnemonic (stored as JSON array).
balancedoubleCurrent balance (default: 0).

Indexes:

  • PRIMARY KEY (id)
  • UNIQUE KEY (address)
  • INDEX (type)
  • INDEX (user_id)

3. alerts Table

Stores price alerts for users on different assets.

ColumnTypeDescription
idint(11)Primary key (Auto Increment).
user_idbigint(20)User ID (links to users.user_id).
typetinyint(4)Alert type (e.g., 1 = increase, 2 = decrease).
pricedoubleAlert price threshold.
blockchainvarchar(3)Blockchain (TON or SOL).
assetvarchar(128)Asset name (TON, SOL, Jettons, Tokens).
statustinyint(4)Alert status (0 = pending, 1 = triggered).

Indexes:

  • PRIMARY KEY (id)
  • INDEX (user_id)

4. trade_conditions Table

Stores user-defined trade conditions that trigger automated swaps.

ColumnTypeDescription
idint(11)Primary key (Auto Increment).
user_idbigint(20)User ID (links to users.user_id).
wallet_idint(11)Wallet ID (links to wallets.id).
typetinyint(4)Trade type (1 = buy, 2 = sell).
pricedoublePrice condition for trade execution.
amountdoubleAmount of asset to trade.
blockchainvarchar(3)Blockchain (TON or SOL).
assetvarchar(128)Asset name (Jettons, Tokens, etc.).
statustinyint(4)Condition status (0 = pending, 1 = executed).

Indexes:

  • PRIMARY KEY (id)
  • INDEX (user_id)
  • INDEX (wallet_id)

Foreign Keys:

  • user_idusers.user_id
  • wallet_idwallets.id

3. Table Relationships

plaintext
(users) 1 ───> * (wallets)
(users) 1 ───> * (alerts)
(users) 1 ───> * (trade_conditions)
(wallets) 1 ───> * (trade_conditions)