-- Crypto withdrawal methods from external API (GET /api/v1/withdrawal-methods). Synced every 30 min.
-- Methods table overwritten on each sync (no hash check). min_withdrawal is per method.
-- One row per active withdrawal method (pid = icon_id from API, used for icon filename e.g. 30.png).
CREATE TABLE `crypto_withdrawal_methods` (
  `id` BIGINT NOT NULL AUTO_INCREMENT,
  `pid` INT NOT NULL COMMENT 'Icon ID from API; equals icon filename without extension',
  `name` VARCHAR(50) NOT NULL COMMENT 'Display name (ticker from API, e.g. TON, LTC)',
  `network` VARCHAR(100) NOT NULL COMMENT 'Network name from API (e.g. Toncoin, Litecoin)',
  `way_id` INT NOT NULL COMMENT 'External API way_id',
  `min_withdrawal` DECIMAL(10,2) NOT NULL DEFAULT 0.10,
  `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_pid` (`pid`),
  KEY `ix_way_id` (`way_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Seed initial methods (LTC, BNB, TRX, TON)
INSERT INTO `crypto_withdrawal_methods` (`pid`, `name`, `network`, `way_id`, `min_withdrawal`) VALUES
(30, 'LTC', 'Litecoin', 1, 0.10),
(130, 'BNB', 'BNB', 2, 0.10),
(90, 'TRX', 'TRON', 3, 0.10),
(235, 'TON', 'Toncoin', 4, 0.10);
