@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
436 lines (435 loc) • 29.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const hardhat_1 = require("hardhat");
const chai_1 = require("chai");
const common_1 = require("./helpers/common");
const deploy_1 = require("./helpers/deploy");
const exceptions_1 = require("./helpers/exceptions");
const mocha_1 = require("mocha");
const fundTreasury_1 = require("./helpers/fundTreasury");
const typechain_types_1 = require("../typechain-types");
const local_1 = require("@repo/config/contracts/envs/local");
const helpers_1 = require("../scripts/helpers");
const events_1 = require("./helpers/events");
const helpers_2 = require("./helpers");
(0, mocha_1.describe)("Treasury - @shard7", () => {
let treasuryProxy;
let b3tr;
let vot3;
let galaxyMember;
let owner;
let otherAccount;
(0, mocha_1.before)(async () => {
const config = (0, local_1.createLocalConfig)();
config.B3TR_GOVERNOR_DEPOSIT_THRESHOLD = 1;
const info = await (0, deploy_1.getOrDeployContractInstances)({
forceDeploy: true,
config,
});
treasuryProxy = info.treasury;
owner = info.owner;
otherAccount = info.otherAccount;
b3tr = info.b3tr;
vot3 = info.vot3;
galaxyMember = info.galaxyMember;
await treasuryProxy.setTransferLimitVET(hardhat_1.ethers.parseEther("1"));
await treasuryProxy.setTransferLimitToken(await b3tr.getAddress(), hardhat_1.ethers.parseEther("1"));
await treasuryProxy.setTransferLimitToken(await vot3.getAddress(), hardhat_1.ethers.parseEther("1"));
await (0, fundTreasury_1.fundTreasuryVTHO)(await treasuryProxy.getAddress(), hardhat_1.ethers.parseEther("10"));
await (0, fundTreasury_1.fundTreasuryVET)(await treasuryProxy.getAddress(), 10);
const operatorRole = await b3tr.MINTER_ROLE();
await b3tr.grantRole(operatorRole, owner);
await b3tr.mint(await treasuryProxy.getAddress(), hardhat_1.ethers.parseEther("20"));
});
(0, mocha_1.describe)("Initilization", () => {
(0, mocha_1.it)("Should revert if B3TR is set to zero address in initilisation", async () => {
const config = (0, local_1.createLocalConfig)();
const { owner, vot3 } = await (0, deploy_1.getOrDeployContractInstances)({
forceDeploy: false,
config,
});
await (0, chai_1.expect)((0, helpers_1.deployProxy)("Treasury", [
helpers_2.ZERO_ADDRESS,
await vot3.getAddress(),
owner.address,
owner.address,
owner.address,
owner.address,
config.TREASURY_TRANSFER_LIMIT_VET,
config.TREASURY_TRANSFER_LIMIT_B3TR,
config.TREASURY_TRANSFER_LIMIT_VOT3,
config.TREASURY_TRANSFER_LIMIT_VTHO,
])).to.be.reverted;
});
(0, mocha_1.it)("Should revert if VOT3 is set to zero address in initilisation", async () => {
const config = (0, local_1.createLocalConfig)();
const { owner, b3tr } = await (0, deploy_1.getOrDeployContractInstances)({
forceDeploy: false,
config,
});
await (0, chai_1.expect)((0, helpers_1.deployProxy)("Treasury", [
await b3tr.getAddress(),
helpers_2.ZERO_ADDRESS,
owner.address,
owner.address,
owner.address,
owner.address,
config.TREASURY_TRANSFER_LIMIT_VET,
config.TREASURY_TRANSFER_LIMIT_B3TR,
config.TREASURY_TRANSFER_LIMIT_VOT3,
config.TREASURY_TRANSFER_LIMIT_VTHO,
])).to.be.reverted;
});
(0, mocha_1.it)("Should revert if admin is set to zero address in initilisation", async () => {
const config = (0, local_1.createLocalConfig)();
const { owner, vot3, b3tr } = await (0, deploy_1.getOrDeployContractInstances)({
forceDeploy: false,
config,
});
await (0, chai_1.expect)((0, helpers_1.deployProxy)("Treasury", [
await b3tr.getAddress(),
await vot3.getAddress(),
owner.address,
helpers_2.ZERO_ADDRESS,
owner.address,
owner.address,
config.TREASURY_TRANSFER_LIMIT_VET,
config.TREASURY_TRANSFER_LIMIT_B3TR,
config.TREASURY_TRANSFER_LIMIT_VOT3,
config.TREASURY_TRANSFER_LIMIT_VTHO,
])).to.be.reverted;
});
});
(0, mocha_1.describe)("Tokens", () => {
(0, mocha_1.describe)("VTHO", () => {
(0, mocha_1.it)("should transfer VTHO", async () => {
if (hardhat_1.network.name == "hardhat") {
return console.log("Skipping VTHO transfer test on hardhat network as hardcoded VTHO contract address in Treasury does not exist");
}
const balance = await treasuryProxy.getVTHOBalance();
await (0, chai_1.expect)(treasuryProxy.transferVTHO(otherAccount.address, hardhat_1.ethers.parseEther("1"))).not.to.be.reverted;
(0, chai_1.expect)(await treasuryProxy.getVTHOBalance()).to.be.lessThan(balance);
});
(0, mocha_1.it)("should revert if not called by GOVERNANCE_ROLE", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).transferVTHO(otherAccount.address, hardhat_1.ethers.parseEther("1")));
});
(0, mocha_1.it)("only governance can transfer VTHO", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).transferVTHO(otherAccount.address, hardhat_1.ethers.parseEther("1")));
});
(0, mocha_1.it)("should revert if contract is paused", async () => {
await treasuryProxy.pause();
await (0, exceptions_1.catchRevert)(treasuryProxy.transferVTHO(otherAccount.address, hardhat_1.ethers.parseEther("1")));
await treasuryProxy.unpause();
});
});
(0, mocha_1.describe)("VET", () => {
(0, mocha_1.it)("should transfer VET", async () => {
//Since timelock is the only with governance role, let's grant to a wallet to simulate
await treasuryProxy.connect(owner).grantRole(await treasuryProxy.GOVERNANCE_ROLE(), owner.address);
(0, chai_1.expect)(await treasuryProxy.getVETBalance()).to.eql(hardhat_1.ethers.parseEther("10"));
//Transfer VET to other account using the wallet with governance role
await treasuryProxy.connect(owner).transferVET(otherAccount.address, hardhat_1.ethers.parseEther("1"));
(0, chai_1.expect)(await treasuryProxy.getVETBalance()).to.eql(hardhat_1.ethers.parseEther("9"));
});
(0, mocha_1.it)("should revert if not enough balance", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferVET(otherAccount.address, hardhat_1.ethers.parseEther("11")));
});
(0, mocha_1.it)("should revert if not called by GOVERNANCE_ROLE", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).transferVET(otherAccount.address, hardhat_1.ethers.parseEther("1")));
});
(0, mocha_1.it)("Should revert if transfer exceeds limit", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferVET(otherAccount.address, hardhat_1.ethers.parseEther("2")));
});
(0, mocha_1.it)("Should be able to set transfer limit for VET", async () => {
const tx = await treasuryProxy.connect(owner).setTransferLimitVET(hardhat_1.ethers.parseEther("2"));
const receipt = await tx.wait();
const name = (0, events_1.getEventName)(receipt, treasuryProxy);
(0, chai_1.expect)(name).to.eql("TransferLimitVETUpdated");
(0, chai_1.expect)(await treasuryProxy.getTransferLimitVET()).to.eql(hardhat_1.ethers.parseEther("2"));
await treasuryProxy.transferVET(otherAccount.address, hardhat_1.ethers.parseEther("2"));
(0, chai_1.expect)(await treasuryProxy.getVETBalance()).to.eql(hardhat_1.ethers.parseEther("7"));
await (0, chai_1.expect)(treasuryProxy.connect(otherAccount).setTransferLimitVET(hardhat_1.ethers.parseEther("2"))).to.be.reverted; // not admin
});
});
(0, mocha_1.describe)("B3TR", () => {
(0, mocha_1.it)("should transfer B3TR", async () => {
(0, chai_1.expect)(await treasuryProxy.getB3TRBalance()).to.eql(hardhat_1.ethers.parseEther("20"));
await treasuryProxy.transferB3TR(otherAccount.address, hardhat_1.ethers.parseEther("1"));
(0, chai_1.expect)(await treasuryProxy.getB3TRBalance()).to.eql(hardhat_1.ethers.parseEther("19"));
});
(0, mocha_1.it)("should convert B3TR and recieve VOT3", async () => {
await treasuryProxy.convertB3TR(hardhat_1.ethers.parseEther("10"));
(0, chai_1.expect)(await treasuryProxy.getB3TRBalance()).to.eql(hardhat_1.ethers.parseEther("9"));
(0, chai_1.expect)(await treasuryProxy.getVOT3Balance()).to.eql(hardhat_1.ethers.parseEther("10"));
});
(0, mocha_1.it)("should revert if not enough balance", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferB3TR(otherAccount.address, hardhat_1.ethers.parseEther("11")));
});
(0, mocha_1.it)("should revert if not called by GOVERNANCE_ROLE", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).transferB3TR(otherAccount.address, hardhat_1.ethers.parseEther("1")));
});
(0, mocha_1.it)("should revert if contract is paused", async () => {
await treasuryProxy.pause();
await (0, exceptions_1.catchRevert)(treasuryProxy.transferB3TR(otherAccount.address, hardhat_1.ethers.parseEther("1")));
await treasuryProxy.unpause();
});
(0, mocha_1.it)("should revert if b3tr contract is paused", async () => {
await b3tr.pause();
await (0, exceptions_1.catchRevert)(treasuryProxy.transferB3TR(otherAccount.address, hardhat_1.ethers.parseEther("1")));
await b3tr.unpause();
});
(0, mocha_1.it)("can't convert more than balance", async () => {
const balance = await treasuryProxy.getB3TRBalance();
await (0, exceptions_1.catchRevert)(treasuryProxy.convertB3TR(balance + 1n));
});
(0, mocha_1.it)("should return correct address for contract", async () => {
(0, chai_1.expect)(await treasuryProxy.b3trAddress()).to.eql(await b3tr.getAddress());
});
(0, mocha_1.it)("should revert convert if contract is paused", async () => {
await treasuryProxy.pause();
await (0, exceptions_1.catchRevert)(treasuryProxy.convertB3TR(hardhat_1.ethers.parseEther("1")));
await treasuryProxy.unpause();
});
(0, mocha_1.it)("Should revert if transfer exceeds limit", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferB3TR(otherAccount.address, hardhat_1.ethers.parseEther("2")));
});
(0, mocha_1.it)("Should be able to set transfer limit", async () => {
await treasuryProxy.connect(owner).setTransferLimitToken(await b3tr.getAddress(), hardhat_1.ethers.parseEther("2"));
(0, chai_1.expect)(await treasuryProxy.getTransferLimitToken(await b3tr.getAddress())).to.eql(hardhat_1.ethers.parseEther("2"));
await treasuryProxy.transferB3TR(otherAccount.address, hardhat_1.ethers.parseEther("2"));
(0, chai_1.expect)(await treasuryProxy.getB3TRBalance()).to.eql(hardhat_1.ethers.parseEther("7"));
await (0, chai_1.expect)(treasuryProxy.connect(otherAccount).setTransferLimitToken(await b3tr.getAddress(), hardhat_1.ethers.parseEther("2"))).to.be.reverted; // not admin
});
});
(0, mocha_1.describe)("VOT3", () => {
(0, mocha_1.it)("should transfer VOT3", async () => {
(0, chai_1.expect)(await treasuryProxy.getVOT3Balance()).to.eql(hardhat_1.ethers.parseEther("10"));
await treasuryProxy.transferVOT3(otherAccount.address, hardhat_1.ethers.parseEther("1"));
(0, chai_1.expect)(await treasuryProxy.getVOT3Balance()).to.eql(hardhat_1.ethers.parseEther("9"));
});
(0, mocha_1.it)("should convert VOT3 and recieve B3TR", async () => {
await treasuryProxy.convertVOT3(hardhat_1.ethers.parseEther("5"));
(0, chai_1.expect)(await treasuryProxy.getB3TRBalance()).to.eql(hardhat_1.ethers.parseEther("12"));
(0, chai_1.expect)(await treasuryProxy.getVOT3Balance()).to.eql(hardhat_1.ethers.parseEther("4"));
});
(0, mocha_1.it)("should revert if not enough converted B3TR to convert back", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.convertVOT3(hardhat_1.ethers.parseEther("11")));
});
(0, mocha_1.it)("should revert if not called by GOVERNANCE_ROLE", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).transferVOT3(otherAccount.address, hardhat_1.ethers.parseEther("1")));
});
(0, mocha_1.it)("should revert if contract is paused", async () => {
await treasuryProxy.pause();
await (0, exceptions_1.catchRevert)(treasuryProxy.convertVOT3(hardhat_1.ethers.parseEther("1")));
await treasuryProxy.unpause();
});
(0, mocha_1.it)("should return correct address for contract", async () => {
(0, chai_1.expect)(await treasuryProxy.vot3Address()).to.eql(await vot3.getAddress());
});
(0, mocha_1.it)("should revert if not enough balance", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferVOT3(otherAccount.address, hardhat_1.ethers.parseEther("6")));
});
(0, mocha_1.it)("should revert if vot3 contract is paused", async () => {
await vot3.pause();
await (0, exceptions_1.catchRevert)(treasuryProxy.transferVOT3(otherAccount.address, hardhat_1.ethers.parseEther("1")));
await vot3.unpause();
});
(0, mocha_1.it)("Should revert if transfer exceeds limit", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferVOT3(otherAccount.address, hardhat_1.ethers.parseEther("2")));
});
(0, mocha_1.it)("Should be able to set transfer limit", async () => {
await treasuryProxy.convertB3TR(hardhat_1.ethers.parseEther("10"));
const tx = await treasuryProxy
.connect(owner)
.setTransferLimitToken(await vot3.getAddress(), hardhat_1.ethers.parseEther("2"));
const receipt = await tx.wait();
const name = (0, events_1.getEventName)(receipt, treasuryProxy);
(0, chai_1.expect)(name).to.eql("TransferLimitUpdated");
(0, chai_1.expect)(await treasuryProxy.getTransferLimitToken(await vot3.getAddress())).to.eql(hardhat_1.ethers.parseEther("2"));
await treasuryProxy.transferVOT3(otherAccount.address, hardhat_1.ethers.parseEther("2"));
(0, chai_1.expect)(await treasuryProxy.getVOT3Balance()).to.eql(hardhat_1.ethers.parseEther("12"));
await (0, chai_1.expect)(treasuryProxy.connect(otherAccount).setTransferLimitToken(await vot3.getAddress(), hardhat_1.ethers.parseEther("2"))).to.be.reverted; // not admin
});
});
(0, mocha_1.describe)("ERC20", () => {
(0, mocha_1.it)("should transfer ERC20", async () => {
await b3tr.mint(await treasuryProxy.getAddress(), hardhat_1.ethers.parseEther("10"));
(0, chai_1.expect)(await treasuryProxy.getB3TRBalance()).to.eql(hardhat_1.ethers.parseEther("12"));
(0, chai_1.expect)(await treasuryProxy.getTokenBalance(await b3tr.getAddress())).to.eql(hardhat_1.ethers.parseEther("12"));
await treasuryProxy.transferTokens(await b3tr.getAddress(), otherAccount.address, hardhat_1.ethers.parseEther("1"));
(0, chai_1.expect)(await treasuryProxy.getTokenBalance(await b3tr.getAddress())).to.eql(hardhat_1.ethers.parseEther("11"));
});
(0, mocha_1.it)("should revert if not enough balance", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferTokens(await vot3.getAddress(), otherAccount.address, hardhat_1.ethers.parseEther("6")));
});
(0, mocha_1.it)("should revert if not called by GOVERNANCE_ROLE", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy
.connect(otherAccount)
.transferTokens(await vot3.getAddress(), otherAccount.address, hardhat_1.ethers.parseEther("1")));
});
(0, mocha_1.it)("should revert if B3TR contract is paused", async () => {
await b3tr.pause();
await (0, exceptions_1.catchRevert)(treasuryProxy.transferTokens(await b3tr.getAddress(), otherAccount.address, hardhat_1.ethers.parseEther("1")));
await b3tr.unpause();
});
(0, mocha_1.it)("Should revert if transfer exceeds limit", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferTokens(await vot3.getAddress(), otherAccount.address, hardhat_1.ethers.parseEther("6")));
});
(0, mocha_1.it)("Should be able to set transfer limit", async () => {
await treasuryProxy.connect(owner).setTransferLimitToken(await b3tr.getAddress(), hardhat_1.ethers.parseEther("2"));
(0, chai_1.expect)(await treasuryProxy.getTransferLimitToken(await b3tr.getAddress())).to.eql(hardhat_1.ethers.parseEther("2"));
await treasuryProxy.transferTokens(await b3tr.getAddress(), otherAccount.address, hardhat_1.ethers.parseEther("2"));
(0, chai_1.expect)(await treasuryProxy.getTokenBalance(await b3tr.getAddress())).to.eql(hardhat_1.ethers.parseEther("9"));
await (0, chai_1.expect)(treasuryProxy.connect(otherAccount).setTransferLimitToken(await b3tr.getAddress(), hardhat_1.ethers.parseEther("2"))).to.be.reverted; // not admin
});
});
(0, mocha_1.describe)("NFT", () => {
(0, mocha_1.it)("should transfer NFT", async () => {
// Bootstrap emissions
await (0, common_1.bootstrapEmissions)();
// Should be able to free mint after participating in allocation voting
await (0, common_1.participateInAllocationVoting)(otherAccount);
await (0, chai_1.expect)(await galaxyMember.connect(otherAccount).freeMint()).not.to.be.reverted;
(0, chai_1.expect)(await galaxyMember.balanceOf(otherAccount.address)).to.equal(1);
await (0, chai_1.expect)(await galaxyMember
.connect(otherAccount)
.transferFrom(otherAccount.address, await treasuryProxy.getAddress(), 1)).not.to.be.reverted;
const MAGIC_ON_ERC721_RECEIVED = "0x150b7a02";
(0, chai_1.expect)(await treasuryProxy.onERC721Received(owner.address, otherAccount.address, 1, hardhat_1.ethers.toUtf8Bytes(""))).to.equal(MAGIC_ON_ERC721_RECEIVED);
(0, chai_1.expect)(await galaxyMember.balanceOf(await treasuryProxy.getAddress())).to.equal(1);
(0, chai_1.expect)(await treasuryProxy.getCollectionNFTBalance(await galaxyMember.getAddress())).to.equal(1);
await (0, chai_1.expect)(await treasuryProxy.transferNFT(await galaxyMember.getAddress(), otherAccount.address, 1)).not.to
.be.reverted;
(0, chai_1.expect)(await treasuryProxy.getCollectionNFTBalance(await galaxyMember.getAddress())).to.equal(0);
});
(0, mocha_1.it)("should revert if not called by GOVERNANCE_ROLE", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).transferNFT(await galaxyMember.getAddress(), otherAccount.address, 1));
});
(0, mocha_1.it)("should revert if not enough balance", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferNFT(await galaxyMember.getAddress(), otherAccount.address, 1));
});
});
(0, mocha_1.describe)("ERC1155", () => {
let erc1155;
(0, mocha_1.before)(async () => {
const erc1155ContractFactory = await hardhat_1.ethers.getContractFactory("MyERC1155");
erc1155 = await erc1155ContractFactory.deploy(owner.address);
});
(0, mocha_1.it)("should transfer ERC1155", async () => {
await erc1155.connect(owner).mint(await treasuryProxy.getAddress(), 1, 1, new Uint8Array(0));
(0, chai_1.expect)(await treasuryProxy.getERC1155TokenBalance(await erc1155.getAddress(), 1)).to.eql(1n);
await treasuryProxy.transferERC1155Tokens(await erc1155.getAddress(), owner.address, 1, 1, new Uint8Array(0));
(0, chai_1.expect)(await treasuryProxy.getERC1155TokenBalance(await erc1155.getAddress(), 1)).to.eql(0n);
(0, chai_1.expect)(await erc1155.balanceOf(owner.address, 1)).to.eql(1n);
});
(0, mocha_1.it)("should revert if not called by GOVERNANCE_ROLE", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy
.connect(otherAccount)
.transferERC1155Tokens(await erc1155.getAddress(), owner.address, 1, 1, new Uint8Array(0)));
});
(0, mocha_1.it)("should revert if not enough balance", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.transferERC1155Tokens(await erc1155.getAddress(), owner.address, 1, 1, new Uint8Array(0)));
});
(0, mocha_1.it)("should be able to recieve a batch of ERC1155 tokens", async () => {
await erc1155.connect(owner).mintBatch(await treasuryProxy.getAddress(), [2, 3], [2, 3], new Uint8Array(0));
(0, chai_1.expect)(await treasuryProxy.getERC1155TokenBalance(await erc1155.getAddress(), 2)).to.eql(2n);
(0, chai_1.expect)(await treasuryProxy.getERC1155TokenBalance(await erc1155.getAddress(), 3)).to.eql(3n);
});
});
});
(0, mocha_1.describe)("UUPS", () => {
(0, mocha_1.it)("should upgrade", async () => {
const newTreasury = await hardhat_1.ethers.getContractFactory("Treasury");
const newImplementation = await newTreasury.deploy();
const emptyBytes = new Uint8Array(0);
await treasuryProxy.upgradeToAndCall(await newImplementation.getAddress(), emptyBytes);
const treasury = await hardhat_1.ethers.getContractAt("Treasury", await treasuryProxy.getAddress());
(0, chai_1.expect)(await treasury.getVETBalance()).to.eql(hardhat_1.ethers.parseEther("7"));
});
(0, mocha_1.it)("should revert if not called by ADMIN_ROLE", async () => {
const newTreasury = await hardhat_1.ethers.getContractFactory("Treasury");
const newImplementation = await newTreasury.deploy();
const emptyBytes = new Uint8Array(0);
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).upgradeToAndCall(await newImplementation.getAddress(), emptyBytes));
});
(0, mocha_1.it)("should return correct version", async () => {
(0, chai_1.expect)(await treasuryProxy.version()).to.eql("1");
});
(0, mocha_1.it)("can be initialized only once", async () => {
await (0, exceptions_1.catchRevert)(treasuryProxy.initialize(owner.address, owner.address, owner.address, owner.address, owner.address, owner.address, 1, 1, 1, 1));
});
});
(0, mocha_1.describe)("Pause", () => {
(0, mocha_1.it)("should pause and unpause", async () => {
(0, chai_1.expect)(await treasuryProxy.hasRole(await treasuryProxy.PAUSER_ROLE(), owner.address)).to.eql(true);
await treasuryProxy.pause();
(0, chai_1.expect)(await treasuryProxy.paused()).to.eql(true);
await treasuryProxy.unpause();
(0, chai_1.expect)(await treasuryProxy.paused()).to.eql(false);
});
(0, mocha_1.it)("should revert if not called by ADMIN_ROLE", async () => {
(0, chai_1.expect)(await treasuryProxy.hasRole(await treasuryProxy.PAUSER_ROLE(), otherAccount.address)).to.eql(false);
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).pause());
await (0, exceptions_1.catchRevert)(treasuryProxy.connect(otherAccount).unpause());
});
});
(0, mocha_1.describe)("Timelock", () => {
let tProxy;
let governor;
(0, mocha_1.before)(async () => {
const info = await (0, deploy_1.getOrDeployContractInstances)({
forceDeploy: true,
});
governor = info.governor;
const config = (0, local_1.createLocalConfig)();
tProxy = (await (0, helpers_1.deployProxy)("Treasury", [
await info.b3tr.getAddress(),
await info.vot3.getAddress(),
await info.timeLock.getAddress(),
owner.address,
owner.address,
owner.address,
config.TREASURY_TRANSFER_LIMIT_VET,
config.TREASURY_TRANSFER_LIMIT_B3TR,
config.TREASURY_TRANSFER_LIMIT_VOT3,
config.TREASURY_TRANSFER_LIMIT_VTHO,
]));
await (0, fundTreasury_1.fundTreasuryVET)(await tProxy.getAddress(), 10);
});
(0, mocha_1.it)("should execute transfer TX from proposal", async () => {
const description = "Test Proposal: testing propsal for Transfer VET from tresausry";
const treasuryContractFactory = await hardhat_1.ethers.getContractFactory("Treasury");
await (0, common_1.bootstrapAndStartEmissions)();
await governor
.connect(owner)
.setWhitelistFunction(await tProxy.getAddress(), tProxy.interface.getFunction("transferVET").selector, true);
await (0, common_1.createProposalAndExecuteIt)(owner, otherAccount, tProxy, treasuryContractFactory, description, "transferVET", [owner.address, hardhat_1.ethers.parseEther("1")]);
(0, chai_1.expect)(await tProxy.getVETBalance()).to.eql(hardhat_1.ethers.parseEther("9"));
});
(0, mocha_1.it)("Should be able to set VET transfer limit through proposal", async () => {
const treasuryContractFactory = await hardhat_1.ethers.getContractFactory("Treasury");
const description = "Test Proposal: testing propsal for setting VET transfer limit";
await governor
.connect(owner)
.setWhitelistFunction(await tProxy.getAddress(), treasuryProxy.interface.getFunction("setTransferLimitVET").selector, true);
await (0, common_1.createProposalAndExecuteIt)(owner, otherAccount, tProxy, treasuryContractFactory, description, "setTransferLimitVET", [hardhat_1.ethers.parseEther("3")]);
(0, chai_1.expect)(await tProxy.getTransferLimitVET()).to.eql(hardhat_1.ethers.parseEther("3"));
});
(0, mocha_1.it)("Should be able to set token transfer limit through proposal", async () => {
const treasuryContractFactory = await hardhat_1.ethers.getContractFactory("Treasury");
const description = "Test Proposal: testing propsal for setting token transfer limit";
await governor
.connect(owner)
.setWhitelistFunction(await tProxy.getAddress(), treasuryProxy.interface.getFunction("setTransferLimitToken").selector, true);
await (0, common_1.createProposalAndExecuteIt)(owner, otherAccount, tProxy, treasuryContractFactory, description, "setTransferLimitToken", [await b3tr.getAddress(), hardhat_1.ethers.parseEther("3")]);
(0, chai_1.expect)(await tProxy.getTransferLimitToken(await b3tr.getAddress())).to.eql(hardhat_1.ethers.parseEther("3"));
});
});
(0, mocha_1.describe)("Fallback", () => {
(0, mocha_1.it)("Fallback function handles invalid calls", async () => {
const nonExistentFuncSignature = "nonExistentFunction(uint256,uint256)";
const treasuryWithFakeFunction = new hardhat_1.ethers.Contract(await treasuryProxy.getAddress(), [...typechain_types_1.Treasury__factory.createInterface().fragments, `function ${nonExistentFuncSignature}`], owner);
await treasuryWithFakeFunction.nonExistentFunction(1, 1);
});
});
});