From 63e8b3ba7d8917548538ebc81d0c2399ce7b9bf9 Mon Sep 17 00:00:00 2001 From: Adrian Soghoian Date: Thu, 20 Oct 2022 14:15:55 -0400 Subject: [PATCH 1/2] Allow setting pool capacity --- contracts/Pool.sol | 12 ++++++------ contracts/interfaces/IPool.sol | 4 ++-- test/Pool.test.ts | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/contracts/Pool.sol b/contracts/Pool.sol index 4cda810f..82b1ea6e 100644 --- a/contracts/Pool.sol +++ b/contracts/Pool.sol @@ -296,13 +296,13 @@ contract Pool is IPool, ERC20 { } /** - * @dev Updates the pool capacity. Can only be called by the Pool Manager. + * @inheritdoc IPool */ - function updatePoolCapacity(uint256) - external - onlyManager - returns (uint256) - {} + function updatePoolCapacity(uint256 newCapacity) external onlyManager { + require(newCapacity >= totalAssets(), "Pool: invalid capacity"); + _poolSettings.maxCapacity = newCapacity; + emit PoolSettingsUpdated(); + } /** * @dev Updates the pool end date. Can only be called by the Pool Manager. diff --git a/contracts/interfaces/IPool.sol b/contracts/interfaces/IPool.sol index 280b1f1a..ee68de09 100644 --- a/contracts/interfaces/IPool.sol +++ b/contracts/interfaces/IPool.sol @@ -86,7 +86,7 @@ interface IPool is IERC4626 { /** * @dev Emitted when pool settings are updated. */ - event PoolSettingsUpdated(IPoolConfigurableSettings settings); + event PoolSettingsUpdated(); /** * @dev Emitted when first loss capital is used to cover loan defaults @@ -155,7 +155,7 @@ interface IPool is IERC4626 { /** * @dev Updates the pool capacity. Can only be called by the Pool Manager. */ - function updatePoolCapacity(uint256) external returns (uint256); + function updatePoolCapacity(uint256) external; /** * @dev Updates the pool end date. Can only be called by the Pool Manager. diff --git a/test/Pool.test.ts b/test/Pool.test.ts index b0f475c1..b0bf7d0c 100644 --- a/test/Pool.test.ts +++ b/test/Pool.test.ts @@ -400,6 +400,7 @@ describe("Pool", () => { }); }); +<<<<<<< HEAD describe("previewDeposit()", async () => { it("includes interest when calculating deposit exchange rate", async () => { const lender = (await ethers.getSigners())[10]; @@ -452,6 +453,33 @@ describe("Pool", () => { }); }); + describe("updatePoolCapacity()", () => { + it("prevents setting capacity to less than current pool size", async () => { + const { pool, otherAccount, poolManager, liquidityAsset } = + await loadFixture(loadPoolFixture); + + await activatePool(pool, poolManager, liquidityAsset); + await depositToPool(pool, otherAccount, liquidityAsset, 100); + await expect( + pool.connect(poolManager).updatePoolCapacity(1) + ).to.be.revertedWith("Pool: invalid capacity"); + }); + + it("allows setting pool capacity", async () => { + const { pool, otherAccount, poolManager, liquidityAsset } = + await loadFixture(loadPoolFixture); + + await activatePool(pool, poolManager, liquidityAsset); + await depositToPool(pool, otherAccount, liquidityAsset, 100); + await expect(pool.connect(poolManager).updatePoolCapacity(101)).to.emit( + pool, + "PoolSettingsUpdated" + ); + + expect((await pool.settings()).maxCapacity).to.equal(101); + }); + }); + describe("Permissions", () => { describe("updatePoolCapacity()", () => { it("reverts if not called by Pool Manager", async () => { From 4789f396538fcb5f5e27e4488a2181d570a5abba Mon Sep 17 00:00:00 2001 From: Adrian Soghoian Date: Tue, 25 Oct 2022 09:27:53 -0400 Subject: [PATCH 2/2] Post rebase lint --- test/Pool.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Pool.test.ts b/test/Pool.test.ts index b0bf7d0c..619cea87 100644 --- a/test/Pool.test.ts +++ b/test/Pool.test.ts @@ -400,7 +400,6 @@ describe("Pool", () => { }); }); -<<<<<<< HEAD describe("previewDeposit()", async () => { it("includes interest when calculating deposit exchange rate", async () => { const lender = (await ethers.getSigners())[10];