Skip to content

Commit dbf13c1

Browse files
committed
Add invariant_Tranche_K
1 parent 272bdf2 commit dbf13c1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

test/invariant/BaseInvariants.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {BaseTest} from "./BaseTest.sol";
55
import {EpochManager} from "contracts/liquidity/EpochManager.sol";
66
import {PayPeriodDuration} from "contracts/common/SharedDefs.sol";
77
import {PoolSettings, LPConfig, FrontLoadingFeesStructure, FeeStructure, FirstLossCoverConfig} from "contracts/common/PoolConfig.sol";
8-
import {BORROWER_LOSS_COVER_INDEX, ADMIN_LOSS_COVER_INDEX, SENIOR_TRANCHE, JUNIOR_TRANCHE} from "contracts/common/SharedDefs.sol";
8+
import {BORROWER_LOSS_COVER_INDEX, ADMIN_LOSS_COVER_INDEX, SENIOR_TRANCHE, JUNIOR_TRANCHE, HUNDRED_PERCENT_IN_BPS} from "contracts/common/SharedDefs.sol";
99
import {CreditRecord, CreditConfig, CreditState, DueDetail} from "contracts/credit/CreditStructs.sol";
1010

1111
import "forge-std/console.sol";
@@ -398,6 +398,14 @@ contract BaseInvariants is BaseTest {
398398
);
399399
}
400400

401+
function _assert_Tranche_K() internal {
402+
assertGe(
403+
juniorTranche.totalAssets() * poolConfig.getLPConfig().maxSeniorJuniorRatio,
404+
seniorTranche.totalAssets(),
405+
"Tranche Invariant K"
406+
);
407+
}
408+
401409
function _assert_EpochManager_A() internal {
402410
EpochManager.CurrentEpoch memory epoch = epochManager.currentEpoch();
403411
assertGt(epoch.endTime, block.timestamp, "EpochManager Invariant A");

test/invariant/LiquidityInvariants.t.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ contract LiquidityInvariants is BaseInvariants {
100100
_assert_Tranche_J();
101101
}
102102

103+
function invariant_Tranche_K() public {
104+
_assert_Tranche_K();
105+
}
106+
103107
function invariant_EpochManager_A() public {
104108
_assert_EpochManager_A();
105109
}
@@ -147,6 +151,7 @@ contract LiquidityInvariants is BaseInvariants {
147151
_assert_Tranche_G();
148152
_assert_Tranche_H_I();
149153
_assert_Tranche_J();
154+
_assert_Tranche_K();
150155
}
151156

152157
function test_EpochManager_invariants() public {

0 commit comments

Comments
 (0)