The Opium team was motivated by the real financial markets to create a token standard that can represent financial instruments that are traded on exchanges. An exchange-traded product is a standardised financial instrument that is traded on an organized exchange. Therefore, such products are interchangeable with the same standardised products. Standardisation of products means setting parameters such as price source, maturity, quantity, documentation and regulation. For example, two future contracts on gold with the same standardised parameters are absolutely the same, but they are different from similar futures for oil. They are also different from futures contracts on gold that have a different maturity.
We have created the standard that allows to have all kind of different non-interchangeable tokens like ERC-721, but each can be minted in any quantity, being interchangeable with its "twins".
The ERC-721o token standard is a combination of the ERC-20 and ERC-721 token standards with extra functionalities. It allows for batch trading (and thus optimizing gas usage) and creating portfolios in a native way. In financial markets, instruments can be the same and interchangeable with each other, but there are many types of different instruments. Different by maturity, underlying or standard conventions. Our inspiration to develop this token standard comes from the real financial markets, where often positions are traded in large sizes and portfolios are used to take multiple positions at once, without having the risk of 1 leg of the portfolio not being executed (see examples below). At the same time, ERC-721o tokens are backwards compatible with the ERC-721 token standard and thus can be traded in existing ecosystems where, for example, relayers use the 0x protocol.
Financial instruments most of the times are combined and managed as portfolios. This motivates us to create a possibility to wrap several tokens into a portfolio that is represented by one token. Once a portfolio is created, it is stored on the owner's balance and corresponding tokens are deleted from the blockchain.
We introduce three portfolio functions:
Once composed, the whole portfolio can be managed or traded as one token, saving gas and implementing convenient financial logic.
When the portfolio decompose function is used, the tokens that were used to compose the portfolio are minted again and stored on the owners' balance.
We can get the ID of a portfolio token through a simple cryptographic wrap hash function:
Another function of the ERC-721o standard is recomposing. New position tokens can be added to the existing portfolio token, but position tokens can also be taken out from the portfolio token. This function works in a gas efficient way and allows to add/take tokens with one transaction.
Minting and burning of Opium derivative tokens is done only on order of the Opium core contract and therefore are always backed by the necessary margin in the network.
Owners can interact with the Opium minting contract by managing their positions within sending, composing and recomposing requests, but can not directly request minting or burning of a token. To mint or burn a token, users should send enough margin to the corresponsing derivative recipe or execute and withdraw an existing position after maturity.
Besides the newly introduced portfolio functions, we inherite several functions from the ERC721x token standard: