Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VAL-36 Allow setting pool capacity #54

Merged
merged 2 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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