Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions test/unit/CompoundModel/CompoundModel.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
import { initialBehavior } from "./initialize.behavior"
import { setUpBehavior } from "./setup.behavior"

export function unitTestCompoundModel(): void {
describe("CompoundModel", function() {
initialBehavior()
setUpBehavior()
})
import { initialBehavior } from "./initialize.behavior";
import { setUpBehavior } from "./setup.behavior";
import { expect } from "chai";
import { ethers } from "hardhat";
import { ModelStorage } from "../../typechain/ModelStorage";
import { AaveYieldStrategy } from "../../typechain/AaveYieldStrategy";
import { AaveLendingPool } from "../../typechain/AaveLendingPool";

export function unitTestAaveYieldStrategy(): void {
describe("AaveYieldStrategy", function () {
let modelStorage: ModelStorage;
let aaveYieldStrategy: AaveYieldStrategy;
let aaveLendingPool: AaveLendingPool;

before(async function () {
const [owner] = await ethers.getSigners();
modelStorage = await ethers.deployContract(owner, ModelStorage);
aaveYieldStrategy = await ethers.deployContract(owner, AaveYieldStrategy, modelStorage.address);
aaveLendingPool = await ethers.deployContract(owner, AaveLendingPool);
});

initialBehavior();

setUpBehavior();

it("should deposit to Aave Lending Pool", async function () {
const depositAmount = ethers.utils.parseEther("100");
await aaveYieldStrategy.deposit(depositAmount);
expect(await aaveLendingPool.balanceOf(aaveYieldStrategy.address)).to.be.equal(depositAmount);
});

it("should withdraw from Aave Lending Pool", async function () {
const withdrawAmount = ethers.utils.parseEther("50");
await aaveYieldStrategy.withdraw(withdrawAmount);
expect(await aaveLendingPool.balanceOf(aaveYieldStrategy.address)).to.be.equal(ethers.utils.parseEther("50"));
});

it("should earn interest from Aave Lending Pool", async function () {
const interestRate = ethers.utils.parseEther("0.05");
await aaveLendingPool.setInterestRate(interestRate);
await aaveYieldStrategy.earnInterest();
expect(await aaveYieldStrategy.balanceOf()).to.be.gt(ethers.utils.parseEther("100"));
});
});
}