Skip to content

Commit

Permalink
[NES-296] [Fix] Remove double nonreentrant modifiers. (#124)
Browse files Browse the repository at this point in the history
* remove nonreentrant from aggregatetoken override functions

* add comments about double reentrancy
  • Loading branch information
ungaro authored Dec 11, 2024
1 parent a2e043c commit 7c71d3a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions nest/src/AggregateToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {
}

/// @inheritdoc IComponentToken
/// @dev Do not add reentrancy guard here, as it is already handled in the parent contract
function deposit(
uint256 assets,
address receiver,
address controller
) public override(ComponentToken, IComponentToken) nonReentrant returns (uint256 shares) {
) public override(ComponentToken, IComponentToken) returns (uint256 shares) {
if (_getAggregateTokenStorage().paused) {
revert DepositPaused();
}
Expand All @@ -182,15 +183,16 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {

/**
* @inheritdoc ERC4626Upgradeable
* @dev Overridden to add pause check before deposit
* @dev Overridden to add pause check before deposit. Do not add reentrancy guard here, as it is already handled in
* the parent contract
* @param assets Amount of assets to deposit
* @param receiver Address that will receive the shares
* @return shares Amount of shares minted
*/
function deposit(
uint256 assets,
address receiver
) public override(ERC4626Upgradeable, IERC4626) nonReentrant returns (uint256 shares) {
) public override(ERC4626Upgradeable, IERC4626) returns (uint256 shares) {
if (_getAggregateTokenStorage().paused) {
revert DepositPaused();
}
Expand All @@ -199,7 +201,8 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {

/**
* @inheritdoc ComponentToken
* @dev Overridden to add pause check before minting
* @dev Overridden to add pause check before minting. Do not add reentrancy guard here, as it is already handled in
* the parent contract
* @param shares Amount of shares to mint
* @param receiver Address that will receive the shares
* @param controller Address that controls the minting
Expand All @@ -209,7 +212,7 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {
uint256 shares,
address receiver,
address controller
) public override(ComponentToken) nonReentrant returns (uint256 assets) {
) public override(ComponentToken) returns (uint256 assets) {
if (_getAggregateTokenStorage().paused) {
revert DepositPaused();
}
Expand All @@ -218,27 +221,29 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {

/**
* @inheritdoc ERC4626Upgradeable
* @dev Overridden to add pause check before minting
* @dev Overridden to add pause check before minting. Do not add reentrancy guard here, as it is already handled in
* the parent contract
* @param shares Amount of shares to mint
* @param receiver Address that will receive the shares
* @return assets Amount of assets deposited
*/
function mint(
uint256 shares,
address receiver
) public override(ERC4626Upgradeable, IERC4626) nonReentrant returns (uint256 assets) {
) public override(ERC4626Upgradeable, IERC4626) returns (uint256 assets) {
if (_getAggregateTokenStorage().paused) {
revert DepositPaused();
}
return super.mint(shares, receiver);
}

/// @inheritdoc IComponentToken
/// @dev Do not add reentrancy guard here, as it is already handled in the parent contract
function redeem(
uint256 shares,
address receiver,
address controller
) public override(ComponentToken, IComponentToken) nonReentrant returns (uint256 assets) {
) public override(ComponentToken, IComponentToken) returns (uint256 assets) {
return super.redeem(shares, receiver, controller);
}

Expand Down

0 comments on commit 7c71d3a

Please sign in to comment.