SDEX NFT Diagram

NFT on Stellar – Solution to Pricing Limitations on the SDEX

This post summarizes the issue previously discussed on Keybase #dev-discussion team and explains in details the solution we use for the upcoming NFT marketplace.

Issuing Indivisible Tokens on Stellar

The smallest amount for an asset issued on Stellar is called a stroop and is equal to one ten-millionth or 0.0000001. Therefore, we can issue 1 stroop of an asset to ensure that it is indivisible (e.g. as part of the requirements for NFTs).

Stellar DEX Price Limit

However, such small amounts may cause issues on the Stellar DEX because Core internally uses INT32 for the fractional representation of prices and the INT32 type can only store values between -2,147,483,648 to 2,147,483,647 (inclusive).

That is, the maximum price for an offer on the SDEX is 2,147,483,647 so when you are selling 1 stroop of an asset, the offer price goes out of bound if the amount of the quote asset is over 214.7 (2147483647 x 0.0000001 ≈ 214.7).

For example, if you are trading NFT/USD, the maximum amount of USD you can get is 214.7 (i.e. selling at a price of 214.7 / 0.0000001), if you are trading NFT/XLM, the maximum amount of XLM will be 214.7 XLM and so on.

Therefore, this limitation may be an issue for many trading pairs.

Path Payments

Stellar provides a powerful feature called Path Payment. Path payments are used for cross-currency payments through SDEX offers. Since the source and destination of path payments can be the same, it is an extremely versatile tool (although some have abused the feature on the SDEX, leading to the Surge Pricing implementation).

For example, Stellarport uses Path Payments to implement Market Orders since Path Payments can guarantee the amount being traded either way with strict-receive or strict-send. Litemint uses it to implement in-app purchases in game shops so we can offer cross-currency payments as well as decentralized price discovery.

The NFT marketplace is also leveraging path payments to circumvent the limitation discussed in this post and to allow sellers and buyers to choose their payment currency independently.

Solution

By self-issuing a quote asset, we can fully control the ask price for an NFT. This method can also be used to hedge against volatility as shown in the diagram below.

The intermediate account sets the Authorization Required flag to prevent anyone (but the NFT owner) from acquiring the asset. Although, such listings could be hit partially by spam executions (sending HDG to the NFT seller), these spam transactions are always more costly to the spammer than the NFT seller. A free workaround is simply to issue double the amount of the hedging asset (e.g. 2 HDG @ 300USD) so the NFT offer liquidity is not affected and with generous spammers, we could even grab our ask price without having to sell our NFT! 🙂

We also set the signer to the NFT seller account to ensure ownership for the NFT seller during the selling process. At any time the seller can change the price for the offer.

After the offer execution, the payment can be sent to the NFT owner (as mentioned ownership is already guaranteed so this is seamless and decentralized) and the intermediate account is simply merged to the NFT owner account so the reserves can be recovered.

From the seller and buyer viewpoint the setup is fully transparent leaving the seller free to choose any selling price without having to worry about the SDEX limitations.

Any questions or comment, feel free to let me know.

Make sure you follow us on our social channels to keep posted about our latest news:

Website: https://litemint.com/
Github: https://github.com/litemint
Twitter: https://twitter.com/LitemintHQ
Facebook: https://www.facebook.com/litemint
Youtube: https://www.youtube.com/channel/UC4d-ENpghypzHBB-N7hLN2w
Web App: https://litemint.app/
Google Play: https://play.google.com/store/apps/details?id=com.litemint.app
App Store: https://apps.apple.com/app/litemint/id1454801150
Discord: litemint.gg
Reddit: https://www.reddit.com/user/blockonomy

Thanks for reading.