Skip to content

Commit

Permalink
fix: PVE-001 claim fix in vrt
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGuru7 committed Apr 14, 2023
1 parent 672b9de commit 369cf3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion contracts/VRTVault/VRTVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ contract VRTVault is VRTVaultStorage, AccessControlledV5 {
uint256 vrtBalance = vrt.balanceOf(address(this));
require(vrtBalance >= accruedInterest, "Failed to transfer VRT, Insufficient VRT in Vault.");
emit Claim(account, accruedInterest);
user.accrualStartBlockNumber = getBlockNumber();
uint256 currentBlock_ = getBlockNumber();
if (lastAccruingBlock > currentBlock_) {
user.accrualStartBlockNumber = currentBlock_;
} else {
user.accrualStartBlockNumber = lastAccruingBlock;
}
vrt.safeTransfer(user.userAddress, accruedInterest);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/hardhat/VRT/VRTVault.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FakeContract, smock } from "@defi-wonderland/smock";
import { loadFixture, mineUpTo } from "@nomicfoundation/hardhat-network-helpers";
import { loadFixture, mine, mineUpTo } from "@nomicfoundation/hardhat-network-helpers";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect } from "chai";
import { BigNumber } from "ethers";
Expand Down Expand Up @@ -79,7 +79,7 @@ describe("VRTVault", async () => {

it("should not able to set lastAccuringBlock less than current block", async function () {
const { vrtVault, lastAccruingBlock } = fixture;
await mineUpTo(200);
await mine(200);
await expect(vrtVault.setLastAccruingBlock(lastAccruingBlock - 7)).to.be.revertedWith(
"Invalid _lastAccruingBlock interest have been accumulated",
);
Expand Down

0 comments on commit 369cf3f

Please sign in to comment.