Commit before cuna
This commit is contained in:
153
scripts/view_real_stakes.js
Normal file
153
scripts/view_real_stakes.js
Normal file
@@ -0,0 +1,153 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user