import { ethers } from "hardhat";

async function main() {
  const [deployer] = await ethers.getSigners();

  if (!deployer) {
    console.error("❌ No deployer account found. Have you set PLATFORM_TREASURY_PRIVATE_KEY in your .env?");
    process.exit(1);
  }

  console.log("=====================================");
  console.log("🎣 VibeWork Phase 18: Bot Honeypot");
  console.log("=====================================");
  console.log("Deploying from:", deployer.address);
  
  const balance = await ethers.provider.getBalance(deployer.address);
  console.log("Balance:", ethers.formatEther(balance), "ETH");

  if (balance === 0n) {
    console.error("❌ INSUFFICIENT FUNDS. You need a few dollars of Base ETH to deploy.");
    console.error("Please fund your Treasury wallet on Base Mainnet:", deployer.address);
    process.exit(1);
  }

  console.log("\n🚀 Deploying $VIBE Token (5% Tax to Treasury)...");
  
  // The treasury is the deployer wallet itself
  const VibeToken = await ethers.getContractFactory("VibeToken");
  const token = await VibeToken.deploy(deployer.address);

  await token.waitForDeployment();

  const tokenAddress = await token.getAddress();
  console.log("\n✅ $VIBE Deployed Successfully!");
  console.log("📍 Contract Address:", tokenAddress);
  console.log("\nNEXT STEPS:");
  console.log("1. Go to Uniswap V3 on Base Mainnet.");
  console.log(`2. Create a new pool for ${tokenAddress} / WETH.`);
  console.log("3. Add ~$5 worth of ETH and your total supply of $VIBE.");
  console.log("4. Watch Sniper Bots immediately buy the token, while 5% of their purchase goes directly into your Treasury Wallet!");
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
