Skip to content

Commit

Permalink
Update multiwrap interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishang Nadgauda authored and Krishang Nadgauda committed Mar 30, 2022
1 parent 8f0eb2b commit 9f6ab6d
Showing 1 changed file with 56 additions and 21 deletions.
77 changes: 56 additions & 21 deletions contracts/interfaces/IMultiwrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,85 @@ pragma solidity ^0.8.11;
import "./IThirdwebContract.sol";
import "./IThirdwebRoyalty.sol";
import "./IThirdwebOwnable.sol";
import "../lib/MultiTokenTransferLib.sol";

/**
* Thirdweb's Multiwrap contract lets you wrap arbitrary ERC20, ERC721 and ERC1155
* tokens you own into a single wrapped token / NFT.
*
* A wrapped NFT can be unwrapped i.e. burned in exchange for its underlying contents.
*/

interface IMultiwrap is IThirdwebContract, IThirdwebOwnable, IThirdwebRoyalty {

/// @notice The type of assets that can be wrapped.
enum TokenType { ERC20, ERC721, ERC1155 }

/**
* @notice A generic interface to describe a token to wrap.
*
* @param assetContract The contract address of the asset to wrap.
* @param tokenType The token type (ERC20 / ERC721 / ERC1155) of the asset to wrap.
* @param tokenId The token Id of the asset to wrap, if the asset is an ERC721 / ERC1155 NFT.
* @param amount The amount of the asset to wrap, if the asset is an ERC20 / ERC1155 fungible token.
*/
struct Token {
address assetContract;
TokenType tokenType;
uint256 tokenId;
uint256 amount;
}

/**
* @notice An internal data structure to track the wrapped contents of a wrapped NFT.
*
* @param count The total kinds of assets i.e. `Token` wrapped.
* @param token Mapping from a UID -> to the asset i.e. `Token` at that UID.
*/
struct WrappedContents {
uint256 count;
mapping(uint256 => Token) token;
}

/// @dev Emitted when tokens are wrapped.
event TokensWrapped(
address indexed wrapper,
uint256 indexed tokenIdOfShares,
MultiTokenTransferLib.MultiToken wrappedContents
address indexed recipientOfWrappedToken,
uint256 indexed tokenIdOfWrappedToken,
Token[] wrappedContents
);

/// @dev Emitted when tokens are unwrapped.
event TokensUnwrapped(
address indexed wrapper,
address sentTo,
uint256 indexed tokenIdOfShares,
uint256 sharesUnwrapped,
MultiTokenTransferLib.MultiToken wrappedContents
address indexed unwrapper,
address indexed recipientOfWrappedContents,
uint256 indexed tokenIdOfWrappedToken,
Token[] wrappedContents
);

/// @dev Emitted when a new Owner is set.
/// @dev Emitted when the contract owner is updated.
event OwnerUpdated(address prevOwner, address newOwner);

/**
* @notice Wrap multiple ERC1155, ERC721, ERC20 tokens into 'n' shares (i.e. variable supply of 1 ERC 1155 token)
* @notice Wrap multiple ERC1155, ERC721, ERC20 tokens into a single wrapped NFT.
*
* @param wrappedContents The tokens to wrap.
* @param shares The number of shares to issue for the wrapped contents.
* @param uriForShares The URI for the shares i.e. wrapped token.
* @param wrappedContents The tokens to wrap.
* @param uriForWrappedToken The metadata URI for the wrapped NFT.
* @param recipient The recipient of the wrapped NFT.
*/
function wrap(
MultiTokenTransferLib.MultiToken calldata wrappedContents,
uint256 shares,
string calldata uriForShares
Token[] memory wrappedContents,
string calldata uriForWrappedToken,
address recipient
) external payable returns (uint256 tokenId);

/**
* @notice Unwrap shares to retrieve underlying ERC1155, ERC721, ERC20 tokens.
* @notice Unwrap a wrapped NFT to retrieve underlying ERC1155, ERC721, ERC20 tokens.
*
* @param tokenId The token Id of the tokens to unwrap.
* @param amountToRedeem The amount of shares to unwrap
* @param tokenId The token Id of the wrapped NFT to unwrap.
* @param recipient The recipient of the underlying ERC1155, ERC721, ERC20 tokens of the wrapped NFT.
*/
function unwrap(
uint256 tokenId,
uint256 amountToRedeem,
address _sendTo
address recipient
) external;
}

0 comments on commit 9f6ab6d

Please sign in to comment.