Skip to content

Commit

Permalink
_beforeTokenTransfer auditor suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
jtfirek committed Oct 8, 2024
1 parent 601ff25 commit f979658
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
9 changes: 6 additions & 3 deletions src/WithdrawRequestNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,12 @@ contract WithdrawRequestNFT is ERC721Upgradeable, UUPSUpgradeable, OwnableUpgrad

// invalid NFTs is non-transferable except for the case they are being burnt by the owner via `seizeInvalidRequest`
function _beforeTokenTransfer(address /*from*/, address /*to*/, uint256 firstTokenId, uint256 batchSize) internal view override {
for (uint256 i = 0; i < batchSize; i++) {
uint256 tokenId = firstTokenId + i;
require(_requests[tokenId].isValid || msg.sender == owner(), "INVALID_REQUEST");
if (msg.sender != owner()) {
// if not called by the contract owner, only allow transfers of valid NFTs
for (uint256 i = 0; i < batchSize; i++) {
uint256 tokenId = firstTokenId + i;
require(_requests[tokenId].isValid, "INVALID_REQUEST");
}
}
}

Expand Down
11 changes: 1 addition & 10 deletions test/WithdrawRequestNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -311,24 +311,15 @@ contract WithdrawRequestNFTTest is TestSetup {
assertEq(eETHInstance.balanceOf(address(withdrawRequestNFTInstance)), 8);
// Within `LP.requestWithdraw`
// - `share` is calculated by `sharesForAmount` as (9 * 98) / 100 = 8.82 ---> (rounded down to) 8

uint256 dustSharesBefore = withdrawRequestNFTInstance.getAccumulatedDustEEthAmount();
console.log("dustSharesBefore: ", dustSharesBefore);


vm.prank(address(membershipManagerInstance));
liquidityPoolInstance.rebase(2);

_finalizeWithdrawalRequest(requestId);

uint256 dustSharesAfter = withdrawRequestNFTInstance.getAccumulatedDustEEthAmount();
console.log("dustSharesAfter: ", dustSharesAfter);

vm.prank(bob);
withdrawRequestNFTInstance.claimWithdraw(requestId, 1);

uint256 dustSharesAfter2 = withdrawRequestNFTInstance.getAccumulatedDustEEthAmount();
console.log("dustSharesAfter2: ", dustSharesAfter2);

// Within `claimWithdraw`,
// - `request.amountOfEEth` is 9
// - `amountForShares` is (8 * 100) / 98 = 8.16 ---> (rounded down to) 8
Expand Down

0 comments on commit f979658

Please sign in to comment.