@@ -13,6 +13,7 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
13
13
INCONSISTENT_EMODE_CATEGORY ,
14
14
HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD ,
15
15
COLLATERAL_CANNOT_COVER_NEW_BORROW ,
16
+ INVALID_EMODE_CATEGORY_PARAMS ,
16
17
} = ProtocolErrors ;
17
18
18
19
let snapSetup : string ;
@@ -548,6 +549,75 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
548
549
expect ( user4Data . healthFactor ) . to . be . gt ( parseEther ( '1' ) ) ;
549
550
} ) ;
550
551
552
+ it ( 'Admin sets LTV of stablecoins eMode category to zero (revert expected)' , async ( ) => {
553
+ const {
554
+ configurator,
555
+ pool,
556
+ users : [ , user1 ] ,
557
+ } = testEnv ;
558
+
559
+ const { id } = CATEGORIES . STABLECOINS ;
560
+
561
+ const eModeData = await pool . getEModeCategoryData ( id ) ;
562
+ const newLtv = BigNumber . from ( 0 ) ;
563
+
564
+ await expect (
565
+ configurator . setEModeCategory (
566
+ id ,
567
+ newLtv ,
568
+ eModeData . liquidationThreshold ,
569
+ eModeData . liquidationBonus ,
570
+ eModeData . priceSource ,
571
+ eModeData . label
572
+ )
573
+ ) . to . be . revertedWith ( INVALID_EMODE_CATEGORY_PARAMS ) ;
574
+ } ) ;
575
+
576
+ it ( 'Admin sets Liquidation Threshold of stablecoins eMode category to zero (revert expected)' , async ( ) => {
577
+ const { configurator, pool } = testEnv ;
578
+
579
+ const { id } = CATEGORIES . STABLECOINS ;
580
+
581
+ const eModeData = await pool . getEModeCategoryData ( id ) ;
582
+ const newLiquidationThreshold = BigNumber . from ( 0 ) ;
583
+
584
+ await expect (
585
+ configurator . setEModeCategory (
586
+ id ,
587
+ eModeData . ltv ,
588
+ newLiquidationThreshold ,
589
+ eModeData . liquidationBonus ,
590
+ eModeData . priceSource ,
591
+ eModeData . label
592
+ )
593
+ ) . to . be . revertedWith ( INVALID_EMODE_CATEGORY_PARAMS ) ;
594
+ } ) ;
595
+
596
+ it ( 'Admin lowers LTV of stablecoins eMode category below an asset within the eModes individual LTV (revert expected)' , async ( ) => {
597
+ const { configurator, pool, dai, usdc, helpersContract } = testEnv ;
598
+
599
+ const { id } = CATEGORIES . STABLECOINS ;
600
+
601
+ const eModeData = await pool . getEModeCategoryData ( id ) ;
602
+
603
+ // find the min LTV of assets in eMode and submit a new LTV lower
604
+ const daiLtv = ( await helpersContract . getReserveConfigurationData ( dai . address ) ) . ltv ;
605
+ const usdcLtv = ( await helpersContract . getReserveConfigurationData ( usdc . address ) ) . ltv ;
606
+ const maxExistingLtv = daiLtv . sub ( usdcLtv ) . gte ( 0 ) ? daiLtv : usdcLtv ;
607
+ const newLtv = maxExistingLtv . sub ( 1 ) ;
608
+
609
+ await expect (
610
+ configurator . setEModeCategory (
611
+ id ,
612
+ newLtv ,
613
+ eModeData . liquidationThreshold ,
614
+ eModeData . liquidationBonus ,
615
+ eModeData . priceSource ,
616
+ eModeData . label
617
+ )
618
+ ) . to . be . revertedWith ( INVALID_EMODE_CATEGORY_PARAMS ) ;
619
+ } ) ;
620
+
551
621
it ( 'Admin lowers LTV of stablecoins eMode category, decreasing user borrowing power' , async ( ) => {
552
622
const {
553
623
configurator,
@@ -560,7 +630,7 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
560
630
const userDataBefore = await pool . getUserAccountData ( user1 . address ) ;
561
631
562
632
const eModeData = await pool . getEModeCategoryData ( id ) ;
563
- const newLtv = BigNumber . from ( eModeData . ltv . toString ( ) ) . div ( 2 ) ;
633
+ const newLtv = BigNumber . from ( '9500' ) ;
564
634
565
635
expect (
566
636
await configurator . setEModeCategory (
@@ -605,6 +675,28 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
605
675
) ;
606
676
} ) ;
607
677
678
+ it ( 'Admin lowers LT of stablecoins eMode category below an asset within the eModes individual LT (revert expected)' , async ( ) => {
679
+ const { configurator, pool } = testEnv ;
680
+
681
+ const { id } = CATEGORIES . STABLECOINS ;
682
+
683
+ const eModeData = await pool . getEModeCategoryData ( id ) ;
684
+
685
+ const newLtv = BigNumber . from ( 8300 ) ;
686
+ const newLt = BigNumber . from ( 8500 ) ;
687
+
688
+ await expect (
689
+ configurator . setEModeCategory (
690
+ id ,
691
+ newLtv ,
692
+ newLt ,
693
+ eModeData . liquidationBonus ,
694
+ eModeData . priceSource ,
695
+ eModeData . label
696
+ )
697
+ ) . to . be . revertedWith ( INVALID_EMODE_CATEGORY_PARAMS ) ;
698
+ } ) ;
699
+
608
700
it ( 'Admin lowers LT of stablecoins eMode category, decreasing user health factor' , async ( ) => {
609
701
const {
610
702
configurator,
@@ -617,7 +709,8 @@ makeSuite('EfficiencyMode', (testEnv: TestEnv) => {
617
709
const userDataBefore = await pool . getUserAccountData ( user1 . address ) ;
618
710
619
711
const eModeData = await pool . getEModeCategoryData ( id ) ;
620
- const newLt = BigNumber . from ( '8000' ) ;
712
+ const newLt = eModeData . ltv ;
713
+
621
714
expect (
622
715
await configurator . setEModeCategory (
623
716
id ,
0 commit comments