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

[NES-253] add function to call requestDeposit #92

Merged
merged 2 commits into from
Nov 12, 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
13 changes: 12 additions & 1 deletion nest/src/AggregateToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,22 @@ contract AggregateToken is ComponentToken, IAggregateToken, ERC1155Holder {
emit ComponentTokenSold(msg.sender, componentToken, componentTokenAmount, assets);
}

/**
* @notice Request to buy ComponentToken.
* @dev Only the owner can call this function. This function requests the purchase of ComponentToken, which will be
* processed later.
* @param componentToken ComponentToken to buy
* @param assets Amount of `asset` to pay to receive the ComponentToken
*/
function requestBuyComponentToken(IComponentToken componentToken, uint256 assets) public onlyRole(ADMIN_ROLE) {
uint256 requestId = componentToken.requestDeposit(assets, address(this), address(this));
emit ComponentTokenBuyRequested(msg.sender, componentToken, assets, requestId);
}

/**
* @notice Request to sell ComponentToken.
* @dev Only the owner can call this function. This function requests the sale of ComponentToken, which will be
* processed later.
*
* @param componentToken ComponentToken to sell
* @param componentTokenAmount Amount of ComponentToken to sell
*/
Expand Down
12 changes: 11 additions & 1 deletion nest/src/interfaces/IAggregateToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,19 @@ interface IAggregateToken is IComponentToken {
address indexed owner, IComponentToken indexed componentToken, uint256 componentTokenAmount, uint256 assets
);

/**
* @notice Emitted when the owner requests to buy a ComponentToken.
* @param owner Address of the owner who requested to buy the ComponentToken.
* @param componentToken ComponentToken that was requested to be bought.
* @param assets Amount of `asset` requested to be paid.
* @param requestId The ID of the buy request.
*/
event ComponentTokenBuyRequested(
address indexed owner, IComponentToken indexed componentToken, uint256 assets, uint256 requestId
);

/**
* @notice Emitted when the owner requests to sell a ComponentToken.
*
* @param owner Address of the owner who requested to sell the ComponentToken.
* @param componentToken ComponentToken that was requested to be sold.
* @param componentTokenAmount Amount of ComponentToken requested to be sold.
Expand Down