Skip to content

Commit

Permalink
fix: resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGuru7 committed Aug 25, 2023
1 parent 0ea2384 commit ca4d1da
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
5 changes: 1 addition & 4 deletions contracts/Tokens/VTokens/VToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,7 @@ contract VToken is VTokenInterface, Exponential, TokenErrorReporter {
* @param newReduceReservesBlockDelta_ block difference value
*/
function setReduceReservesBlockDelta(uint256 newReduceReservesBlockDelta_) external returns (uint) {
// Check caller is admin
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_REDUCE_RESERVES_BLOCK_DELTA_OWNER_CHECK);
}
ensureAllowed("setReduceReservesBlockDelta(uint256)");
emit NewReduceReservesBlockDelta(reduceReservesBlockDelta, newReduceReservesBlockDelta_);
reduceReservesBlockDelta = newReduceReservesBlockDelta_;
}
Expand Down
1 change: 1 addition & 0 deletions tests/hardhat/EvilXToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ describe("Evil Token test", async () => {
await vDelegator1.deployed();

vToken1 = await ethers.getContractAt("VBep20MockDelegate", vDelegator1.address);
await vToken1.setAccessControlManager(accessControlMock.address);

await unitroller._supportMarket(vToken1.address);
await unitroller._setCollateralFactor(vToken1.address, convertToUnit(cf1, 18));
Expand Down
19 changes: 14 additions & 5 deletions tests/hardhat/Fork/VTokensUpgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ethers } from "hardhat";

import {
FaucetToken__factory,
IAccessControlManagerV5__factory,
IProtocolShareReserve,
VBep20Delegate,
VBep20Delegate__factory,
Expand Down Expand Up @@ -35,6 +36,7 @@ chai.use(smock.matchers);
const FORK_MAINNET = process.env.FORK_MAINNET === "true";

const NORMAL_TIMELOCK = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396";
const ACM = "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555";

let impersonatedTimelock: Signer;
let protocolShareReserve: FakeContract<IProtocolShareReserve>;
Expand All @@ -45,13 +47,20 @@ async function configureTimelock() {

async function configureNew(vTokenAddress: string) {
await configureTimelock();
const accessControlManager = IAccessControlManagerV5__factory.connect(ACM, impersonatedTimelock);
const vTokenProxy = VBep20Delegator__factory.connect(vTokenAddress, impersonatedTimelock);
const vTokenFactory = await ethers.getContractFactory("VBep20Delegate");
const vTokenImpl = await vTokenFactory.deploy();
await vTokenImpl.deployed();
await vTokenProxy.connect(impersonatedTimelock)._setImplementation(vTokenImpl.address, true, "0x00");
const vToken = VBep20Delegate__factory.connect(vTokenAddress, impersonatedTimelock);
protocolShareReserve = await smock.fake<IProtocolShareReserve>("IProtocolShareReserve");
await vToken.setAccessControlManager(ACM);
await accessControlManager.giveCallPermission(
vToken.address,
"setReduceReservesBlockDelta(uint256)",
NORMAL_TIMELOCK,
);
await vToken.connect(impersonatedTimelock).setReduceReservesBlockDelta(1000);
await vToken.connect(impersonatedTimelock).setProtocolShareReserve(protocolShareReserve.address);
return vToken;
Expand Down Expand Up @@ -145,7 +154,7 @@ if (FORK_MAINNET) {
amount: string,
) {
await setForkBlock(blockNumber);
await mine(4);
await mine(6);
const vTokenOld = await configureOld(vTokenContract);
await configureUserAndTokens(vTokenContract, userAddress, underlyingAddress, amount);
await vTokenOld.connect(signer).mint(amount);
Expand Down Expand Up @@ -176,7 +185,7 @@ if (FORK_MAINNET) {
amount: string,
) {
await setForkBlock(blockNumber);
await mine(4);
await mine(6);
const vTokenOld = await configureOld(vTokenContract);
await configureUserAndTokens(vTokenContract, userAddress, underlyingAddress, amount);
await vTokenOld.connect(signer).borrow(amount);
Expand Down Expand Up @@ -207,7 +216,7 @@ if (FORK_MAINNET) {
amount: string,
) {
await setForkBlock(blockNumber);
await mine(4);
await mine(6);
const vTokenOld = await configureOld(vTokenContract);
await configureUserAndTokens(vTokenContract, userAddress, underlyingAddress, amount);
await vTokenOld.connect(signer).redeem(amount);
Expand Down Expand Up @@ -238,7 +247,7 @@ if (FORK_MAINNET) {
amount: string,
) {
await setForkBlock(blockNumber);
await mine(4);
await mine(6);
const vTokenOld = await configureOld(vTokenContract);
await configureUserAndTokens(vTokenContract, userAddress, underlyingAddress, amount);
await vTokenOld.connect(signer).repayBorrow(amount);
Expand All @@ -261,7 +270,7 @@ if (FORK_MAINNET) {
};
}

it("Should match mint operations in all markets", async () => {
it.only("Should match mint operations in all markets", async () => {
const markets = Object.keys(vTokenAddresses);
for (const market of markets) {
const marketAddress = vTokenAddresses[market];
Expand Down
1 change: 1 addition & 0 deletions tests/hardhat/Fork/vTokenACMUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ async function configure() {
vBusd = VBep20Delegate__factory.connect(VBUSD, impersonatedTimelock);
await vBusd.setAccessControlManager(ACM);
const protocolShareReserve = await smock.fake<IProtocolShareReserve>("IProtocolShareReserve");
await grantPermission("setReduceReservesBlockDelta(uint256)");
await vBusd.connect(impersonatedTimelock).setReduceReservesBlockDelta(1000);
await vBusd.connect(impersonatedTimelock).setProtocolShareReserve(protocolShareReserve.address);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/hardhat/VAI/VAIController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ describe("VAIController", async () => {
await comptroller._supportMarket(vusdt.address);
await comptroller._setCollateralFactor(vusdt.address, bigNumber17.mul(5));
await vusdt.setProtocolShareReserve(protocolShareReserve.address);
await vusdt.setReduceReservesBlockDelta(10000000000);

return { usdt, accessControl, comptroller, priceOracle, vai, vaiController, vusdt };
}

Expand All @@ -147,6 +145,8 @@ describe("VAIController", async () => {
));
accessControl.isAllowedToCall.reset();
accessControl.isAllowedToCall.returns(true);
await vusdt.setAccessControlManager(accessControl.address);
await vusdt.setReduceReservesBlockDelta(10000000000);
await vusdt.harnessSetBalance(user1.address, bigNumber18.mul(200));
await comptroller.connect(user1).enterMarkets([vusdt.address]);
});
Expand Down

0 comments on commit ca4d1da

Please sign in to comment.