Stellar Asset Creation and Trading

0
17

In this blog post I am going to explain what is stellar asset and how the trading process happening in the backend.

If you are new to stellar or want to know how stellar architecture and behind the scenes check this blog.

Asset

The Stellar distributed network can be used to track, hold, and transfer any type of asset: dollars, euros, bitcoin, stocks, gold, and other tokens of value. Any asset on the network can be traded and exchanged with any other.

assets are the representation of the real-world objects. We can represent 10 apples using 10 apple assets.
We can convert all these into assets

Each asset in stellar will have one asset code that is either alphanumeric 4 or alphanumeric 12 and an issuer account. any account can issue assets in stellar. the accounts that are issuing assets are called anchors. Anchors can be run by individuals, small businesses, local communities, nonprofits, organizations, etc. Any type of financial institution–a bank, a payment processor–can be an anchor. anchors can control the assets by authorization required and each anchor can produce unlimited assets and unlimited quantity of assets as well.

Trustline

once we want to buy an asset first we need to trust that asset. the trusting part is not controlled by stellar. for an example if bob having 100 apple asset and Alice want to buy 20. and when Alice return that 20 in real world to bob he will give 20 apples to Alice. in stellar we can trust how many apple assets left in bob’s account, but we can’t trust blindly that bob will have apples in real world. (Sometimes he even doesn’t have an apple tree :) but having only apple assets). So, to make sure that Alice trust that bob will have apples in real word we need to create the trust-line.

trust-line will confirm that you trust the asset and then only you can buy the asset from bob. Also, the buying and trading the assets will not directly link with anchors all the time. for a case once, Alice bought 20 apple assets and the she can sell 10 apple assets to john. so, hear john not buying from anchor but before buying he need to trust bob and need to create a trust-line with bobs apple asset. one can sell/buy the asset using XLM or can trade the asset with another asset that he holds.

Asset Trading

asset trading in stellar is more secure process as its storing the trading and trading requests in the ledger itself. In addition to supporting the issuing and movement of assets, the Stellar network also acts as a decentralized distributed exchange (DEX) of any type of asset that people have added to the network. Its ledger stores both balances held by user accounts and offers that user accounts make to buy or sell assets.

as mentioned earlier there are two ways to sell/buy an asset. once is directly buy and sell with another account or else create an offer to sell/buy and trade the asset. any account that holds the asset can create offers to sell and any account can create buy offer that already trust the buying asset issuer. once the offer created it will be stored in order-book in stellar. when creating the offer user can mentioned what ration he needs to sell or buy. for an example sell 1 apple and buy 2 oranges (1:2). the offer will be invalid or canceled in situations where the offer created account cancel the offer, the account no longer holds enough asset, the offer matched and already traded or offer matched and taken by the path payment.

Exchange meat for fish

An orderbook is a record of outstanding orders on the Stellar network. This record sits between any two assets. for an example Alice holding only milk and wants to buy apple. So, when she creates an offer to sell milk and buy apple that will check whether there is any orderbook already there, if not it will create a new book and record this offer there.

order book will have two sides for each combination of assets. in our case one side will hold all the offers that made for sell apple and buy milk and other side will hold the offers about sell milk and buy apple. Orderbook entries will hold the ration that each account wants to sell or buy.

when a new offer created stellar will automatically check the orderbook and will match with the best offer there. for example, if I am creating an offer to sell apple and buy milk for 2:1 ratio and in the order book already 2 accounts like to sell milk and buy apples, but one accounts ratio is 1 milk for 3 apples (1:3) and another ratio is (1:1). so, in this case stellar will check and matched my offer with second account which holds the offer for 1:1. Stellar always match the offer with same ratio or lesser than that. it will not match the offer that greater than the one user created. If the offer is not matched stellar will store that offer as an entry in the order book for future trades.

Cross asset payment

Any accounts can create a payment using asset. for an example Alice holding apple and wants to buy cake. but the once who okay to sell the cake want the milk and don’t want the apple. in this case Alice will create a cross payment where stellar will find and offer in order book that convert apple to milk first and then milk to cake. apple->milk->cake. in hear Alice no need to trust the milk but only need to trust the cake. and other account who sell cake no need to trust apple. while creating the cross-payment user can mentioned which account it wants to use to convert the asset or else can leave that part to stellar. stellar will automatically match the best ration to convert apple to milk and milk to cake and then Alice will receive cake and other party will get milk. can put maximum 6 hops in between 2 assets. (apple->milk->cheese->orange->chocolate->mango->cake). Below image showing how to transfer USD to EUR using cross payment.

Conclusion

stellar assets are more secure as they were straightaway storing in the ledger. Also, its storing the offers in the ledger as well. this process can be useful while making cross border currency transfer or trade. because we can find the best conversion rate in the stellar network. and get the best match. also, it can be used to verify the trust between two accounts to transfer things offline. And can use this trustline to verify the user authorization as well.

I hope this article will help people who wants to understand stellar asset and trading process. Looking forward your feedback’s and comments :).

Get Best Software Deals Directly In Your Inbox

Stellar Asset Creation and Trading was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.