Skip to content

Add Mint Cap to Bonding Curve#119

Merged
Joeysantoro merged 1 commit intomasterfrom
feat/BondingCurveCap
Aug 6, 2021
Merged

Add Mint Cap to Bonding Curve#119
Joeysantoro merged 1 commit intomasterfrom
feat/BondingCurveCap

Conversation

@Joeysantoro
Copy link
Contributor

@Joeysantoro Joeysantoro commented Aug 3, 2021

Adds a cap on the amount of FEI minted by a bonding curve to mitigate the damage from infinite minting attacks and oracle malfunctions

});
});

describe('Exceeding cap', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't tell if there is a test in this file that buys under the mint cap to check that its still possible to buy even with the mint cap on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add to this point, I only see purchasing happening in the before each hook and we don't verify the fei they received. Recommend adding a test purchasing from the bonding curve that actually succeeds. After the success, we should verify FEI balances and that the bonding curve or receiving contract's eth balance incremented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are tests for the FEI being received higher up in the file

uint256 public override discount;

/// @notice the cap on how much FEI can be minted by the bonding curve
uint256 public override mintCap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we upgrade the contracts, are we doing it with a proxy/storage pattern or some other method?
If we are using a proxy/storage pattern, the variable should be added after BASIS_POINTS_GRANULARITY.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use proxy/storage its just drop-and-replace

});
});

describe('Exceeding cap', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add to this point, I only see purchasing happening in the before each hook and we don't verify the fei they received. Recommend adding a test purchasing from the bonding curve that actually succeeds. After the success, we should verify FEI balances and that the bonding curve or receiving contract's eth balance incremented.

@eswak
Copy link
Contributor

eswak commented Aug 4, 2021

keep this PR simple, but maybe an idea for later : you could add these mintCap, setMintCap, availableToMint functions, and MintCapUpdate event, in a generic extension "PCVMinterBase" (or something like it), that contracts could inherit.

The minted/burnt amount can be tracked by an override of _burnFeiHeld and _mintFei from CoreRef in this base contract.

When I was working on the Curve deposit with reweights, I wanted to have this kind of tracking of minted / burnt fei, and implement a kind of availableToMint function too. Maybe that's a need that is pretty generic and applies to multiple PCV contracts that have Minter/Burner role ?

@Joeysantoro Joeysantoro merged commit 777bf85 into master Aug 6, 2021
Copy link
Contributor

@thomas-waite thomas-waite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@xklob xklob deleted the feat/BondingCurveCap branch September 19, 2021 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments