The auction contract does not provide a mechanism to reclaim unsold ZENO tokens after the auction ends. If the auction does not sell out, the remaining tokens stay locked in the contract indefinitely, resulting in a loss of accessible funds.
import { expect } from "chai";
import hre from "hardhat";
const { ethers } = hre;
describe("Auction Contract - Unsold Token Handling Test", function () {
let Auction, auction, owner, addr1, businessAddress;
let ZENO, zeno, USDC, usdc;
let startTime, endTime;
beforeEach(async function () {
[owner, addr1, businessAddress] = await ethers.getSigners();
USDC = await ethers.getContractFactory("MockUSDC");
usdc = await USDC.deploy();
await usdc.waitForDeployment();
console.log(`MockUSDC deployed at: ${await usdc.getAddress()}`);
const maturityDate = Math.floor(Date.now() / 1000) + 365 * 24 * 60 * 60;
ZENO = await ethers.getContractFactory("ZENO");
zeno = await ZENO.deploy(
await usdc.getAddress(),
maturityDate,
"ZENO Token",
"ZENO",
owner.address
);
await zeno.waitForDeployment();
console.log(`ZENO Token deployed at: ${await zeno.getAddress()}`);
const latestBlock = await ethers.provider.getBlock("latest");
startTime = latestBlock.timestamp + 10;
endTime = startTime + 3600;
const startingPrice = ethers.parseUnits("100", 18);
const reservePrice = ethers.parseUnits("50", 18);
const totalAllocated = ethers.parseUnits("1000", 18);
Auction = await ethers.getContractFactory("Auction");
auction = await Auction.deploy(
await zeno.getAddress(),
await usdc.getAddress(),
businessAddress.address,
startTime,
endTime,
startingPrice,
reservePrice,
totalAllocated,
owner.address
);
await auction.waitForDeployment();
console.log(`Auction Contract deployed at: ${await auction.getAddress()}`);
await zeno.mint(await auction.getAddress(), totalAllocated);
});
it("should check if unsold tokens remain in the auction contract after the auction ends", async function () {
console.log("Moving time forward to auction end...");
await ethers.provider.send("evm_setNextBlockTimestamp", [endTime + 1]);
await ethers.provider.send("evm_mine");
console.log("Auction has ended.");
const auctionBalanceAfterEnd = await zeno.balanceOf(await auction.getAddress());
console.log(`ZENO balance in auction contract after auction: ${ethers.formatUnits(auctionBalanceAfterEnd, 18)} ZENO`);
expect(auctionBalanceAfterEnd).to.be.gt(0);
});
it("should verify that the owner did not automatically receive unsold tokens", async function () {
console.log("Moving time forward to auction end...");
await ethers.provider.send("evm_setNextBlockTimestamp", [endTime + 1]);
await ethers.provider.send("evm_mine");
console.log("Auction has ended.");
const ownerBalanceAfterEnd = await zeno.balanceOf(owner.address);
console.log(`ZENO balance of owner after auction: ${ethers.formatUnits(ownerBalanceAfterEnd, 18)} ZENO`);
expect(ownerBalanceAfterEnd).to.be.equal(0);
});
});