-
Notifications
You must be signed in to change notification settings - Fork 195
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
feat: [draft] vaults validators triggerable exits #933
base: feat/vaults
Are you sure you want to change the base?
Conversation
Add role ADD_FULL_WITHDRAWAL_REQUEST_ROLE for full withdrawal requests.
…hdrawal-credentials
Access pubkeys and amounts directly instead of copying them to memory.
pass pubkeys as array of bytes
…o feat/waults-triggerable-exits # Conflicts: # scripts/scratch/steps/0120-initialize-non-aragon-contracts.ts
# Conflicts: # contracts/0.8.25/vaults/Dashboard.sol # test/integration/vaults-happy-path.integration.ts
…le-exits # Conflicts: # contracts/0.8.9/WithdrawalVault.sol # contracts/common/lib/TriggerableWithdrawals.sol
…le-exits # Conflicts: # contracts/common/lib/TriggerableWithdrawals.sol # test/common/lib/triggerableWithdrawals/triggerableWithdrawals.test.ts
function addFullWithdrawalRequests( | ||
bytes calldata pubkeys | ||
) external payable onlyRole(ADD_FULL_WITHDRAWAL_REQUEST_ROLE) { | ||
uint256 prevBalance = address(this).balance - msg.value; | ||
|
||
uint256 minFeePerRequest = TriggerableWithdrawals.getWithdrawalRequestFee(); | ||
uint256 totalFee = (pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH) * minFeePerRequest; | ||
|
||
if (totalFee > msg.value) { | ||
revert InsufficientTriggerableWithdrawalFee( | ||
msg.value, | ||
totalFee, | ||
pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH | ||
); | ||
} | ||
|
||
TriggerableWithdrawals.addFullWithdrawalRequests(pubkeys, minFeePerRequest); | ||
|
||
uint256 refund = msg.value - totalFee; | ||
if (refund > 0) { | ||
(bool success, ) = msg.sender.call{value: refund}(""); | ||
|
||
if (!success) { | ||
revert TriggerableWithdrawalRefundFailed(); | ||
} | ||
} | ||
|
||
assert(address(this).balance == prevBalance); | ||
} |
Check warning
Code scanning / Slither
Divide before multiply Medium
- totalFee = (pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH) * minFeePerRequest
function addFullWithdrawalRequests( | ||
bytes calldata pubkeys | ||
) external payable onlyRole(ADD_FULL_WITHDRAWAL_REQUEST_ROLE) { | ||
uint256 prevBalance = address(this).balance - msg.value; | ||
|
||
uint256 minFeePerRequest = TriggerableWithdrawals.getWithdrawalRequestFee(); | ||
uint256 totalFee = (pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH) * minFeePerRequest; | ||
|
||
if (totalFee > msg.value) { | ||
revert InsufficientTriggerableWithdrawalFee( | ||
msg.value, | ||
totalFee, | ||
pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH | ||
); | ||
} | ||
|
||
TriggerableWithdrawals.addFullWithdrawalRequests(pubkeys, minFeePerRequest); | ||
|
||
uint256 refund = msg.value - totalFee; | ||
if (refund > 0) { | ||
(bool success, ) = msg.sender.call{value: refund}(""); | ||
|
||
if (!success) { | ||
revert TriggerableWithdrawalRefundFailed(); | ||
} | ||
} | ||
|
||
assert(address(this).balance == prevBalance); | ||
} |
Check warning
Code scanning / Slither
Dangerous strict equalities Medium
- assert(bool)(address(this).balance == prevBalance)
41728a7
to
a30cd67
Compare
function _getAndValidateExitFees(bytes calldata _pubkeys) private view returns (uint256 feePerRequest, uint256 totalFee) { | ||
feePerRequest = TriggerableWithdrawals.getWithdrawalRequestFee(); | ||
totalFee = _pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH * feePerRequest; | ||
|
||
if (msg.value < totalFee) { | ||
revert InsufficientExitFee(msg.value, totalFee); | ||
} | ||
|
||
return (feePerRequest, totalFee); | ||
} |
Check warning
Code scanning / Slither
Divide before multiply Medium
- totalFee = _pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH * feePerRequest
Hardhat Unit Tests Coverage Summary
Diff against master
Results for commit: a30cd67 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Add triggerable exits for vaults