From a17a5877ddfe4d4116e2fa5de1966c8d6f6db295 Mon Sep 17 00:00:00 2001 From: Vishal Sharma Date: Fri, 1 May 2026 13:21:27 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Research=20Fix:=20#6=20-=20Punk?= =?UTF-8?q?=20x=20Aave=20Yield=20Strategy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unit/CompoundModel/CompoundModel.ts | 52 ++++++++++++++++++++---- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/test/unit/CompoundModel/CompoundModel.ts b/test/unit/CompoundModel/CompoundModel.ts index b1ec6eb..eadc028 100644 --- a/test/unit/CompoundModel/CompoundModel.ts +++ b/test/unit/CompoundModel/CompoundModel.ts @@ -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")); + }); + }); } \ No newline at end of file