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

Add ERC: ERC-721 Guarantee Extension #306

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
657646a
Add files via upload
iunknow588 Mar 10, 2024
3feb978
Add files via upload
iunknow588 Mar 10, 2024
2bc7360
Add files via upload
iunknow588 Mar 10, 2024
cfe5d41
Merge branch 'ethereum:master' into master
iunknow588 Mar 20, 2024
68288dc
798->7652
iunknow588 Mar 20, 2024
fd93869
Update erc-7652.md
iunknow588 Mar 20, 2024
2f9fb90
Delete ERCS/erc-798.md
iunknow588 Mar 20, 2024
4c89956
Update erc-7652.md
iunknow588 Mar 20, 2024
f5159e7
Update erc-7652.md
iunknow588 Mar 20, 2024
0c49349
Update erc-7652.md
iunknow588 Mar 20, 2024
2b955cb
Merge branch 'ethereum:master' into master
iunknow588 Mar 21, 2024
9f279bb
Update erc-7652.md
iunknow588 Mar 21, 2024
1327350
Update erc-7652.md
iunknow588 Mar 21, 2024
18d9907
Update erc-7652.md
iunknow588 Mar 21, 2024
b0ea81c
Update erc-7652.md
iunknow588 Mar 21, 2024
e456a95
Create ERC721Guaranteeable.sol
iunknow588 Mar 21, 2024
0d5d6a5
Create GuarantedNFT.sol
iunknow588 Mar 21, 2024
b7df251
Create IterfaceDaoInfo.sol
iunknow588 Mar 21, 2024
5eae255
Create IEIP721Guarantee.sol
iunknow588 Mar 21, 2024
e952311
Create IERC798Errors.sol
iunknow588 Mar 21, 2024
f06979d
Add files via upload
iunknow588 Mar 21, 2024
1a4a4fe
Create DaoInfo.sol
iunknow588 Mar 21, 2024
9b70266
Add files via upload
iunknow588 Mar 21, 2024
8966a14
Create FaiDivision.sol
iunknow588 Mar 21, 2024
353b86a
Add files via upload
iunknow588 Mar 21, 2024
ebcb36b
Delete assets/erc-7652/Base directory
iunknow588 Mar 21, 2024
802dea3
Create IEIP721Guarantee.sol
iunknow588 Mar 21, 2024
76fc67f
Add files via upload
iunknow588 Mar 21, 2024
78f436f
Add files via upload
iunknow588 Mar 21, 2024
d5aa84a
Update erc-7652.md
iunknow588 Mar 21, 2024
74d1380
Merge branch 'ethereum:master' into master
iunknow588 Mar 21, 2024
7e267fd
Merge branch 'ethereum:master' into master
iunknow588 Mar 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
160 changes: 160 additions & 0 deletions ERCS/erc-7652.md
@@ -0,0 +1,160 @@
---
eip: 7652
title: ERC-721 Guarantee Extension
description: ERC-721 Guarantor interface
author: LiuC.Dao (@CDao) <iunknow@163.com>, Sam <1047180870@qq.com>
discussions-to: https://ethereum-magicians.org/t/erc-7652-eip-721-guarantee-extension/19284
status: Draft
type: Standards Track
category: ERC
created: 2024-03-10
requires: 165, 721
---

## Abstract

This specification defines functions outlining a guarantor role for instance of [EIP-721](./eip-721.md). The guarantee interface implements the user-set valuation and guarantee share for a given NFT (token ID), as well as the guarantee rights enjoyed and obligations assumed during subsequent transactions. An implementation enables the user to read or set the current guarantee value for a given NFT (token ID), and also realizes the distribution of guarantee interest and the performance of guarantee obligations. It sends the standardized events when the status changes. This proposal relies on and extends the existing [EIP-721](./eip-721.md).

## Motivation

NFT (token ID) commonly face the issue of insufficient market liquidity: the main reason being the lack of transparency in NFT pricing, making it difficult for users to cash out after trading and purchasing NFT (token ID).

With the introduction of the guarantor role, different guarantor groups can offer various price guarantees for NFT (token ID), establishing a multi-faceted price evaluation system for NFT (token ID).

After purchasing an NFT (token ID), users can return it to the guarantor at any time at the highest guaranteed price to protect their interests.

Additionally, after fulfilling their guarantee obligations, the guarantor can also request subsequent guarantors to provide guarantee obligations.

When an NFT (token ID) is owned by the guarantor, and since the guarantor can be a DAO organization, this expansion allows the NFT (token ID) to continue operating as a DAO, thus further enhancing the social or community recognition of the NFT (token ID).


## Specification

The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

Every contract compliant to the `EIP721Guarantee` MUST implement the `IEIP721Guarantee` guarantee interface.

The **guarantee extension** is OPTIONAL for EIP-721 contracts.

```solidity
pragma solidity ^0.8.20;

// import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

/// @title EIP-721 Guarantor Role extension
/// Note: the EIP-165 identifier for this interface is


interface IEIP721Guarantee /*is IERC721*/{
/// @notice Emitted when `guarantee contract` is established for an NFT
/// @param user address of guarantor
/// @param value The guarantee value provided by dao
/// @param DAO DAO organization providing guarantee
/// @param tokenId Guaranteed NFT (token ID),
event GuaranteeIsEstablshed(
address user,
uint256 value,
address DAO,
uint256 indexed tokenId
);

/// @notice Emitted when `guarantee contract` is canceled
/// @dev Some users in the closed DAO request a reduction in their guarantee share
/// @param user address of guarantor
/// @param value The guarantee value provided by dao
/// @param DAO DAO organization providing guarantee
/// @param tokenId Guaranteed NFT (token ID),
event GuaranteeIsCancel(
address user,
uint256 value,
address DAO,
uint256 indexed tokenId
);

/// @notice Emitted when `Guarantee sequence` is established for an NFT
/// @param userGuaranteed address of guaranteed
/// @param number block.number of transaction,
/// and all DAOs established before this point will enter the guarantee sequence
/// @param DAOs DAO sequence providing guarantee
/// @param tokenId Guaranteed NFT (token ID),
event GuaranteeSequenceIsEstablshed(
address userGuaranteed,
uint256 number,
address DAOs,
uint256 indexed tokenId
);

/// @notice A user's evaluation for an NFT (token ID)
/// @dev Set the guarantee information for one guarantor,
/// Throws if `_tokenId` is not a valid NFT
/// @param value user's evaluation for an NFT, the oledr value is canceled,
/// @param user address of guarantor
/// @param weight guarantee weight for guarantor
/// @param tokenId The NFT
/// @return the error status of function execution
function setNFTGuarantedInfo(
uint256 value,
address user,
uint256 weight,
uint256 tokenId
) external returns (uint256);

/// @notice Establish guarantee sequence for an NFT (token ID) and split the commission
/// @dev Each NFT(token ID) retains a current guarantee sequence,
/// and expired guarantee sequences are no longer valid,
/// Throws if `_tokenId` is not a valid NFT
/// @param valueCommission Commission for a transactions
/// @param userGuaranteed address of guaranteed
/// @param number block.number of transaction,
/// and all DAOs established before this point will enter the guarantee sequence
/// @param tokenId The NFT
/// @return the error status of function execution
function establishNFTGuarantee(
uint256 valueCommission,
address userGuaranteed,
uint256 number,
uint256 tokenId
) external returns (uint256);

/// @notice Transactions that fulfill the guarantee responsibility
/// @dev The new accountability transaction also requires
/// the construction of a new guarantee sequence
/// Throws if `_tokenId` is not a valid NFT or userGuaranteed is not right

/// @param userGuaranteed address of guaranteed
/// @param tokenId The NFT
/// @return the error status of function execution
function FulfillGuaranteeTransfer(address userGuaranteed, uint256 tokenId)
external
returns (uint256);
}

```

## Rationale

Key factors influencing the standard:

- Pay attention to ensuring fairness between and within groups when allocating commissions
- Keeping the number of guarantee groups (DAOs)in the interfaces to prevent contract bloat
- The guarantee group is a DAO contract, which MUST implement the `ERC721TokenReceiver` interface
- Simplicity
- Gas Efficiency


## Backwards Compatibility

This standard is compatible with current EIP-721 standards. There are no other standards that define a similar role for NFTs and the name (Guarantor) is not used by other EIP-721 related standards.


## Reference Implementation

The reference implementation can be found [here](../assets/eip-7652/contracts/ERC721Guaranteeable.sol).

## Security Considerations

Needs discussion.

## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).
1 change: 1 addition & 0 deletions assets/erc-7652/README.md
@@ -0,0 +1 @@
ERC-721 Guarantee Extension
93 changes: 93 additions & 0 deletions assets/erc-7652/contracts/Base/IEIP721Guarantee.sol
@@ -0,0 +1,93 @@
// SPDX-License-Identifier: Apache License 2.0

pragma solidity ^0.8.20;

// import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

/// @title EIP-721 Guarantor Role extension
/// Note: the EIP-165 identifier for this interface is


interface IEIP721Guarantee /*is IERC721*/{
/// @notice Emitted when `guarantee contract` is established for an NFT
/// @param user address of guarantor
/// @param value The guarantee value provided by dao
/// @param DAO DAO organization providing guarantee
/// @param tokenId Guaranteed NFT (token ID),
event GuaranteeIsEstablshed(
address user,
uint256 value,
address DAO,
uint256 indexed tokenId
);

/// @notice Emitted when `guarantee contract` is canceled
/// @dev Some users in the closed DAO request a reduction in their guarantee share
/// @param user address of guarantor
/// @param value The guarantee value provided by dao
/// @param DAO DAO organization providing guarantee
/// @param tokenId Guaranteed NFT (token ID),
event GuaranteeIsCancel(
address user,
uint256 value,
address DAO,
uint256 indexed tokenId
);

/// @notice Emitted when `Guarantee sequence` is established for an NFT
/// @param userGuaranteed address of guaranteed
/// @param number block.number of transaction,
/// and all DAOs established before this point will enter the guarantee sequence
/// @param DAOs DAO sequence providing guarantee
/// @param tokenId Guaranteed NFT (token ID),
event GuaranteeSequenceIsEstablshed(
address userGuaranteed,
uint256 number,
address DAOs,
uint256 indexed tokenId
);

/// @notice A user's evaluation for an NFT (token ID)
/// @dev Set the guarantee information for one guarantor,
/// Throws if `_tokenId` is not a valid NFT
/// @param value user's evaluation for an NFT, the oledr value is canceled,
/// @param user address of guarantor
/// @param weight guarantee weight for guarantor
/// @param tokenId The NFT
/// @return the error status of function execution
function setNFTGuarantedInfo(
uint256 value,
address user,
uint256 weight,
uint256 tokenId
) external returns (uint256);

/// @notice Establish guarantee sequence for an NFT (token ID) and split the commission
/// @dev Each NFT(token ID) retains a current guarantee sequence,
/// and expired guarantee sequences are no longer valid,
/// Throws if `_tokenId` is not a valid NFT
/// @param valueCommission Commission for a transactions
/// @param userGuaranteed address of guaranteed
/// @param number block.number of transaction,
/// and all DAOs established before this point will enter the guarantee sequence
/// @param tokenId The NFT
/// @return the error status of function execution
function establishNFTGuarantee(
uint256 valueCommission,
address userGuaranteed,
uint256 number,
uint256 tokenId
) external returns (uint256);

/// @notice Transactions that fulfill the guarantee responsibility
/// @dev The new accountability transaction also requires
/// the construction of a new guarantee sequence
/// Throws if `_tokenId` is not a valid NFT or userGuaranteed is not right

/// @param userGuaranteed address of guaranteed
/// @param tokenId The NFT
/// @return the error status of function execution
function FulfillGuaranteeTransfer(address userGuaranteed, uint256 tokenId)
external
returns (uint256);
}
34 changes: 34 additions & 0 deletions assets/erc-7652/contracts/Base/IERC798Errors.sol
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache License 2.0

pragma solidity ^0.8.20;

/**
* @dev Standard ERC798 Errors
*/


// 定义枚举类型 DAO_STATE
enum IEC798_DAO_RETURN_VALUE {
SUCCESS, // 成功
SUC_DAO_CLOSE, //成功执行且DAO已经关闭
ERR_, // 保证状态
ERR_PROCESS // 投票状态
}


interface IERC798Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC798InvalidOwner(address owner);

/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC798NonexistentToken(uint256 tokenId);


}
44 changes: 44 additions & 0 deletions assets/erc-7652/contracts/Base/IterfaceDaoInfo.sol
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: Apache License 2.0

pragma solidity ^0.8.20;

//import {IERC721Receiver} from "./IERC721Receiver.sol";

import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

// 定义枚举类型 DAO_STATE
enum DAO_STATE {
Hold, // 持有状态
Split, // 分裂状态
Guaranteed, // 保证状态
Vote // 投票状态
}

/*
一个用户的组织也DAO,方便转让部分权重,
*/

interface IterfaceDaoInfo {

/// @notice DAO筹资完成,达到目标值
/// @param DaoAdd address of DAO
/// @param objValue objValue organization providing guarantee
event DaoFundraisingEnd(address DaoAdd,uint256 objValue);

//一旦基金关闭,份额只能向第三人整体转让,不能退出;
function setInfo(address addr, uint256 weight)
external
returns (uint256 errInfo);

//一旦基金关闭,份额只能向第三人整体转让,不能退出;
// 关闭前也可以转让;
function transferWeight(
address from,
address to,
uint256 weight
) external returns (uint256 errInfo);

function resetDivision(uint256 shareValue)
external
returns (uint256 errInfo);
}