@@ -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" ;
@@ -412,7 +412,10 @@ describe("LiquidityPool", function () {
412412 expect ( await usdc . balanceOf ( user . address ) ) . to . be . eq ( amount ) ;
413413 expect ( await aToken . balanceOf ( liquidityPool . target ) ) . to . be . greaterThan ( 0 ) ;
414414
415- expect ( await liquidityPool . connect ( admin ) . withdrawAll ( user . address ) )
415+ // Using type(uint256).max as amount to withdraw all available amount
416+ expect ( await liquidityPool . connect ( admin ) . withdraw (
417+ user . address , MaxUint256
418+ ) )
416419 . to . emit ( liquidityPool , "WidthrawnFromAave" ) ;
417420 expect ( await usdc . balanceOf ( user . address ) ) . to . be . greaterThan ( amount ) ;
418421 expect ( await aToken . balanceOf ( liquidityPool . target ) ) . to . eq ( 0 ) ;
@@ -681,39 +684,6 @@ describe("LiquidityPool", function () {
681684 . to . be . revertedWithCustomError ( liquidityPool , "AccessControlUnauthorizedAccount" ) ;
682685 } ) ;
683686
684- it ( "Should NOT withdraw all collateral if there is some debt" , async function ( ) {
685- const {
686- liquidityPool, usdc, usdcOwner, USDC_DEC , user, admin, uni, mpc_signer, UNI_DEC , user2
687- } = await loadFixture ( deployAll ) ;
688- const amount = 1000n * USDC_DEC ; // $1000
689- await usdc . connect ( usdcOwner ) . transfer ( liquidityPool . target , amount ) ;
690- expect ( await liquidityPool . deposit ( ) )
691- . to . emit ( liquidityPool , "SuppliedToAave" ) . withArgs ( amount ) ;
692-
693- const amountToBorrow = 3n * UNI_DEC ;
694-
695- const signature = await signBorrow (
696- mpc_signer ,
697- liquidityPool . target as string ,
698- uni . target as string ,
699- amountToBorrow . toString ( ) ,
700- user2 . address ,
701- "0x" ,
702- 31337
703- ) ;
704-
705- expect ( await liquidityPool . connect ( user ) . borrow (
706- uni . target ,
707- amountToBorrow ,
708- user2 ,
709- "0x" ,
710- signature ) )
711- . to . emit ( liquidityPool , "Borrowed" ) ;
712-
713- await expect ( liquidityPool . connect ( admin ) . withdrawAll ( user . address ) )
714- . to . be . revertedWithCustomError ( liquidityPool , "TokenHasDebt" ) ;
715- } ) ;
716-
717687 it ( "Should NOT withdraw profit for collateral" , async function ( ) {
718688 const { liquidityPool, usdc, admin, user} = await loadFixture ( deployAll ) ;
719689 const amount = 1000n ;
0 commit comments