const { EVM_CANDIDATE_CONFIG } = require('./evmCandidateConfig');

const TOKEN_DISTRIBUTION_VERSION = 'plais-token-distribution/v0.2';
const TOTAL_SUPPLY = '10000000000';
const BASIS_POINTS = 10000;

const TOKEN_DISTRIBUTION = Object.freeze([
  Object.freeze({
    id: 'ecosystem_user_rewards',
    label: 'Ecosystem and user rewards',
    allocationBps: 3200,
    tgeUnlockBps: 50,
    cliffMonths: 0,
    vestingMonths: 120,
    purpose: 'PoSS service, content, commerce, moderation, and verified ecosystem participation rewards.'
  }),
  Object.freeze({
    id: 'node_storage_validator_rewards',
    label: 'Node, storage, and validator rewards',
    allocationBps: 2000,
    tgeUnlockBps: 25,
    cliffMonths: 0,
    vestingMonths: 120,
    purpose: 'Verified storage, restore, uptime, node, and validator incentives under approved policies.'
  }),
  Object.freeze({
    id: 'foundation_treasury',
    label: 'Foundation treasury',
    allocationBps: 1500,
    tgeUnlockBps: 25,
    cliffMonths: 12,
    vestingMonths: 60,
    purpose: 'Audited operations, infrastructure, legal, security, and ecosystem continuity.'
  }),
  Object.freeze({
    id: 'core_team_contributors',
    label: 'Core team and contributors',
    allocationBps: 1200,
    tgeUnlockBps: 0,
    cliffMonths: 12,
    vestingMonths: 36,
    purpose: 'Long-term contributors subject to service and clawback agreements.'
  }),
  Object.freeze({
    id: 'ecosystem_partners_grants',
    label: 'Ecosystem partners and grants',
    allocationBps: 800,
    tgeUnlockBps: 50,
    cliffMonths: 6,
    vestingMonths: 48,
    purpose: 'Published grants, integrations, developer programs, and strategic ecosystem work.'
  }),
  Object.freeze({
    id: 'market_liquidity',
    label: 'Market and liquidity infrastructure',
    allocationBps: 600,
    tgeUnlockBps: 450,
    cliffMonths: 0,
    vestingMonths: 24,
    purpose: 'Exchange deposits, market-making loans, and disclosed liquidity programs.'
  }),
  Object.freeze({
    id: 'community_launch',
    label: 'Community launch and eligibility program',
    allocationBps: 500,
    tgeUnlockBps: 200,
    cliffMonths: 0,
    vestingMonths: 24,
    purpose: 'Separately approved launch eligibility, education, and community distribution.'
  }),
  Object.freeze({
    id: 'security_insurance_reserve',
    label: 'Security and insurance reserve',
    allocationBps: 200,
    tgeUnlockBps: 0,
    cliffMonths: 24,
    vestingMonths: 36,
    purpose: 'Audited emergency remediation and user-protection measures; not routine operations.'
  })
]);

const TOKEN_DISTRIBUTION_POLICY = Object.freeze({
  version: TOKEN_DISTRIBUTION_VERSION,
  status: EVM_CANDIDATE_CONFIG.externalTransfersEnabled
    ? 'candidate-policy-user-transfers-enabled-no-public-issuance'
    : 'candidate-policy-locked-no-public-issuance',
  supply: TOTAL_SUPPLY,
  decimals: 18,
  currentPublicCirculation: '0',
  tgeMaximumCirculationBps: 800,
  publicIssuanceApproved: false,
  externalTransfersEnabled: EVM_CANDIDATE_CONFIG.externalTransfersEnabled,
  privateSaleAllocationBps: 0,
  scheduleChangeNoticeDays: 60,
  disclosureCadence: 'monthly',
  categories: TOKEN_DISTRIBUTION
});

module.exports = {
  BASIS_POINTS,
  TOKEN_DISTRIBUTION,
  TOKEN_DISTRIBUTION_POLICY,
  TOKEN_DISTRIBUTION_VERSION,
  TOTAL_SUPPLY
};
