Skip to content

Commit

Permalink
fix: typechain issues
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Oct 27, 2022
1 parent 10da2d6 commit 97bff0b
Show file tree
Hide file tree
Showing 13 changed files with 2,395 additions and 2,461 deletions.
2 changes: 1 addition & 1 deletion contracts/test/VBep20Harness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../VBep20Delegate.sol";
import "../Governance/AccessControlManager.sol";
import "./ComptrollerScenario.sol";

contract VBep20Harness is VBep20Immutable {
contract VBEP20Harness is VBep20Immutable {
uint public blockNumber = 100000;
uint public harnessExchangeRate;
bool public harnessExchangeRateStored;
Expand Down
1 change: 1 addition & 0 deletions copy_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
rm -rf ./contracts/oracle
mkdir -p ./contracts/oracle
cp -rf ./node_modules/@venusprotocol/oracle/contracts/ ./contracts/oracle
rm -rf ./contracts/oracle/contracts/test
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as dotenv from "dotenv";
dotenv.config();

import { HardhatUserConfig, task, types } from "hardhat/config";
import '@nomicfoundation/hardhat-toolbox';
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-chai-matchers";
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@defi-wonderland/smock": "^2.2.0",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.3",
"@nomicfoundation/hardhat-network-helpers": "^1.0.4",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",
"@nomiclabs/hardhat-etherscan": "^3.0.3",
"@typechain/ethers-v5": "^7.2.0",
Expand Down
8 changes: 4 additions & 4 deletions tests/hardhat/Tokens/accrueInterestTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import chai from "chai";
const { expect } = chai;
chai.use(smock.matchers);

import { VBep20Harness, ERC20Harness, Comptroller, InterestRateModel, AccessControlManager } from "../../../typechain";
import { VBEP20Harness, ERC20Harness, Comptroller, InterestRateModel, AccessControlManager } from "../../../typechain";
import { convertToUnit } from "../../../helpers/utils";
import { vTokenTestFixture } from "../util/TokenTestHelpers";

Expand All @@ -18,7 +18,7 @@ const borrowIndex = convertToUnit("1", 18);
const borrowRate = convertToUnit("0.000001", 18);

async function pretendBlock(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
accrualBlock: number | string = blockNumber,
deltaBlocks: number | string = 1
) {
Expand All @@ -28,7 +28,7 @@ async function pretendBlock(
}

async function preAccrue({ vToken, interestRateModel }: {
vToken: MockContract<VBep20Harness>;
vToken: MockContract<VBEP20Harness>;
interestRateModel: FakeContract<InterestRateModel>;
}) {
interestRateModel.getBorrowRate.reset();
Expand All @@ -40,7 +40,7 @@ async function preAccrue({ vToken, interestRateModel }: {
describe('VToken', () => {
let root: Signer;
let accounts: Signer[];
let vToken: MockContract<VBep20Harness>;
let vToken: MockContract<VBEP20Harness>;
let interestRateModel: FakeContract<InterestRateModel>;

beforeEach(async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/hardhat/Tokens/adminTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import chai from "chai";
const { expect } = chai;
chai.use(smock.matchers);

import { VBep20Harness } from "../../../typechain";
import { VBEP20Harness } from "../../../typechain";
import { vTokenTestFixture } from "../util/TokenTestHelpers";


describe('admin / _setPendingAdmin / _acceptAdmin', () => {
let vToken: MockContract<VBep20Harness>;
let vToken: MockContract<VBEP20Harness>;
let root: Signer;
let rootAddress: string;
let guy: Signer;
Expand Down
14 changes: 7 additions & 7 deletions tests/hardhat/Tokens/borrowAndRepayTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import chai from "chai";
const { expect } = chai;
chai.use(smock.matchers);

import { VBep20Harness, ERC20Harness, Comptroller, InterestRateModel } from "../../../typechain";
import { VBEP20Harness, ERC20Harness, Comptroller, InterestRateModel } from "../../../typechain";
import { convertToUnit } from "../../../helpers/utils";
import { Error } from "../util/Errors";
import {
Expand Down Expand Up @@ -41,15 +41,15 @@ async function preBorrow(
}

async function borrowFresh(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
borrower: Signer,
borrowAmount: BigNumberish
) {
return vToken.harnessBorrowFresh(await borrower.getAddress(), borrowAmount);
}

async function borrow(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
borrower: Signer,
borrowAmount: BigNumberish
) {
Expand Down Expand Up @@ -81,7 +81,7 @@ async function preRepay(
}

async function repayBorrowFresh(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
payer: Signer,
borrower: Signer,
repayAmount: BigNumberish
Expand All @@ -92,7 +92,7 @@ async function repayBorrowFresh(
}

async function repayBorrow(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
borrower: Signer,
repayAmount: BigNumberish
) {
Expand All @@ -102,7 +102,7 @@ async function repayBorrow(
}

async function repayBorrowBehalf(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
payer: Signer,
borrower: Signer,
repayAmount: BigNumberish
Expand All @@ -115,7 +115,7 @@ async function repayBorrowBehalf(
describe('VToken', function () {
let contracts: VTokenTestFixture;
let comptroller: FakeContract<Comptroller>;
let vToken: MockContract<VBep20Harness>;
let vToken: MockContract<VBEP20Harness>;
let underlying: MockContract<ERC20Harness>;
let interestRateModel: FakeContract<InterestRateModel>;
let root: Signer;
Expand Down
20 changes: 13 additions & 7 deletions tests/hardhat/Tokens/liquidateTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { expect } = chai;
chai.use(smock.matchers);

import {
Comptroller, VBep20Harness, AccessControlManager, Shortfall
Comptroller, VBEP20Harness, AccessControlManager, Shortfall
} from "../../../typechain";
import { convertToUnit } from "../../../helpers/utils";
import { Error } from "../util/Errors";
Expand Down Expand Up @@ -41,7 +41,6 @@ async function liquidateTestFixture(): Promise<LiquidateTestFixture> {
await makeVToken({ name: "BAT", comptroller, accessControlManager, admin, shortfall});
const collateral =
await makeVToken({ name: "ZRX", comptroller, accessControlManager, admin, shortfall});

await collateral.vToken.harnessSetExchangeRate(exchangeRate);

// setup for success in liquidating
Expand Down Expand Up @@ -84,13 +83,14 @@ function configure({ comptroller, accessControlManager, collateral, borrowed }:
}

async function liquidateFresh(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
liquidator: Signer,
borrower: Signer,
repayAmount: BigNumberish,
vTokenCollateral: MockContract<VBep20Harness>,
vTokenCollateral: MockContract<VBEP20Harness>,
skipLiquidityCheck: boolean = false
) {

return vToken.harnessLiquidateBorrowFresh(
await liquidator.getAddress(),
await borrower.getAddress(),
Expand All @@ -101,15 +101,18 @@ async function liquidateFresh(
}

async function liquidate(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
liquidator: Signer,
borrower: Signer,
repayAmount: BigNumberish,
vTokenCollateral: MockContract<VBep20Harness>
vTokenCollateral: MockContract<VBEP20Harness>
) {
// make sure to have a block delta so we accrue interest

await vToken.harnessFastForward(1);

await vTokenCollateral.harnessFastForward(1);

return vToken.connect(liquidator).liquidateBorrow(
await borrower.getAddress(),
repayAmount,
Expand All @@ -118,11 +121,12 @@ async function liquidate(
}

async function seize(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
liquidator: Signer,
borrower: Signer,
seizeAmount: BigNumberish
) {

return vToken.seize(await liquidator.getAddress(), await borrower.getAddress(), seizeAmount);
}

Expand Down Expand Up @@ -196,6 +200,7 @@ describe('VToken', function () {
const beforeBalances =
await getBalances([borrowed.vToken, collateral.vToken], [liquidatorAddress, borrowerAddress]);
comptroller.liquidateCalculateSeizeTokens.reverts("Oups");

await expect(liquidateFresh(borrowed.vToken, liquidator, borrower, repayAmount, collateral.vToken))
.to.be.reverted; //With('LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED');
const afterBalances =
Expand All @@ -222,6 +227,7 @@ describe('VToken', function () {
const borrowerAddress = await borrower.getAddress();

const beforeBalances = await getBalances([borrowed.vToken, collateral.vToken], [liquidatorAddress, borrowerAddress]);

const result = await liquidateFresh(borrowed.vToken, liquidator, borrower, repayAmount, collateral.vToken);
const afterBalances = await getBalances([borrowed.vToken, collateral.vToken], [liquidatorAddress, borrowerAddress]);
//expect(
Expand Down
18 changes: 9 additions & 9 deletions tests/hardhat/Tokens/mintAndRedeemTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import chai from "chai";
const { expect } = chai;
chai.use(smock.matchers);

import { VBep20Harness, ERC20Harness, Comptroller, InterestRateModel, AccessControlManager } from "../../../typechain";
import { VBEP20Harness, ERC20Harness, Comptroller, InterestRateModel, AccessControlManager } from "../../../typechain";
import { convertToUnit } from "../../../helpers/utils";
import { Error } from "../util/Errors";
import {
Expand Down Expand Up @@ -46,15 +46,15 @@ async function preMint(
}

async function mintFresh(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
minter: Signer,
mintAmount: BigNumberish
) {
return vToken.harnessMintFresh(await minter.getAddress(), mintAmount);
}

async function preSupply(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
account: Signer,
tokens: BigNumberish,
opts: { supply?: boolean } = { supply: true }
Expand Down Expand Up @@ -92,7 +92,7 @@ async function preRedeem(
}

async function redeemFreshTokens(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
redeemer: Signer,
redeemTokens: BigNumberish,
redeemAmount: BigNumberish
Expand All @@ -102,7 +102,7 @@ async function redeemFreshTokens(
}

async function redeemFreshAmount(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
redeemer: Signer,
redeemTokens: BigNumberish,
redeemAmount: BigNumberish
Expand All @@ -113,7 +113,7 @@ async function redeemFreshAmount(

async function quickMint(
underlying: MockContract<ERC20Harness>,
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
minter: Signer,
mintAmount: BigNumberish,
opts: { approve?: boolean, exchangeRate?: BigNumberish, faucet?: boolean } = { approve: true, faucet: true }
Expand All @@ -135,7 +135,7 @@ async function quickMint(
}

async function quickRedeem(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
redeemer: Signer,
redeemTokens: BigNumberish,
opts: { supply?: boolean, exchangeRate?: BigNumberish } = { supply: true }
Expand All @@ -156,7 +156,7 @@ async function quickRedeem(
}

async function quickRedeemUnderlying(
vToken: MockContract<VBep20Harness>,
vToken: MockContract<VBEP20Harness>,
redeemer: Signer,
redeemAmount: BigNumberish,
opts: { exchangeRate?: BigNumberish } = {}
Expand All @@ -182,7 +182,7 @@ describe('VToken', function () {

let contracts: VTokenTestFixture;
let comptroller: FakeContract<Comptroller>;
let vToken: MockContract<VBep20Harness>;
let vToken: MockContract<VBEP20Harness>;
let underlying: MockContract<ERC20Harness>;
let interestRateModel: FakeContract<InterestRateModel>;

Expand Down
4 changes: 2 additions & 2 deletions tests/hardhat/Tokens/setComptrollerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import chai from "chai";
const { expect } = chai;
chai.use(smock.matchers);

import { AccessControlManager, VBep20Harness, Comptroller } from "../../../typechain";
import { AccessControlManager, VBEP20Harness, Comptroller } from "../../../typechain";
import { vTokenTestFixture } from "../util/TokenTestHelpers";


Expand All @@ -17,7 +17,7 @@ async function setComptrollerTestFixture() {
}

describe('VToken', function () {
let vToken: MockContract<VBep20Harness>;
let vToken: MockContract<VBEP20Harness>;
let comptroller: FakeContract<Comptroller>;
let newComptroller: FakeContract<Comptroller>;
let accessControlManager: FakeContract<AccessControlManager>;
Expand Down
4 changes: 2 additions & 2 deletions tests/hardhat/Tokens/transferTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import chai from "chai";
const { expect } = chai;
chai.use(smock.matchers);

import { VBep20Harness, ERC20Harness, Comptroller, InterestRateModel, AccessControlManager } from "../../../typechain";
import { VBEP20Harness, ERC20Harness, Comptroller, InterestRateModel, AccessControlManager } from "../../../typechain";
import { convertToUnit } from "../../../helpers/utils";
import { Error } from "../util/Errors";
import {
Expand All @@ -22,7 +22,7 @@ describe('VToken', function () {
let rootAddress: string;
let guyAddress: string;
let accounts: Signer[];
let vToken: MockContract<VBep20Harness>;
let vToken: MockContract<VBEP20Harness>;
let comptroller: FakeContract<Comptroller>;

beforeEach(async () => {
Expand Down
Loading

0 comments on commit 97bff0b

Please sign in to comment.