-
Notifications
You must be signed in to change notification settings - Fork 37
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
Conversation
asselstine
commented
Aug 15, 2023
- Hooks have gas limits
- Hook failures are recorded during batch calls, so they can be avoided.
src/Vault.sol
Outdated
error BeforeClaimPrizeFailed(bytes reason); | ||
|
||
error AfterClaimPrizeFailed(bytes reason); | ||
|
||
uint256 constant HOOK_GAS = 150_000; |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Natspec doc.