ERC-7444 Standard for querying timelock maturity (Time Locks Maturity)

Draft · Vaults & DeFi · created 2023-06-05

Defines a common query function that reports when assets locked by a timelock will be released. Any locked asset can have its maturity read the same way and used for valuation.

Why it is needed

Timelocks that lock up assets for a period of time are common throughout Ethereum, but there has been no common way to determine when such a lock will be released. The value of a locked asset changes depending on the time remaining until release. This property, where value changes over time, is called theta decay. However, because each project stores and displays maturity differently, it has been difficult to automatically calculate the value of locked assets on-chain. This is especially true when rights to a locked asset can be transferred to others in the form of a token such as an NFT (ERC-721, ERC-1155), where both buyer and seller need to be able to easily check maturity information in order to price it correctly. This standard solves the problem by unifying a single function that returns the maturity timestamp.

What to implement

In depth

getMaturity function specification

The single function getMaturity(bytes32 id) is the core of this standard. id is an identifier referring to a specific timelock, and the return value maturity is the time at which that timelock is unlocked. It is a view function, so it only queries state without changing it. The return value must be implemented in the widely used Solidity Unix timestamp format, and the source gives block.timestamp as an example, which represents the Unix timestamp at which a block was mined as a 256-bit value.

ERC-165 Interface Detection Required

Every contract that follows ERC-7444 must implement ERC-165 interface detection. ERC-165 is a standard that lets a contract be queried in advance for whether it supports a particular interface. This lets a wallet or app check whether a contract supports getMaturity queries before calling it.

Handling the id Parameter in Singleton Implementations for Fungible Assets

If a single contract is a singleton implementation that manages one time lock for an entire class of fungible assets, it SHOULD ignore the value passed as id. Querying such an implementation should be done by calling with 0x0 for id, since there is only one lock rather than multiple, so there is no need to distinguish identifiers.

Why Maturity Information Is Used in Valuation

A locked asset's value changes over the lock period depending on time and various factors, making it hard to value using ordinary methods. The source text cites the Black-Scholes Model as an example of a model that estimates an asset's theoretical value by accounting for the effect of time and risk. In this model, time to maturity is a core variable in the price calculation. This is why being able to read maturity data through a common interface is the rationale for this standard. It explains that the need for such a unified interface has grown as locked assets are used across many areas of DeFi, such as yield farming and vesting escrows.

Compatibility with existing token standards

This standard can be implemented as an extension of an ERC-721 or ERC-1155 token that has time lock functionality. The source text explains that even an already deployed token can be retrofitted by attaching a separate designated contract that reports when the time lock unlocks.

Reference Implementation: Locked ERC-20 Example

The source text shows an example contract that locks ERC-20 tokens. Depositing tokens via deposit(amount, lockingPeriod) sets the maturity by adding the lock period to block.timestamp, and uses a hash of the depositor's address, amount, and maturity combined as the lockId. The lock information is stored in a TimeLock struct (owner, amount, maturity, lockId). withdraw(lockId) can only be called by the lock's owner, and after checking the maturity condition, it clears the lock information and returns the tokens. getMaturity(id) simply returns the maturity value of that lock.

Proposal status

This proposal was created on June 5, 2023, and its current status is Draft. Since it is still at the draft stage, its content may change or progress may stall.

Things to watch out for

Original ERC · ← ERCs