Skip to content

Commit

Permalink
VAL-36 Allow setting pool capacity (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
ams9198 authored Oct 25, 2022
1 parent f2555b5 commit ebe0307
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
12 changes: 6 additions & 6 deletions contracts/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
27 changes: 27 additions & 0 deletions test/Pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,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 () => {
Expand Down

0 comments on commit ebe0307

Please sign in to comment.