|
1 | 1 | import { |
2 | | - loadFixture, time |
| 2 | + loadFixture, time, setBalance |
3 | 3 | } from "@nomicfoundation/hardhat-toolbox/network-helpers"; |
4 | 4 | import {expect} from "chai"; |
5 | 5 | import hre from "hardhat"; |
6 | 6 | import { |
7 | 7 | deploy, signBorrow |
8 | 8 | } from "./helpers"; |
| 9 | +import {ZERO_ADDRESS} from "../scripts/common"; |
9 | 10 | import {encodeBytes32String, AbiCoder} from "ethers"; |
10 | 11 | import { |
11 | 12 | MockTarget, MockBorrowSwap, LiquidityPoolAave |
@@ -51,6 +52,7 @@ describe("LiquidityPoolAave", function () { |
51 | 52 | const uniOwner = await hre.ethers.getImpersonatedSigner(UNI_OWNER_ADDRESS); |
52 | 53 | const uniData = await aavePool.getReserveData(UNI_ADDRESS); |
53 | 54 | const uniDebtToken = await hre.ethers.getContractAt("ERC20", uniData[10]); |
| 55 | + await setBalance(UNI_OWNER_ADDRESS, 10n ** 18n); |
54 | 56 |
|
55 | 57 | // PRIME token used as not supported by aave |
56 | 58 | const NON_SUPPORTED_TOKEN_ADDRESS = "0xb23d80f5FefcDDaa212212F028021B41DEd428CF"; |
@@ -627,7 +629,7 @@ describe("LiquidityPoolAave", function () { |
627 | 629 | const usdcDebtBefore = await usdcDebtToken.balanceOf(liquidityPool.target); |
628 | 630 | expect(usdcDebtBefore).to.be.greaterThan(amountToBorrow); |
629 | 631 |
|
630 | | - await usdc.connect(uniOwner).transfer(liquidityPool.target, amountToBorrow); |
| 632 | + await usdc.connect(usdcOwner).transfer(liquidityPool.target, amountToBorrow); |
631 | 633 |
|
632 | 634 | await expect(liquidityPool.connect(user).repay([usdc.target])) |
633 | 635 | .to.emit(liquidityPool, "Repaid"); |
@@ -892,7 +894,7 @@ describe("LiquidityPoolAave", function () { |
892 | 894 | await expect(liquidityPool.connect(liquidityAdmin).deposit(amountCollateral)) |
893 | 895 | .to.emit(liquidityPool, "SuppliedToAave"); |
894 | 896 |
|
895 | | - await expect(liquidityPool.connect(admin).setHealthFactor(4000n * 10n ** 18n / 100n)) |
| 897 | + await expect(liquidityPool.connect(admin).setHealthFactor(5000n * 10n ** 18n / 100n)) |
896 | 898 | .to.emit(liquidityPool, "HealthFactorSet"); |
897 | 899 |
|
898 | 900 | const amountToBorrow = 3n * UNI_DEC; |
@@ -1274,6 +1276,12 @@ describe("LiquidityPoolAave", function () { |
1274 | 1276 | .to.be.revertedWithCustomError(liquidityPool, "EnforcedPause"); |
1275 | 1277 | }); |
1276 | 1278 |
|
| 1279 | + it("Should NOT withdraw profit to zero address", async function () { |
| 1280 | + const {liquidityPool, user, uni, withdrawProfit, pauser} = await loadFixture(deployAll); |
| 1281 | + await expect(liquidityPool.connect(withdrawProfit).withdrawProfit([uni.target], ZERO_ADDRESS)) |
| 1282 | + .to.be.revertedWithCustomError(liquidityPool, "ZeroAddress()"); |
| 1283 | + }); |
| 1284 | + |
1277 | 1285 | it("Should revert during withdrawing profit if no profit", async function () { |
1278 | 1286 | const {liquidityPool, uni, withdrawProfit, user} = await loadFixture(deployAll); |
1279 | 1287 | await expect(liquidityPool.connect(withdrawProfit).withdrawProfit([uni.target], user.address)) |
|
0 commit comments