Skip to content

Commit

Permalink
fix: PVE004-3
Browse files Browse the repository at this point in the history
  • Loading branch information
UrAvgDeveloper committed Dec 27, 2022
1 parent 4e9070f commit b4cc242
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/Pool/PoolRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ contract PoolRegistry is Ownable2StepUpgradeable {
* @notice Add a market to an existing pool and then mint to provide initial supply
*/
function addMarket(AddMarketInput memory input) external onlyOwner {
require(
_vTokens[input.comptroller][input.asset] == address(0),
"RegistryPool: Market already added for asset comptroller combination"
);

InterestRateModel rate;
if (input.rateModel == InterestRateModels.JumpRate) {
rate = InterestRateModel(
Expand Down
9 changes: 9 additions & 0 deletions tests/hardhat/PoolRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ describe("PoolRegistry: Tests", function () {
expect(await vToken.accessControlManager()).to.equal(fakeAccessControlManager.address);
});

it("reverts if market is readded with same comptroller asset combination", async () => {
await mockToken.faucet(INITIAL_SUPPLY);
await mockToken.approve(poolRegistry.address, INITIAL_SUPPLY);

await expect(poolRegistry.addMarket(await withDefaultMarketParameters())).to.be.revertedWith(
"RegistryPool: Market already added for asset comptroller combination",
);
});

it("sets rate model to a new JumpRateModel with the correct parameters", async () => {
await mockToken.faucet(INITIAL_SUPPLY);
await mockToken.approve(poolRegistry.address, INITIAL_SUPPLY);
Expand Down

0 comments on commit b4cc242

Please sign in to comment.