const {DataTypes} = require("sequelize")
module.exports = (sequelize) => {
  return sequelize.define(
    "Market",
    {
      id: { type: DataTypes.BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true },
      kind: { type: DataTypes.ENUM("spot", "forex_cfd", "perp"), allowNull: false },

      symbol: { type: DataTypes.STRING(30), allowNull: false, unique: true },

      base_asset_id: { type: DataTypes.BIGINT.UNSIGNED, allowNull: false },
      quote_asset_id: { type: DataTypes.BIGINT.UNSIGNED, allowNull: false },

      status: { type: DataTypes.ENUM("active", "halted", "inactive"), allowNull: false, defaultValue: "active" },

      price_decimals: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 5 },
      qty_decimals: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 6 },
      min_qty: { type: DataTypes.DECIMAL(30, 12), allowNull: false, defaultValue: 0 },
      min_notional: { type: DataTypes.DECIMAL(30, 12), allowNull: false, defaultValue: 0 },

      contract_type: { type: DataTypes.ENUM("none", "cfd", "perp"), allowNull: false, defaultValue: "none" },
      contract_size: { type: DataTypes.DECIMAL(30, 12), allowNull: false, defaultValue: 1 },
      settlement_asset_id: { type: DataTypes.BIGINT.UNSIGNED, allowNull: true },
    },
    {
      tableName: "markets",
      underscored: true,
      timestamps: true,
    }
  );
};