Staking tokens has no effect on reward distribution, as rewards are based solely on the user's ve token balance.
import { time } from "@nomicfoundation/hardhat-network-helpers";
import { expect } from "chai";
import hre from "hardhat";
const { ethers } = hre;
describe("RAACGauge", () => {
let raacGauge;
let gaugeController;
let veRAACToken;
let rewardToken;
let stakingToken;
let owner;
let user1;
let user2;
let snapshotId;
const WEEK = 7 * 24 * 3600;
const WEIGHT_PRECISION = 10000;
beforeEach(async () => {
snapshotId = await network.provider.send('evm_snapshot');
[owner, user1, user2,] = await ethers.getSigners();
const MockToken = await ethers.getContractFactory("MockToken");
rewardToken = await MockToken.deploy("Reward Token", "RWD", 18);
veRAACToken = await MockToken.deploy("veRAAC Token", "veRAAC", 18);
stakingToken = await MockToken.deploy("Stakign Token", "STK", 18);
await veRAACToken.mint(user1.address, ethers.parseEther("1000"));
await veRAACToken.mint(user2.address, ethers.parseEther("1000"));
await stakingToken.mint(user1.address, ethers.parseEther("1000"));
await stakingToken.mint(user2.address, ethers.parseEther("1000"));
const GaugeController = await ethers.getContractFactory("GaugeController");
gaugeController = await GaugeController.deploy(await veRAACToken.getAddress());
const currentTime = BigInt(await time.latest());
const nextWeekStart = ((currentTime / BigInt(WEEK)) + 3n) * BigInt(WEEK);
await time.setNextBlockTimestamp(Number(nextWeekStart));
await network.provider.send("evm_mine");
const RAACGauge = await ethers.getContractFactory("RAACGauge");
raacGauge = await RAACGauge.deploy(
await rewardToken.getAddress(),
await stakingToken.getAddress(),
await gaugeController.getAddress()
);
await raacGauge.grantRole(await raacGauge.CONTROLLER_ROLE(), owner.address);
await rewardToken.connect(user1).approve(raacGauge.getAddress(), ethers.MaxUint256);
await rewardToken.connect(user2).approve(raacGauge.getAddress(), ethers.MaxUint256);
await gaugeController.grantRole(await gaugeController.GAUGE_ADMIN(), owner.address);
await gaugeController.addGauge(await raacGauge.getAddress(), 0, WEIGHT_PRECISION);
await time.increase(WEEK);
await gaugeController.connect(user1).vote(await raacGauge.getAddress(), WEIGHT_PRECISION);
await raacGauge.setWeeklyEmission(ethers.parseEther("10000"));
await rewardToken.mint(raacGauge.getAddress(), ethers.parseEther("100000"));
await raacGauge.setBoostParameters(
25000,
10000,
WEEK
);
await raacGauge.setInitialWeight(5000);
await network.provider.send("evm_mine");
});
afterEach(async () => {
await network.provider.send('evm_revert', [snapshotId]);
});
describe("Reward Distribution", () => {
beforeEach(async () => {
await stakingToken.connect(user1).approve(raacGauge.getAddress(), ethers.MaxUint256);
await raacGauge.connect(user1).stake(ethers.parseEther("1000"));
await raacGauge.connect(user1).voteEmissionDirection(5000);
});
it("Stakes are effectless", async () => {
await raacGauge.notifyRewardAmount(ethers.parseEther("1000"));
await time.increase(WEEK / 2);
await raacGauge.connect(user1).getReward();
await raacGauge.connect(user2).getReward();
const balance1 = await rewardToken.balanceOf(user1.address);
const balance2 = await rewardToken.balanceOf(user2.address);
console.log("User1 Reward Balance:", balance1.toString());
console.log("User2 Reward Balance:", balance2.toString());
expect(balance1).to.be.gt(0);
expect(balance2).to.be.gt(0);
});
});
});
Stakes have no effect on rewards.
Ensure that the staking amount is integrated into the reward calculation logic to accurately reflect user contributions.