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

Audit fix: InvalidClaimableAmount params order #159

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions contracts/libraries/AssetsAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ library AssetsAccounting {

error InvalidSharesValue(SharesValue value);
error InvalidUnstETHStatus(uint256 unstETHId, UnstETHRecordStatus status);
error InvalidUnstETHHolder(uint256 unstETHId, address actual, address expected);
error InvalidUnstETHHolder(uint256 unstETHId, address holder);
error MinAssetsLockDurationNotPassed(Timestamp lockDurationExpiresAt);
error InvalidClaimableAmount(uint256 unstETHId, ETHValue expected, ETHValue actual);
error InvalidClaimableAmount(uint256 unstETHId, ETHValue claimableAmount);

// ---
// stETH shares operations accounting
Expand Down Expand Up @@ -339,7 +339,7 @@ library AssetsAccounting {
UnstETHRecord storage unstETHRecord = self.unstETHRecords[unstETHId];

if (unstETHRecord.lockedBy != holder) {
revert InvalidUnstETHHolder(unstETHId, holder, unstETHRecord.lockedBy);
revert InvalidUnstETHHolder(unstETHId, holder);
}

if (unstETHRecord.status == UnstETHRecordStatus.NotLocked) {
Expand Down Expand Up @@ -389,7 +389,7 @@ library AssetsAccounting {
if (unstETHRecord.status == UnstETHRecordStatus.Finalized) {
// if the unstETH was marked finalized earlier, it's claimable amount must stay the same
if (unstETHRecord.claimableAmount != claimableAmount) {
revert InvalidClaimableAmount(unstETHId, claimableAmount, unstETHRecord.claimableAmount);
revert InvalidClaimableAmount(unstETHId, claimableAmount);
}
} else {
unstETHRecord.claimableAmount = claimableAmount;
Expand All @@ -408,7 +408,7 @@ library AssetsAccounting {
revert InvalidUnstETHStatus(unstETHId, unstETHRecord.status);
}
if (unstETHRecord.lockedBy != holder) {
revert InvalidUnstETHHolder(unstETHId, holder, unstETHRecord.lockedBy);
revert InvalidUnstETHHolder(unstETHId, holder);
}
unstETHRecord.status = UnstETHRecordStatus.Withdrawn;
amountWithdrawn = unstETHRecord.claimableAmount;
Expand Down
19 changes: 4 additions & 15 deletions test/unit/libraries/AssetsAccounting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,7 @@ contract AssetsAccountingUnitTests is UnitTest {
uint256[] memory unstETHIds = new uint256[](1);
unstETHIds[0] = genRandomUnstEthId(1234);

vm.expectRevert(
abi.encodeWithSelector(AssetsAccounting.InvalidUnstETHHolder.selector, unstETHIds[0], holder, address(0x0))
);
vm.expectRevert(abi.encodeWithSelector(AssetsAccounting.InvalidUnstETHHolder.selector, unstETHIds[0], holder));

AssetsAccounting.accountUnstETHUnlock(_accountingContext, holder, unstETHIds);
}
Expand All @@ -798,9 +796,7 @@ contract AssetsAccountingUnitTests is UnitTest {
unstETHIds[0] = genRandomUnstEthId(1234);
_accountingContext.unstETHRecords[unstETHIds[0]].lockedBy = holder;

vm.expectRevert(
abi.encodeWithSelector(AssetsAccounting.InvalidUnstETHHolder.selector, unstETHIds[0], current, holder)
);
vm.expectRevert(abi.encodeWithSelector(AssetsAccounting.InvalidUnstETHHolder.selector, unstETHIds[0], current));

AssetsAccounting.accountUnstETHUnlock(_accountingContext, current, unstETHIds);
}
Expand Down Expand Up @@ -1251,12 +1247,7 @@ contract AssetsAccountingUnitTests is UnitTest {
}

vm.expectRevert(
abi.encodeWithSelector(
AssetsAccounting.InvalidClaimableAmount.selector,
unstETHIds[0],
claimableAmounts[0],
uint256(claimableAmounts[0]) + 1
)
abi.encodeWithSelector(AssetsAccounting.InvalidClaimableAmount.selector, unstETHIds[0], claimableAmounts[0])
);

AssetsAccounting.accountUnstETHClaimed(_accountingContext, unstETHIds, claimableAmountsPrepared);
Expand Down Expand Up @@ -1392,9 +1383,7 @@ contract AssetsAccountingUnitTests is UnitTest {
_accountingContext.unstETHRecords[unstETHIds[0]].lockedBy = holder;
_accountingContext.unstETHRecords[unstETHIds[0]].claimableAmount = ETHValues.from(123);

vm.expectRevert(
abi.encodeWithSelector(AssetsAccounting.InvalidUnstETHHolder.selector, unstETHIds[0], current, holder)
);
vm.expectRevert(abi.encodeWithSelector(AssetsAccounting.InvalidUnstETHHolder.selector, unstETHIds[0], current));

AssetsAccounting.accountUnstETHWithdraw(_accountingContext, current, unstETHIds);
}
Expand Down