Skip to content

Commit

Permalink
Cleanup: only read new Pool.lifeCycleState() computed value instead o…
Browse files Browse the repository at this point in the history
…f stored var (#57)
  • Loading branch information
ams9198 authored Oct 21, 2022
1 parent a5f074a commit 18dc192
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
11 changes: 6 additions & 5 deletions contracts/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ contract Pool is IPool, ERC20 {
* @dev Modifier that checks that the pool is Initialized or Active
*/
modifier atInitializedOrActiveState() {
IPoolLifeCycleState _lifecycle = lifeCycleState();
require(
_poolLifeCycleState == IPoolLifeCycleState.Active ||
_poolLifeCycleState == IPoolLifeCycleState.Initialized,
_lifecycle == IPoolLifeCycleState.Active ||
_lifecycle == IPoolLifeCycleState.Initialized,
"Pool: invalid pool state"
);
_;
Expand All @@ -97,7 +98,7 @@ contract Pool is IPool, ERC20 {
*/
modifier atState(IPoolLifeCycleState state) {
require(
_poolLifeCycleState == state,
lifeCycleState() == state,
"Pool: FunctionInvalidAtThisLifeCycleState"
);
_;
Expand Down Expand Up @@ -263,7 +264,7 @@ contract Pool is IPool, ERC20 {
spender,
amount,
address(_firstLossVault),
_poolLifeCycleState,
lifeCycleState(),
_poolSettings.firstLossInitialMinimum
);

Expand Down Expand Up @@ -784,7 +785,7 @@ contract Pool is IPool, ERC20 {
{
return
PoolLib.calculateMaxDeposit(
_poolLifeCycleState,
lifeCycleState(),
_poolSettings.maxCapacity,
totalAssets()
);
Expand Down
13 changes: 13 additions & 0 deletions test/Pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ describe("Pool", () => {
});
});

describe("lifeCycleState()", () => {
it("is closed when pool end date passes", async () => {
const { pool } = await loadFixture(loadPoolFixture);

expect(await pool.lifeCycleState()).to.equal(0); // initialized

const poolEndDate = (await pool.settings()).endDate;
await time.increaseTo(poolEndDate);

expect(await pool.lifeCycleState()).to.equal(3); // closed
});
});

describe("setRequestFee()", () => {
it("sets the request fee in Bps", async () => {
const { pool, poolManager } = await loadFixture(loadPoolFixture);
Expand Down

0 comments on commit 18dc192

Please sign in to comment.