// Global CBDC Tokenomics Framework (GCTF) - Type Definitions

export enum CBDCUnitType {
  RETAIL = 'rCBDC', // Retail CBDC - Consumer money
  WHOLESALE = 'wCBDC', // Wholesale CBDC - Interbank settlement token
  INSTITUTIONAL = 'iCBDC', // Institutional CBDC - For regulated corporates, supranationals
}

export enum CBDCIssuancePolicy {
  DEMAND_DRIVEN = 'DEMAND_DRIVEN',
  FIXED_SUPPLY = 'FIXED_SUPPLY',
  RESERVE_BACKED = 'RESERVE_BACKED',
  HYBRID = 'HYBRID',
}

export interface CBDCSupplyMechanics {
  sovereignBankId: string;
  unitType: CBDCUnitType;
  currentSupply: string; // Decimal as string
  maxSupply?: string; // Optional max supply cap
  issuancePolicy: CBDCIssuancePolicy;
  reserveBacking?: string; // For reserve-backed CBDCs
  commodityBacking?: string; // For commodity-backed CBDCs
  lastIssuance: Date;
  lastBurn: Date;
}

export interface CBDCIssuanceRule {
  demandAdjustment: number; // Adjustment based on demand
  settlementVolume: string; // Current settlement volume
  factor: number; // Issuance factor (0-1)
  stressPenalties: number; // Penalties during stress periods
  calculatedSupply: string; // CBDC_new = demand_adjustment + (settlement_volume * factor) - stress_penalties
}

export interface CBDCVelocityControl {
  sovereignBankId: string;
  unitType: CBDCUnitType;
  transactionVelocityCap?: {
    daily: number;
    weekly: number;
    monthly: number;
  };
  spendingCategoryRestrictions?: {
    category: string;
    maxAmount: string;
    allowed: boolean;
  }[];
  crossBorderRoutingLimit?: {
    maxAmount: string;
    maxTransactions: number;
    timeWindow: 'DAILY' | 'WEEKLY' | 'MONTHLY';
  };
  sovereignQuarantineMode?: boolean; // Active during crises
  quarantineStartDate?: Date;
  quarantineEndDate?: Date;
}

export interface CBDCTokenomicsConfig {
  sovereignBankId: string;
  unitType: CBDCUnitType;
  supplyMechanics: CBDCSupplyMechanics;
  velocityControls?: CBDCVelocityControl;
  monetaryPolicy: {
    interestRate?: number; // If applicable
    reserveRequirement?: number;
    fxBandWidth?: number;
  };
  programmableCompliance: {
    enabled: boolean;
    rules: string[]; // Smart contract rule identifiers
  };
}

export interface CBDCIssuanceRequest {
  sovereignBankId: string;
  unitType: CBDCUnitType;
  amount: string;
  reason: string;
  operatorIdentity: string;
}

export interface CBDCBurnRequest {
  sovereignBankId: string;
  unitType: CBDCUnitType;
  amount: string;
  reason: string;
  operatorIdentity: string;
}

export interface CBDCSupplyAdjustment {
  sovereignBankId: string;
  unitType: CBDCUnitType;
  adjustment: string; // Positive for issuance, negative for burn
  reason: string;
  timestamp: Date;
}

