Trading Options with Metaplex Core

May 10 2024



In our last post we introduced Metaplex core - a new standard for creating NFTs that is far cheaper and more flexible than the previous SPL standard. We now use Core to do something more interesting than just creating standard NFTs - we are going to use it to power an options trading platform.

This won't be a technical post, we are just going to summarise how we are using core to drive the backend of the program. In the near future Core are going to enable user created plugins for assets that include hooks for lifecycle events like transfers and burns. When that happens we will update the program here and write a more technical post that goes though those new features and allows users to execute their options simply by burning them.

You'll find the app below, just enter a token mint address that exists on devnet (for example, BJLX7W73vmUu83uYNW6YLxXwKG5Li4F76pFegHDFGMfb, which you can buy from Lets Cook on devnet here) and you'll be able to create, trade and execute options with that token as an underlying asset.

Option Info:

Token:
Name:
Symbol:

Create

Trade

Execute

Refund

Using Collections


Whenever someone creates the first option for a particular token, the program will create the collection automatically. The collection is used to group all the options for that token, so that front ends can simply retrieve all the assets in that collection to display all the options that currently exist (this is exactly what the app does above). As an example you can check out this one. The core explorer shows all the members of the collection, and the attributes metadata for the collection tells you the token mint address that will be the underlying for the collection.

Options as Core Assets


Ultimately core assets are just accounts on chain that can contain arbitrary data, where the standard makes it easy to interact with those accounts, transferring ownership between users, or updating the data. When you create an option is uses the core standard to store all of the details for the option in the attributes plugin for the asset. This means that the program can access and update that metadata on chain. Below you'll see the metadata we store for each option. This includes things like the side (Call or Put), the strike price, the creator and so on. When you relist an option that you bought previously the program will just update the fields for the option price and the seller, and this will be displayed in any explorer that supports core assets.

Attributes

When creating an option either the tokens (if it is a call option) or the SOL (if it is a put option) are transferred to an escrow account owned by the program. The program is also given both burn and transfer delegate status on the asset, so that the original creator is able to reclaim it, and the value in the escrow account, after it has expired.

Final Comments

Using the Core standard as a way to package up data that you want to be easily viewed in explorers that will work out of the box with wallets is an exciting prospect. Although not all wallets and explorers support the standard fully just yet, i'm hopeful it will only be a matter of time. When user created plugins are available that can act in a similar way to the token-2022 transfer hook, but on any life cycle event, that will open up even more oppertunities. I looked forward to updating this program using the on-burn hook, so that owners of an option just need to burn it in their wallet to be able to execute (or refund) the option without needing to go via any other interface.

If you've learnt something new or found this post useful, go ahead and follow us on X to keep up to date with future posts!