const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
  const MarketPair = sequelize.define('MarketPair', {

    id: {
      type: DataTypes.BIGINT.UNSIGNED,
      autoIncrement: true,
      primaryKey: true
    },

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

    baseAssetId: {
      type: DataTypes.BIGINT.UNSIGNED,
      allowNull: false,
      field: 'base_asset_id'
    },

    quoteAssetId: {
      type: DataTypes.BIGINT.UNSIGNED,
      allowNull: false,
      field: 'quote_asset_id'
    },
    name:{
      type: DataTypes.STRING(299),
    },
    type: {
      type: DataTypes.ENUM('spot','fx','stock','commodity'),
      defaultValue: 'spot'
    },

    spread: {
      type: DataTypes.DECIMAL(20,8),
      defaultValue: 0.01,
    },

    pricePrecision: {
      type: DataTypes.DECIMAL(20,8),
      defaultValue: 0.01,
      field: 'price_precision'
    },
   
    priceVolatility: {
      type: DataTypes.DECIMAL(20,8),
      defaultValue: 0.001,
      field: 'price_volatility'
    },

    priceTrend: {
      type: DataTypes.DECIMAL(20,8),
      defaultValue: 0.001,
      field: 'price_trend'
    },

    quantityPrecision: {
      type: DataTypes.DECIMAL(20,8),
      defaultValue: 0.001,
      field: 'quantity_precision'
    },

    quantityPrecision: {
      type: DataTypes.DECIMAL(20,8),
      defaultValue: 0.001,
      field: 'quantity_precision'
    },


    decimals: {
      type: DataTypes.INTEGER,
      defaultValue: 8,
    },

   

    minOrderSize: {
      type: DataTypes.DECIMAL(20,10),
      field: 'min_order_size'
    },

    maxOrderSize: {
      type: DataTypes.DECIMAL(20,10),
      field: 'max_order_size'
    },
    optionsEnabled:{
      type: DataTypes.BOOLEAN,
      field: "options_enabled",
      defaultValue: 1
    },
    tradingEnabled:{
      type: DataTypes.BOOLEAN,
      field: "trading_enabled",
      defaultValue: 1
    },
    status: {
      type: DataTypes.ENUM('active','inactive'),
      defaultValue: 'active'
    }

  }, {
    tableName: 'market_pairs',
    timestamps: true,
    underscored: true
  });

  return MarketPair;
};
