pragma solidity ^0.8.20;
/**
* @dev The settings of the agency.
* @param currency The address of the currency. If `currency` is 0, the currency is Ether.
* @param basePremium The base premium of the currency.
* @param feeRecipient The address of the fee recipient.
* @param mintFeePercent The fee of minting.
* @param burnFeePercent The fee of burning.
*/
struct Asset {
address currency;
uint256 basePremium;
address feeRecipient;
uint16 mintFeePercent;
uint16 burnFeePercent;
}
interface IERC7527Agency {
/**
* @dev Allows the account to receive Ether
*
* Accounts MUST implement a `receive` function.
*
* Accounts MAY perform arbitrary logic to restrict conditions
* under which Ether can be received.
*/
receive() external payable;
/**
* @dev Emitted when `tokenId` token is wrapped.
* @param to The address of the recipient of the newly created non-fungible token.
* @param tokenId The identifier of the newly created non-fungible token.
* @param premium The premium of wrapping.
* @param fee The fee of wrapping.
*/
event Wrap(address indexed to, uint256 indexed tokenId, uint256 premium, uint256 fee);
/**
* @dev Emitted when `tokenId` token is unwrapped.
* @param to The address of the recipient of the currency.
* @param tokenId The identifier of the non-fungible token to unwrap.
* @param premium The premium of unwrapping.
* @param fee The fee of unwrapping.
*/
event Unwrap(address indexed to, uint256 indexed tokenId, uint256 premium, uint256 fee);
/**
* @dev Constructor of the instance contract.
*/
function iconstructor() external;
/**
* @dev Wrap some amount of currency into a non-fungible token.
* @param to The address of the recipient of the newly created non-fungible token.
* @param data The data to encode into ifself and the newly created non-fungible token.
* @return The identifier of the newly created non-fungible token.
*/
function wrap(address to, bytes calldata data) external payable returns (uint256);
/**
* @dev Unwrap a non-fungible token into some amount of currency.
*
* Todo: event
*
* @param to The address of the recipient of the currency.
* @param tokenId The identifier of the non-fungible token to unwrap.
* @param data The data to encode into ifself and the non-fungible token with identifier `tokenId`.
*/
function unwrap(address to, uint256 tokenId, bytes calldata data) external payable;
/**
* @dev Returns the strategy of the agency.
* @return app The address of the app.
* @return asset The asset of the agency.
* @return attributeData The attributeData of the agency.
*/
function getStrategy() external view returns (address app, Asset memory asset, bytes memory attributeData);
/**
* @dev Returns the premium and fee of wrapping.
* @param data The data to encode to calculate the premium and fee of wrapping.
* @return premium The premium of wrapping.
* @return fee The fee of wrapping.
*/
function getWrapOracle(bytes memory data) external view returns (uint256 premium, uint256 fee);
/**
* @dev Returns the premium and fee of unwrapping.
* @param data The data to encode to calculate the premium and fee of unwrapping.
* @return premium The premium of wrapping.
* @return fee The fee of wrapping.
*/
function getUnwrapOracle(bytes memory data) external view returns (uint256 premium, uint256 fee);
/**
* @dev OPTIONAL - This method can be used to improve usability and clarity of Agency, but interfaces and other contracts MUST NOT expect these values to be present.
* @return the description of the agency, such as how `getWrapOracle()` and `getUnwrapOracle()` are calculated.
*/
function description() external view returns (string memory);
}
App 接口
ERC7527App 应该从接口 ERC721Metadata 继承 name。
pragma solidity ^0.8.20;
interface IERC7527App {
/**
* @dev Returns the maximum supply of the non-fungible token.
*/
function getMaxSupply() external view returns (uint256);
/**
* @dev Returns the name of the non-fungible token with identifier `id`.
* @param id The identifier of the non-fungible token.
*/
function getName(uint256 id) external view returns (string memory);
/**
* @dev Returns the agency of the non-fungible token.
*/
function getAgency() external view returns (address payable);
/**
* @dev Constructor of the instance contract.
*/
function iconstructor() external;
/**
* @dev Sets the agency of the non-fungible token.
* @param agency The agency of the non-fungible token.
*/
function setAgency(address payable agency) external;
/**
* @dev Mints a non-fungible token to `to`.
* @param to The address of the recipient of the newly created non-fungible token.
* @param data The data to encode into the newly created non-fungible token.
*/
function mint(address to, bytes calldata data) external returns (uint256);
/**
* @dev Burns a non-fungible token with identifier `tokenId`.
* @param tokenId The identifier of the non-fungible token to burn.
* @param data The data to encode into the non-fungible token with identifier `tokenId`.
*/
function burn(uint256 tokenId, bytes calldata data) external;
}
Token ID 可以在 mint 函数的 data 参数中指定。
Factory 接口
可选 - 此接口可用于部署 App 和 Agency,但接口和其他合约不应期望存在此接口。
如果需要工厂来部署绑定的 App 和 Agency,则工厂应该实现以下接口:
pragma solidity ^0.8.20;
import {Asset} from "./IERC7527Agency.sol";
/**
* @dev The settings of the agency.
* @param implementation The address of the agency implementation.
* @param asset The parameter of asset of the agency.
* @param immutableData The immutable data are stored in the code region of the created proxy contract of agencyImplementation.
* @param initData If init data is not empty, calls proxy contract of agencyImplementation with this data.
*/
struct AgencySettings {
address payable implementation;
Asset asset;
bytes immutableData;
bytes initData;
}
/**
* @dev The settings of the app.
* @param implementation The address of the app implementation.
* @param immutableData The immutable data are stored in the code region of the created proxy contract of appImplementation.
* @param initData If init data is not empty, calls proxy contract of appImplementation with this data.
*/
struct AppSettings {
address implementation;
bytes immutableData;
bytes initData;
}
interface IERC7527Factory {
/**
* @dev Deploys a new agency and app clone and initializes both.
* @param agencySettings The settings of the agency.
* @param appSettings The settings of the app.
* @param data The data is additional data, it has no specified format and it is sent in call to `factory`.
* @return appInstance The address of the created proxy contract of appImplementation.
* @return agencyInstance The address of the created proxy contract of agencyImplementation.
*/
function deployWrap(AgencySettings calldata agencySettings, AppSettings calldata appSettings, bytes calldata data)
external
returns (address, address);
}