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

Implemented safety mechanisms around vault hooks #21

Merged
merged 2 commits into from
Aug 15, 2023

Conversation

asselstine
Copy link
Contributor

  • Hooks have gas limits
  • Hook failures are recorded during batch calls, so they can be avoided.

src/Vault.sol Outdated
Comment on lines 101 to 105
error BeforeClaimPrizeFailed(bytes reason);

error AfterClaimPrizeFailed(bytes reason);

uint256 constant HOOK_GAS = 150_000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add Natspec docs.

@@ -199,6 +205,13 @@ contract Vault is ERC4626, ERC20Permit, ILiquidationSource, Ownable {
*/
event RecordedExchangeRate(uint256 exchangeRate);

event ClaimFailed(
Copy link
Contributor

Choose a reason for hiding this comment

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

Add Natspec doc.

@@ -1038,6 +1058,15 @@ contract Vault is ERC4626, ERC20Permit, ILiquidationSource, Ownable {
}

/* ============ Claim Functions ============ */
function claimPrize(
Copy link
Contributor

Choose a reason for hiding this comment

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

Add Natspec doc.

address _winner,
uint8 _tier,
uint32 _prizeIndex,
uint96 _fee,
address _feeRecipient
) internal returns (uint256) {
) external returns (uint256) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be internal no? Or even private.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has to be external because of the try catch. Kind of a weird trick

@@ -1239,4 +1271,9 @@ contract Vault is ERC4626, ERC20Permit, ILiquidationSource, Ownable {
function _setYieldFeeRecipient(address yieldFeeRecipient_) internal {
_yieldFeeRecipient = yieldFeeRecipient_;
}

modifier onlyClaimer() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add Natspec doc.

@asselstine asselstine merged commit 8e3f87e into main Aug 15, 2023
1 of 2 checks passed
@asselstine asselstine deleted the gen-322-c4-issue-465-hooks branch August 15, 2023 22:36
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.

2 participants