Skip to content

Commit

Permalink
add setAsyncFlags (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
ungaro authored Jan 2, 2025
1 parent f485bf4 commit dbacef9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 42 deletions.
43 changes: 1 addition & 42 deletions nest/src/AggregateToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {
/// @notice Emitted when the AggregateToken contract is unpaused for deposits
event Unpaused();

/// @notice Emitted when the asset token is updated
event AssetTokenUpdated(IERC20 indexed oldAsset, IERC20 indexed newAsset);

/// @notice Emitted when vault tokens are bought
event VaultTokenBought(address indexed buyer, address indexed token, uint256 assets, uint256 shares);

Expand All @@ -78,21 +75,12 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {
*/
error ComponentTokenAlreadyListed(IComponentToken componentToken);

/// @notice Emitted when a ComponentToken is removed from the component token list
event ComponentTokenRemoved(IComponentToken indexed componentToken);

/**
* @notice Indicates a failure because the ComponentToken is not in the component token list
* @param componentToken ComponentToken that is not in the component token list
*/
error ComponentTokenNotListed(IComponentToken componentToken);

/**
* @notice Indicates a failure because the ComponentToken has a non-zero balance
* @param componentToken ComponentToken that has a non-zero balance
*/
error ComponentTokenBalanceNonZero(IComponentToken componentToken);

/**
* @notice Indicates a failure because the ComponentToken is the current `asset
* @param componentToken ComponentToken that is the current `asset`
Expand Down Expand Up @@ -157,7 +145,7 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {
uint256 askPrice,
uint256 bidPrice
) public initializer {
super.initialize(owner, name, symbol, IERC20(address(asset_)), false, true);
super.initialize(owner, name, symbol, IERC20(address(asset_)), false, false);

AggregateTokenStorage storage $ = _getAggregateTokenStorage();
$.componentTokenList.push(asset_);
Expand All @@ -167,35 +155,6 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {
$.paused = false;
}

/**
* @notice Reinitialize the AggregateToken
* @param owner Address of the owner of the AggregateToken
* @param name Name of the AggregateToken
* @param symbol Symbol of the AggregateToken
* @param asset_ Asset used to mint and burn the AggregateToken
* @param askPrice Price at which users can buy the AggregateToken using `asset`, times the base
* @param bidPrice Price at which users can sell the AggregateToken to receive `asset`, times the base
*/
function reinitialize(
address owner,
string memory name,
string memory symbol,
IComponentToken asset_,
uint256 askPrice,
uint256 bidPrice
) public onlyRole(UPGRADER_ROLE) reinitializer(2) {
super.reinitialize(owner, name, symbol, IERC20(address(asset_)), false, true);

AggregateTokenStorage storage $ = _getAggregateTokenStorage();
if (!$.componentTokenMap[asset_]) {
$.componentTokenList.push(asset_);
$.componentTokenMap[asset_] = true;
emit ComponentTokenListed(asset_);
}
$.askPrice = askPrice;
$.bidPrice = bidPrice;
}

// Override Functions

/**
Expand Down
6 changes: 6 additions & 0 deletions nest/src/ComponentToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -710,4 +710,10 @@ abstract contract ComponentToken is
revert Unimplemented();
}

function setAsyncFlags(bool asyncDeposit, bool asyncRedeem) external onlyRole(UPGRADER_ROLE) {
ComponentTokenStorage storage $ = _getComponentTokenStorage();
$.asyncDeposit = asyncDeposit;
$.asyncRedeem = asyncRedeem;
}

}

0 comments on commit dbacef9

Please sign in to comment.