const { ethers } = require("hardhat"); async function main() { console.log("šŸ‘€ Viewing Real Stakes on BSC Mainnet"); console.log("===================================="); const targetUser = "0x41970Ce76b656030A79E7C1FA76FC4EB93980255"; console.log(`šŸŽÆ Target user: ${targetUser}`); // Connect to the existing BSC PACA contract const pacaAddress = process.env.PROXY_ADDRESS_BSC || "0x3fF44D639a4982A4436f6d737430141aBE68b4E1"; console.log(`šŸ”— PACA contract: ${pacaAddress}`); // Get contract factory and connect to existing contract const PacaFactory = await ethers.getContractFactory("PacaFinanceWithBoostAndScheduleBsc"); const paca = PacaFactory.attach(pacaAddress); console.log(`\nšŸ“Š Getting current stakes for ${targetUser}:`); console.log("=" * 60); try { const stakes = await paca.getStakes(targetUser); console.log(`šŸ“ˆ User has ${stakes.length} total stakes`); if (stakes.length > 0) { let totalStaked = 0n; let activeStakes = 0; let completedStakes = 0; for (let i = 0; i < stakes.length; i++) { const stake = stakes[i]; const isActive = !stake.complete && stake.amount > 0; const isCompleted = stake.complete; if (isActive) activeStakes++; if (isCompleted) completedStakes++; console.log(`\n šŸ“Œ Stake ${i + 1}:`); console.log(` Amount: ${ethers.formatEther(stake.amount)} ETH`); console.log(` Complete: ${stake.complete}`); console.log(` Status: ${isActive ? "🟢 ACTIVE" : isCompleted ? "šŸ”“ COMPLETED" : "🟔 UNKNOWN"}`); // Show more stake details if available if (stake.startTime) { const startDate = new Date(Number(stake.startTime) * 1000); console.log(` Start Time: ${startDate.toLocaleString()}`); } if (stake.endTime) { const endDate = new Date(Number(stake.endTime) * 1000); console.log(` End Time: ${endDate.toLocaleString()}`); } if (stake.rewardAmount) { console.log(` Rewards: ${ethers.formatEther(stake.rewardAmount)} ETH`); } totalStaked += stake.amount; } console.log(`\nšŸ’Ž SUMMARY:`); console.log(` Total Staked Amount: ${ethers.formatEther(totalStaked)} ETH`); console.log(` 🟢 Active Stakes: ${activeStakes}`); console.log(` šŸ”“ Completed Stakes: ${completedStakes}`); console.log(` šŸ“Š Total Stakes: ${stakes.length}`); if (activeStakes > 0) { console.log(`\nšŸŽÆ CLEARING WOULD:`); console.log(` āœ… Zero out ${activeStakes} active stakes`); console.log(` āœ… Mark all stakes as complete`); console.log(` āœ… Remove ${ethers.formatEther(totalStaked)} ETH from staking`); console.log(` šŸ’” This would be equivalent to emergency withdrawal`); } } else { console.log("šŸ“­ No stakes found for this user"); console.log(`\nšŸ’” This could mean:`); console.log(` • User has no active stakes`); console.log(` • All stakes have been withdrawn`); console.log(` • Connected to wrong contract address`); } } catch (error) { console.log(`āŒ Error reading stakes: ${error.message}`); // Try to get more info about the contract console.log(`\nšŸ” Contract Investigation:`); try { const contractCode = await ethers.provider.getCode(pacaAddress); console.log(` Contract has code: ${contractCode.length > 2 ? "āœ… YES" : "āŒ NO"}`); // Try to call a simple view function to test connectivity const owner = await paca.owner(); console.log(` Contract owner: ${owner}`); } catch (contractError) { console.log(` Contract check failed: ${contractError.message}`); } } // Also check vestings console.log(`\nšŸ”® Checking vestings for ${targetUser}:`); try { const vestings = await paca.getVestings(targetUser); console.log(`šŸ“ˆ User has ${vestings.length} total vestings`); if (vestings.length > 0) { let totalVested = 0n; let activeVestings = 0; for (let i = 0; i < vestings.length; i++) { const vesting = vestings[i]; const isActive = !vesting.complete && vesting.amount > 0; if (isActive) activeVestings++; console.log(`\n šŸ”’ Vesting ${i + 1}:`); console.log(` Amount: ${ethers.formatEther(vesting.amount)} tokens`); console.log(` Bonus: ${ethers.formatEther(vesting.bonus)} tokens`); console.log(` Complete: ${vesting.complete}`); console.log(` Status: ${isActive ? "🟢 ACTIVE" : "šŸ”“ COMPLETED"}`); if (vesting.lockedUntil) { const unlockDate = new Date(Number(vesting.lockedUntil) * 1000); console.log(` Unlocks: ${unlockDate.toLocaleString()}`); } totalVested += vesting.amount; } console.log(`\nšŸ’Ž VESTING SUMMARY:`); console.log(` Total Vested: ${ethers.formatEther(totalVested)} tokens`); console.log(` 🟢 Active Vestings: ${activeVestings}`); console.log(` šŸ“Š Total Vestings: ${vestings.length}`); } } catch (error) { console.log(`āš ļø Could not read vestings: ${error.message}`); } console.log("\nšŸ“‹ Investigation Complete"); console.log("========================="); console.log(`šŸŽÆ User: ${targetUser}`); console.log(`šŸ”— Contract: ${pacaAddress}`); console.log(`🌐 Network: BSC Mainnet`); console.log("\nšŸ’” To test clearing locally, run:"); console.log(" npx hardhat run scripts/test_clear_stakes.js --network hardhat"); } main() .then(() => process.exit(0)) .catch((error) => { console.error("šŸ’„ Investigation failed:", error); process.exit(1); });