@@ -6,7 +6,7 @@ import hre from "hardhat";
66import {
77 getCreateAddress , getContractAt , deploy , signBorrow
88} from "./helpers" ;
9- import { encodeBytes32String } from "ethers" ;
9+ import { encodeBytes32String , MaxUint256 } from "ethers" ;
1010import {
1111 MockTarget , LiquidityPool , TransparentUpgradeableProxy , ProxyAdmin
1212} from "../typechain-types" ;
@@ -431,7 +431,10 @@ describe("LiquidityPool", function () {
431431 expect ( await usdc . balanceOf ( user . address ) ) . to . be . eq ( amount ) ;
432432 expect ( await aToken . balanceOf ( liquidityPool . target ) ) . to . be . greaterThan ( 0 ) ;
433433
434- expect ( await liquidityPool . connect ( admin ) . withdrawAll ( user . address ) )
434+ // Using type(uint256).max as amount to withdraw all available amount
435+ expect ( await liquidityPool . connect ( admin ) . withdraw (
436+ user . address , MaxUint256
437+ ) )
435438 . to . emit ( liquidityPool , "WidthrawnFromAave" ) ;
436439 expect ( await usdc . balanceOf ( user . address ) ) . to . be . greaterThan ( amount ) ;
437440 expect ( await aToken . balanceOf ( liquidityPool . target ) ) . to . eq ( 0 ) ;
@@ -785,41 +788,6 @@ describe("LiquidityPool", function () {
785788 . to . be . revertedWithCustomError ( liquidityPool , "AccessControlUnauthorizedAccount" ) ;
786789 } ) ;
787790
788- it ( "Should NOT withdraw all collateral if there is some debt" , async function ( ) {
789- const {
790- liquidityPool, usdc, usdcOwner, USDC_DEC , user, admin, uni, mpc_signer, UNI_DEC , user2
791- } = await loadFixture ( deployAll ) ;
792- const amount = 1000n * USDC_DEC ; // $1000
793- await usdc . connect ( usdcOwner ) . transfer ( liquidityPool . target , amount ) ;
794- expect ( await liquidityPool . deposit ( ) )
795- . to . emit ( liquidityPool , "SuppliedToAave" ) . withArgs ( amount ) ;
796-
797- const amountToBorrow = 3n * UNI_DEC ;
798-
799- const signature = await signBorrow (
800- mpc_signer ,
801- liquidityPool . target as string ,
802- uni . target as string ,
803- amountToBorrow . toString ( ) ,
804- user2 . address ,
805- "0x" ,
806- 31337
807- ) ;
808-
809- expect ( await liquidityPool . connect ( user ) . borrow (
810- uni . target ,
811- amountToBorrow ,
812- user2 ,
813- "0x" ,
814- 0n ,
815- 2000000000n ,
816- signature ) )
817- . to . emit ( liquidityPool , "Borrowed" ) ;
818-
819- await expect ( liquidityPool . connect ( admin ) . withdrawAll ( user . address ) )
820- . to . be . revertedWithCustomError ( liquidityPool , "TokenHasDebt" ) ;
821- } ) ;
822-
823791 it ( "Should NOT withdraw profit for collateral" , async function ( ) {
824792 const { liquidityPool, usdc, admin, user} = await loadFixture ( deployAll ) ;
825793 const amount = 1000n ;
0 commit comments