Skip to content

Commit

Permalink
Add invariant_Tranche_K
Browse files Browse the repository at this point in the history
  • Loading branch information
bin-57blocks committed Feb 8, 2024
1 parent 272bdf2 commit dbf13c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/invariant/BaseInvariants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {BaseTest} from "./BaseTest.sol";
import {EpochManager} from "contracts/liquidity/EpochManager.sol";
import {PayPeriodDuration} from "contracts/common/SharedDefs.sol";
import {PoolSettings, LPConfig, FrontLoadingFeesStructure, FeeStructure, FirstLossCoverConfig} from "contracts/common/PoolConfig.sol";
import {BORROWER_LOSS_COVER_INDEX, ADMIN_LOSS_COVER_INDEX, SENIOR_TRANCHE, JUNIOR_TRANCHE} from "contracts/common/SharedDefs.sol";
import {BORROWER_LOSS_COVER_INDEX, ADMIN_LOSS_COVER_INDEX, SENIOR_TRANCHE, JUNIOR_TRANCHE, HUNDRED_PERCENT_IN_BPS} from "contracts/common/SharedDefs.sol";
import {CreditRecord, CreditConfig, CreditState, DueDetail} from "contracts/credit/CreditStructs.sol";

import "forge-std/console.sol";
Expand Down Expand Up @@ -398,6 +398,14 @@ contract BaseInvariants is BaseTest {
);
}

function _assert_Tranche_K() internal {
assertGe(
juniorTranche.totalAssets() * poolConfig.getLPConfig().maxSeniorJuniorRatio,
seniorTranche.totalAssets(),
"Tranche Invariant K"
);
}

function _assert_EpochManager_A() internal {
EpochManager.CurrentEpoch memory epoch = epochManager.currentEpoch();
assertGt(epoch.endTime, block.timestamp, "EpochManager Invariant A");
Expand Down
5 changes: 5 additions & 0 deletions test/invariant/LiquidityInvariants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ contract LiquidityInvariants is BaseInvariants {
_assert_Tranche_J();
}

function invariant_Tranche_K() public {
_assert_Tranche_K();
}

function invariant_EpochManager_A() public {
_assert_EpochManager_A();
}
Expand Down Expand Up @@ -147,6 +151,7 @@ contract LiquidityInvariants is BaseInvariants {
_assert_Tranche_G();
_assert_Tranche_H_I();
_assert_Tranche_J();
_assert_Tranche_K();
}

function test_EpochManager_invariants() public {
Expand Down

0 comments on commit dbf13c1

Please sign in to comment.