ERC-7595 Collateralized NFT
Draft · NFTs & multi-token · created 2023-03-13
An extension standard that lets ERC-20 tokens or native coins be held as collateral inside an ERC-721 NFT, which the NFT owner can withdraw. It enables the NFT's minimum value to be verified on-chain.
Why it is needed
Services that lend money against NFT collateral typically value the NFT based on the collection's floor price, the lowest price at which it is currently being sold in the market. However, floor prices fluctuate widely based on supply and demand in the NFT market and are more volatile than the crypto market as a whole. In certain collections, price manipulation can artificially inflate prices, distorting even the floor prices that lending services rely on. Ultimately, valuing NFTs based solely on market price is unpredictable and unreliable. This standard places actual tokens as collateral inside the NFT and lets anyone verify that balance on-chain, giving the NFT a verifiable minimum value independent of market sentiment. It also proposes royalties backed by the collateral asset and additional revenue streams for creators.
What to implement
event Collateralized(uint256 indexed tokenId, uint256 amount, address tokenAddress);: Notifies when collateral comes in for a specific tokenId, including the token address and amount.event Uncollateralized(uint256 indexed tokenId, uint256 amount, address tokenAddress);: Notifies when collateral is withdrawn from a specific tokenId.event Dispersed(address indexed tokenAddress, uint256 amount);: Notifies when collateral to be distributed across the entire collection has been deposited.event Harvested(address indexed tokenAddress, uint256 amount, uint256 scaledAmount);: Notifies when accumulated fees have been exchanged for the community token and harvested.function commissions(uint256 index) external view returns (uint256);: Returns the fee rate charged on collateral deposit (0) and withdrawal (1). 1000 equals 1%.function blackHole() external view returns (address);: Returns the burn address guaranteed to make sent tokens unrecoverable.function communityToken() external view returns (address);: Returns the community token address used to exchange for accumulated fees.function communityPool(uint256 index) external view returns (address);: Returns the token address at the given index in the list of harvestable tokens.function communityBalance(address tokenAddress) external view returns (uint256);: Returns the harvestable fee balance for that token.function disperseTokens(uint256 index) external view returns (address);: Returns the address at the given index in the list of tokens used for distribution so far.function disperseBalance(address tokenAddress) external view returns (uint256);: Returns the total amount deposited for distribution in that token.function disperseTotalTaken(address tokenAddress) external view returns (uint256);: Returns the total amount already claimed from the distribution.function disperseTaken(uint256 tokenId, address tokenAddress) external view returns (uint256);: Returns the amount a specific tokenId has already claimed from the distribution.function collateralTokens(uint256 tokenId, uint256 index) external view returns (address);: Looks up by index the address of a token that has ever been deposited as collateral for that tokenId.function collateralBalances(uint256 tokenId, address tokenAddress) external view returns (uint256);: Returns the collateral balance of a specific token held under that tokenId.function getAmount(uint256 amount, address tokenAddress) external view returns (uint256);: Calculates the harvestable amount when spending the given amount of the community token.function harvest(uint256[] memory amounts, address[] memory tokenAddresses) external;: Pays the community token to receive accumulated fees.function disperse(uint256[] memory amounts, address[] memory tokenAddresses) external payable;: Deposits collateral so it can be distributed across all NFTs in the collection.function totalCollections() external view returns (uint256);: Returns the number of collections registered with EnviousHouse.function collections(uint256 index) external view returns (address);: Looks up a collection address by its registration number.function collectionIds(address collection) external view returns (uint256);: Looks up a registration number by collection address.function specificCollections(address collection) external view returns (bool);: Returns whether the collection conforms to the ERC-721 standard.function setSpecificCollection(address collection) external;: Adds a collection that is not ERC-721 compatible to the exception list.
In depth
Collateral deposit and withdrawal
collateralize(tokenId, amounts, tokenAddresses) takes arrays of token addresses and amounts to deposit multiple ERC-20 tokens as collateral in a single transaction. It is declared payable so it can also receive the native coin. uncollateralize can only be called by the NFT owner and withdraws the collateral. For queries, collateralBalances(tokenId, tokenAddress) returns the token balance held under a tokenId, and collateralTokens(tokenId, index) returns the list of tokens ever deposited as collateral for that tokenId. Fees are defined in the commissions array, where the first element is the deposit fee and the second is the withdrawal fee, with a three-decimal buffer so that 1000 equals 1%.
Native coin represented by the 0x0 address
Every ERC-20 token has its own contract address, but the native coin has no address. This standard uses the null address (0x0000000000000000000000000000000000000000) as the identifier for the native coin when depositing collateral, since the null address cannot collide with a smart contract address.
disperse: distributing collateral across the collection
disperse(amounts, tokenAddresses) deposits collateral at once across every asset in the collection rather than a single NFT. The total collateral amount is deposited into the smart contract, and each user can claim their share when adding or withdrawing collateral for that asset. Query functions include disperseBalance (total amount deposited), disperseTotalTaken (total amount already claimed), disperseTaken (amount claimed per tokenId), and disperseTokens (list of tokens used for distribution).
harvest, communityToken, and blackHole
Each collection can designate a community ERC-20 token (communityToken), which can be paid to exchange for fees accumulated during the collateral deposit and withdrawal process. getAmount(amount, tokenAddress) calculates the harvestable amount based on the amount of community token spent, and harvest performs the actual exchange. Since some ERC-20 implementations prohibit transfers to the null address, the community tokens received during harvesting are sent to the blackHole contract and removed from circulation. blackHole is an address designed so that it cannot send any token out and only allows read operations.
Four presets
The original text presents four presets. The Basic preset evaluates an on-chain verifiable price floor for a specific NFT asset. The Dynamic preset allows the tokenURI to be changed on-chain according to predetermined collateral rules. The Royalty preset lets creators receive royalties on trades between the asset owner and an externally owned account (EOA), as well as on trades with smart contracts. The VRF preset uses Chainlink's Verifiable Random Function (VRF) to distribute collateral among multiple NFT holders.
EnviousHouse for existing collections
For ERC-721 collections that have already been deployed and cannot be redeployed, an abstraction layer smart contract called IEnviousHouse is provided. This contract replicates all the functionality of the standard and provides access to collateral via mappings. Calling registerCollection(collection, token, incoming, outcoming) registers an ERC-721-compatible collection, grants it collateral functionality, and performs an initial minimum distribution to all NFT holders. The fee rate is interpreted as incoming / 1e5 * 100%. Collections that are not ERC-721 compatible can be added to the exception list with setSpecificCollection, and registration status can be queried via totalCollections, collections, and collectionIds. Each function takes the same form as the individual collection standard's function, with an additional collection address argument.
The name Envious
The original text proposes calling NFT collections issued under this standard, or existing ERC-721 collections using the EnviousHouse abstraction layer, Envious.
Still in Draft stage
This proposal is in Draft status, created in March 2023. Since the specification is not finalized, the content may change or progress may stall going forward.
Things to watch out for
- Hidden logic risk similar to ERC-721: This standard may share security concerns similar to ERC-721. One example is that hidden logic can be embedded in functions such as burn, adding resources, or accepting resources.