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

Sherlock 105.md #571

Merged
merged 1 commit into from
Feb 8, 2023
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
2 changes: 2 additions & 0 deletions src/ERC721Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ contract ERC721Pool is FlashloanablePool, IERC721Pool {
uint256 noOfNFTsToRemove_,
uint256 toIndex_
) external override nonReentrant returns (uint256 collateralMerged_, uint256 bucketLPs_) {
_revertIfAuctionClearable(auctions, loans);

PoolState memory poolState = _accruePoolInterest();
uint256 collateralAmount = Maths.wad(noOfNFTsToRemove_);

Expand Down
11 changes: 11 additions & 0 deletions tests/forge/ERC721Pool/ERC721DSTestPlus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,17 @@ abstract contract ERC721DSTestPlus is DSTestPlus, IERC721PoolEvents {
ERC721Pool(address(_pool)).drawDebt(from, amount, indexLimit, emptyArray);
}

function _assertMergeRemoveCollateralAuctionNotClearedRevert(
address from,
uint256 toIndex,
uint256 noOfNFTsToRemove,
uint256[] memory removeCollateralAtIndex
) internal {
changePrank(from);
vm.expectRevert(abi.encodeWithSignature('AuctionNotCleared()'));
ERC721Pool(address(_pool)).mergeOrRemoveCollateral(removeCollateralAtIndex, noOfNFTsToRemove, toIndex);
}

function _assertCannotMergeToHigherPriceRevert(
address from,
uint256 toIndex,
Expand Down
16 changes: 16 additions & 0 deletions tests/forge/ERC721Pool/ERC721PoolLiquidationsSettle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ contract ERC721PoolLiquidationsSettleTest is ERC721HelperContract {
})
);

// revert if auction is not settled
_assertMergeRemoveCollateralAuctionNotClearedRevert({
from: _lender,
toIndex: MAX_FENWICK_INDEX,
noOfNFTsToRemove: 2,
removeCollateralAtIndex: new uint256[](0)
});

_settle({
from: _lender,
borrower: _borrower2,
Expand All @@ -227,6 +235,14 @@ contract ERC721PoolLiquidationsSettleTest is ERC721HelperContract {
})
);

// revert if auction is not settled
_assertMergeRemoveCollateralAuctionNotClearedRevert({
from: _lender,
toIndex: MAX_FENWICK_INDEX,
noOfNFTsToRemove: 2,
removeCollateralAtIndex: new uint256[](0)
});

// settle borrower
_settle({
from: _lender,
Expand Down