@@ -57,7 +57,7 @@ describe("LiquidityPoolAave", function () {
5757 // PRIME token used as not supported by aave
5858 const NON_SUPPORTED_TOKEN_ADDRESS = "0xb23d80f5FefcDDaa212212F028021B41DEd428CF" ;
5959 const NON_SUPPORTED_TOKEN_OWNER_ADDRESS = process . env . PRIME_OWNER_ADDRESS ! ;
60- if ( ! NON_SUPPORTED_TOKEN_OWNER_ADDRESS )
60+ if ( ! NON_SUPPORTED_TOKEN_OWNER_ADDRESS )
6161 throw new Error ( "Env variables not configured (PRIME_OWNER_ADDRESS missing)" ) ;
6262 const nonSupportedToken = await hre . ethers . getContractAt ( "ERC20" , NON_SUPPORTED_TOKEN_ADDRESS ) ;
6363 const nonSupportedTokenOwner = await hre . ethers . getImpersonatedSigner ( NON_SUPPORTED_TOKEN_OWNER_ADDRESS ) ;
@@ -72,7 +72,7 @@ describe("LiquidityPoolAave", function () {
7272 const defaultLtv = 5n * 10000n / 100n ;
7373 const liquidityPool = (
7474 await deploy ( "LiquidityPoolAave" , deployer , { } ,
75- usdc . target , AAVE_POOL_PROVIDER , admin . address , mpc_signer . address , healthFactor , defaultLtv
75+ usdc . target , AAVE_POOL_PROVIDER , admin . address , mpc_signer . address , healthFactor , defaultLtv
7676 )
7777 ) as LiquidityPoolAave ;
7878
@@ -182,10 +182,10 @@ describe("LiquidityPoolAave", function () {
182182 "0x" ,
183183 0n ,
184184 2000000000n ,
185- signature ) ;
185+ signature ) ;
186186 expect ( await rpl . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
187187 } ) ;
188-
188+
189189 it ( "Should calculate token ltv if decimals of token and collateral are different" , async function ( ) {
190190 const {
191191 liquidityPool, usdc, uni, mpc_signer, user, user2, usdcOwner, liquidityAdmin, USDC_DEC , UNI_DEC
@@ -254,7 +254,7 @@ describe("LiquidityPoolAave", function () {
254254 0n ,
255255 2000000000n ,
256256 signature ) )
257- . to . emit ( mockTarget , "DataReceived" ) . withArgs ( additionalData ) ;
257+ . to . emit ( mockTarget , "DataReceived" ) . withArgs ( additionalData ) ;
258258 expect ( await rpl . balanceOf ( liquidityPool . target ) ) . to . eq ( 0 ) ;
259259 expect ( await rpl . balanceOf ( mockTarget . target ) ) . to . eq ( amountToBorrow ) ;
260260 } ) ;
@@ -288,7 +288,7 @@ describe("LiquidityPoolAave", function () {
288288 "0x" ,
289289 0n ,
290290 2000000000n ,
291- signature ) ;
291+ signature ) ;
292292 expect ( await usdc . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
293293 expect ( await aToken . balanceOf ( liquidityPool . target ) ) . to . be . greaterThanOrEqual ( amountCollateral - 1n ) ;
294294 } ) ;
@@ -339,8 +339,8 @@ describe("LiquidityPoolAave", function () {
339339 ) ;
340340
341341 await expect ( mockBorrowSwap . connect ( user ) . callBorrow ( liquidityPool . target , borrowCalldata . data ) )
342- . to . emit ( mockBorrowSwap , "Swapped" ) . withArgs ( swapData )
343- . and . to . emit ( mockTarget , "DataReceived" ) . withArgs ( additionalData ) ;
342+ . to . emit ( mockBorrowSwap , "Swapped" ) . withArgs ( swapData )
343+ . and . to . emit ( mockTarget , "DataReceived" ) . withArgs ( additionalData ) ;
344344 expect ( await rpl . balanceOf ( liquidityPool . target ) ) . to . eq ( 0 ) ;
345345 expect ( await rpl . balanceOf ( mockBorrowSwap . target ) ) . to . eq ( amountToBorrow ) ;
346346 expect ( await uni . balanceOf ( liquidityPool . target ) ) . to . eq ( 0 ) ;
@@ -349,7 +349,8 @@ describe("LiquidityPoolAave", function () {
349349
350350 it ( "Should repay a debt" , async function ( ) {
351351 const {
352- liquidityPool, usdc, uni, mpc_signer, user, user2, usdcOwner, uniOwner, liquidityAdmin, USDC_DEC , UNI_DEC
352+ liquidityPool, usdc, uni, mpc_signer, user, user2, usdcOwner, uniOwner, liquidityAdmin, USDC_DEC , UNI_DEC ,
353+ aavePool,
353354 } = await loadFixture ( deployAll ) ;
354355 const amountCollateral = 1000n * USDC_DEC ; // $1000
355356 await usdc . connect ( usdcOwner ) . transfer ( liquidityPool . target , amountCollateral ) ;
@@ -376,13 +377,14 @@ describe("LiquidityPoolAave", function () {
376377 "0x" ,
377378 0n ,
378379 2000000000n ,
379- signature ) ;
380+ signature ) ;
380381 expect ( await uni . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
381382
382383 await uni . connect ( uniOwner ) . transfer ( liquidityPool . target , amountToBorrow ) ;
383384
384385 await expect ( liquidityPool . connect ( user ) . repay ( [ uni . target ] ) )
385- . to . emit ( liquidityPool , "Repaid" ) ;
386+ . to . emit ( liquidityPool , "Repaid" ) ;
387+ expect ( await uni . allowance ( liquidityPool . target , aavePool . target ) ) . to . eq ( 0 ) ;
386388 expect ( await uni . balanceOf ( liquidityPool . target ) ) . to . be . lessThan ( amountToBorrow ) ;
387389 } ) ;
388390
@@ -416,7 +418,7 @@ describe("LiquidityPoolAave", function () {
416418 "0x" ,
417419 0n ,
418420 2000000000n ,
419- signature ) ;
421+ signature ) ;
420422 expect ( await uni . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
421423
422424 await expect ( liquidityPool . connect ( pauser ) . pause ( ) )
@@ -425,7 +427,7 @@ describe("LiquidityPoolAave", function () {
425427 await uni . connect ( uniOwner ) . transfer ( liquidityPool . target , amountToBorrow ) ;
426428
427429 await expect ( liquidityPool . connect ( user ) . repay ( [ uni . target ] ) )
428- . to . emit ( liquidityPool , "Repaid" ) ;
430+ . to . emit ( liquidityPool , "Repaid" ) ;
429431 expect ( await uni . balanceOf ( liquidityPool . target ) ) . to . be . lessThan ( amountToBorrow ) ;
430432 } ) ;
431433
@@ -485,7 +487,7 @@ describe("LiquidityPoolAave", function () {
485487 "0x" ,
486488 0n ,
487489 2000000000n ,
488- signature1 ) ;
490+ signature1 ) ;
489491 expect ( await rpl . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
490492
491493 const signature2 = await signBorrow (
@@ -507,7 +509,7 @@ describe("LiquidityPoolAave", function () {
507509 "0x" ,
508510 1n ,
509511 2000000000n ,
510- signature2 ) ;
512+ signature2 ) ;
511513 expect ( await uni . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
512514
513515 // advance time by one hour
@@ -521,21 +523,21 @@ describe("LiquidityPoolAave", function () {
521523 // Repaying with the borrowed tokens that are still in the pool contract
522524 await expect ( liquidityPool . connect ( user ) . repay ( [ uni . target , rpl . target ] ) )
523525 . to . emit ( liquidityPool , "Repaid" ) . withArgs ( uni . target , amountToBorrow )
524- . and . to . emit ( liquidityPool , "Repaid" ) . withArgs ( rpl . target , amountToBorrow ) ;
526+ . and . to . emit ( liquidityPool , "Repaid" ) . withArgs ( rpl . target , amountToBorrow ) ;
525527 const uniDebtAfter1 = await uniDebtToken . balanceOf ( liquidityPool . target ) ;
526528 expect ( uniDebtAfter1 ) . to . be . lessThan ( uniDebtBefore ) ;
527529 const rplDebtAfter1 = await rplDebtToken . balanceOf ( liquidityPool . target ) ;
528530 expect ( rplDebtAfter1 ) . to . be . lessThan ( rplDebtBefore ) ;
529531
530532 await uni . connect ( uniOwner ) . transfer ( liquidityPool . target , amountToBorrow ) ;
531533 await expect ( liquidityPool . connect ( user ) . repay ( [ uni . target ] ) )
532- . to . emit ( liquidityPool , "Repaid" ) ;
534+ . to . emit ( liquidityPool , "Repaid" ) ;
533535 const uniDebtAfter2 = await uniDebtToken . balanceOf ( liquidityPool . target ) ;
534536 expect ( uniDebtAfter2 ) . to . eq ( 0 ) ;
535537
536538 await rpl . connect ( rplOwner ) . transfer ( liquidityPool . target , amountToBorrow ) ;
537539 await expect ( liquidityPool . connect ( user ) . repay ( [ rpl . target ] ) )
538- . to . emit ( liquidityPool , "Repaid" ) ;
540+ . to . emit ( liquidityPool , "Repaid" ) ;
539541 const rplDebtAfter2 = await rplDebtToken . balanceOf ( liquidityPool . target ) ;
540542 expect ( rplDebtAfter2 ) . to . eq ( 0 ) ;
541543 } ) ;
@@ -570,7 +572,7 @@ describe("LiquidityPoolAave", function () {
570572 "0x" ,
571573 0n ,
572574 2000000000n ,
573- signature1 ) ;
575+ signature1 ) ;
574576 expect ( await rpl . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
575577
576578 // advance time by one hour
@@ -583,7 +585,7 @@ describe("LiquidityPoolAave", function () {
583585 await rpl . connect ( rplOwner ) . transfer ( liquidityPool . target , amountToBorrow ) ;
584586
585587 await expect ( liquidityPool . connect ( user ) . repay ( [ uni . target , rpl . target ] ) )
586- . to . emit ( liquidityPool , "Repaid" ) ;
588+ . to . emit ( liquidityPool , "Repaid" ) ;
587589 const uniDebtAfter = await uniDebtToken . balanceOf ( liquidityPool . target ) ;
588590 expect ( uniDebtAfter ) . to . eq ( 0 ) ;
589591 const rplDebtAfter = await rplDebtToken . balanceOf ( liquidityPool . target ) ;
@@ -620,7 +622,7 @@ describe("LiquidityPoolAave", function () {
620622 "0x" ,
621623 0n ,
622624 2000000000n ,
623- signature1 ) ;
625+ signature1 ) ;
624626 expect ( await usdc . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
625627
626628 // advance time by one hour
@@ -632,7 +634,7 @@ describe("LiquidityPoolAave", function () {
632634 await usdc . connect ( usdcOwner ) . transfer ( liquidityPool . target , amountToBorrow ) ;
633635
634636 await expect ( liquidityPool . connect ( user ) . repay ( [ usdc . target ] ) )
635- . to . emit ( liquidityPool , "Repaid" ) ;
637+ . to . emit ( liquidityPool , "Repaid" ) ;
636638 const usdcDebtAfter = await uniDebtToken . balanceOf ( liquidityPool . target ) ;
637639 expect ( usdcDebtAfter ) . to . eq ( 0 ) ;
638640 } ) ;
@@ -960,7 +962,7 @@ describe("LiquidityPoolAave", function () {
960962
961963 it ( "Should NOT borrow if borrowing is paused" , async function ( ) {
962964 const { liquidityPool, user, user2, withdrawProfit, mpc_signer, uni, UNI_DEC } = await loadFixture ( deployAll ) ;
963-
965+
964966 // Pause borrowing
965967 await expect ( liquidityPool . connect ( withdrawProfit ) . pauseBorrow ( ) )
966968 . to . emit ( liquidityPool , "BorrowPaused" ) ;
@@ -990,7 +992,7 @@ describe("LiquidityPoolAave", function () {
990992
991993 it ( "Should NOT borrow if the contract is paused" , async function ( ) {
992994 const { liquidityPool, rpl, user, user2, pauser} = await loadFixture ( deployAll ) ;
993-
995+
994996 // Pause the contract
995997 await expect ( liquidityPool . connect ( pauser ) . pause ( ) )
996998 . to . emit ( liquidityPool , "Paused" ) ;
@@ -1173,7 +1175,7 @@ describe("LiquidityPoolAave", function () {
11731175 0n ,
11741176 2000000000n ,
11751177 signature ) )
1176- . to . emit ( mockTarget , "DataReceived" ) . withArgs ( additionalData ) ;
1178+ . to . emit ( mockTarget , "DataReceived" ) . withArgs ( additionalData ) ;
11771179 expect ( await rpl . balanceOf ( liquidityPool . target ) ) . to . eq ( 0 ) ;
11781180 expect ( await rpl . balanceOf ( mockTarget . target ) ) . to . eq ( amountToBorrow ) ;
11791181
@@ -1263,7 +1265,7 @@ describe("LiquidityPoolAave", function () {
12631265 const { liquidityPool, user, liquidityAdmin, pauser} = await loadFixture ( deployAll ) ;
12641266 await expect ( liquidityPool . connect ( pauser ) . pause ( ) )
12651267 . to . emit ( liquidityPool , "Paused" ) ;
1266-
1268+
12671269 await expect ( liquidityPool . connect ( liquidityAdmin ) . withdraw ( user . address , 10 ) )
12681270 . to . be . revertedWithCustomError ( liquidityPool , "EnforcedPause" ) ;
12691271 } ) ;
@@ -1331,7 +1333,7 @@ describe("LiquidityPoolAave", function () {
13311333 "0x" ,
13321334 0n ,
13331335 2000000000n ,
1334- signature1 ) ;
1336+ signature1 ) ;
13351337 expect ( await rpl . balanceOf ( liquidityPool . target ) ) . to . eq ( amountToBorrow ) ;
13361338 expect ( await rplDebtToken . balanceOf ( liquidityPool . target ) ) . to . be . greaterThan ( 0 ) ;
13371339 await expect ( liquidityPool . connect ( withdrawProfit ) . withdrawProfit ( [ rpl . target ] , user . address ) )
0 commit comments