describe("Lock Amount Constants Validation", () => {
it("demonstrates MAX_TOTAL_LOCKED_AMOUNT vs MAX_TOTAL_SUPPLY inconsistency", async function() {
this.timeout(600000);
const MAX_LOCK_AMOUNT = ethers.parseEther("10000000");
const MAX_TOTAL_LOCKED = ethers.parseEther("1000000000");
const MAX_TOTAL_SUPPLY = ethers.parseEther("100000000");
const individualAmount = ethers.parseEther("9999999");
const numUsers = 101;
const veRAACTokenAddress = await veRAACToken.getAddress();
console.log("\n=== Testing Lock Amount Constants Inconsistency ===");
console.log(`MAX_TOTAL_LOCKED_AMOUNT: ${ethers.formatEther(MAX_TOTAL_LOCKED)} RAAC (unused)`);
console.log(`Individual Lock Amount: ${ethers.formatEther(individualAmount)} RAAC`);
console.log(`Number of Users: ${numUsers}`);
console.log(`Target Total: ${ethers.formatEther(individualAmount * BigInt(numUsers))} RAAC`);
const allSigners = await ethers.getSigners();
const testSigners = allSigners.slice(0, numUsers);
const BATCH_SIZE = 5;
for (let i = 0; i < numUsers; i += BATCH_SIZE) {
const batchEnd = Math.min(i + BATCH_SIZE, numUsers);
for (let j = i; j < batchEnd; j++) {
await raacToken.mint(testSigners[j].address, individualAmount);
await raacToken.connect(testSigners[j]).approve(veRAACTokenAddress, individualAmount);
}
console.log(`Setup complete for users ${i} to ${batchEnd - 1}`);
}
let totalLocked = 0n;
let reachedMAXSupply = false;
for (let i = 0; i < numUsers; i++) {
try {
const tx = await veRAACToken.connect(testSigners[i]).lock(
individualAmount,
365 * 24 * 3600
);
await tx.wait();
totalLocked += individualAmount;
console.log(`Lock ${i + 1} created - Total Locked: ${ethers.formatEther(totalLocked)} RAAC`);
if (totalLocked > MAX_TOTAL_LOCKED) {
console.log(`\n!!! Successfully exceeded MAX_TOTAL_LOCKED_AMOUNT (1B) !!!`);
console.log(`Amount over limit: ${ethers.formatEther(totalLocked - MAX_TOTAL_LOCKED)} RAAC`);
break;
}
} catch (error) {
if (error.message.includes("TotalSupplyLimitExceeded")) {
reachedMAXSupply = true;
console.log(`\n!!! Hit MAX_TOTAL_SUPPLY limit (100M) at ${ethers.formatEther(totalLocked)} RAAC`);
} else {
console.log(`\nError at ${ethers.formatEther(totalLocked)} total locked:`, error.message);
}
break;
}
}
const finalSupply = await veRAACToken.totalSupply();
console.log("\n=== Final State ===");
console.log(`Total RAAC Locked: ${ethers.formatEther(totalLocked)} RAAC`);
console.log(`Final veToken Supply: ${ethers.formatEther(finalSupply)}`);
if (reachedMAXSupply) {
console.log("\nCritical Finding:");
console.log("1. MAX_TOTAL_LOCKED_AMOUNT (1B) is unreachable");
console.log("2. MAX_TOTAL_SUPPLY (100M) prevents locking more than 100M tokens");
console.log("3. Contract has contradicting limits: claims to allow 1B locked but caps at 100M");
}
if (!reachedMAXSupply && totalLocked <= MAX_TOTAL_LOCKED) {
console.log("\nTest Failed:");
console.log("Could not prove if MAX_TOTAL_LOCKED_AMOUNT is enforced or reachable");
}
});
});