Things move fast at Komodo Platform. That’s why the Komodo team has decided to release a weekly briefing to cover all of the progress the Dev Team is making.
This series of posts is called the Tech Tuesday Updates. In case you’ve missed a previous edition and want to catch up, you can find all the previous Tech Tuesday updates here.
Decentralized Margin Trading Game Announcement
It's now time to turn the building blocks of Antara Modules into a public game! In week 16 of the Tech Tuesday blockchain developer update, Komodo introduced synthetic positions & prices derived from decentralized trustless oracles that can now determine prices and provide a market feed for publishing on-chain.
The trustless oracles provide the ability to create prices of stocks, forex and other cryptos relative to any supported unit. For instance, the AAPL stock in BTC price or in KMD price can be created synthetically. This price is created using decentralized price fetching and decentralized price validation. A true trustless pricing oracle enforced by network nodes verifying the price feeds so the validation rules are followed.
That's the fintech blockchain component of the game. Other aspects of the game include solutions to other blockchain problems solved by the Antara Framework.
- The mechanism for anti-spamming an Antara Faucet module is applied to stop abusing the broadcasting of liquidation transactions.
- The concept of an autonomous (no controlling entity) "house address" from the Antara Dice module (a simple blockchain betting game chain). This controls the margin trading house’s autonomous account.
The RPC methods for playing this game via API are at the bottom of this article, anyone can create an interface or scripts to play.
Community Crypto Margin Trading Game Built Using Antara Framework
This game utilizes several technologies to create the Antara Prices Module. Users can open long and short leveraged positions against the house for assets, with prices recorded on-chain by the trustless oracle. The assets come from the Antara Tokens module, and prices fetched from the decentralized trustless oracle (DTO) are written into the Antara Oracles data feed module.
The game currently has two user interfaces.
- Komodo core team produces some of the best text user interfaces in blockchain, so we have a text interface naturally
- Tester Tony created GUI with graphs
Bitcoin price from trustless oracle feed showing the 3 prices - mined price, correlated price & 24 hour smoothed price.
Community challenge to create more GUIs.
Take this opportunity if you're a junior GUI developer and want to have an easy entry to exposing yourself as a blockchain GUI Dev, join the discord chat - some instructions are at the bottom of this article for interfacing with the blockchain's RPC calls. There will likely be some more documentation produced from users as they play.
A further note to GUI devs - the CHIPS project offering microtransaction poker gameplay is looking for a community react developer (or other framework) to make an interface more appealing than the "ugly" one used by the dev community.
Table of synthetic positions (closed / rekt) from bitcoin margin trading in testing the game.
Incentivized Testing & Improvement System (Bounties)
The testing of this decentralized trading platform is taking place as a live testnet where bugs and other bounties are awarded through the LABS notary network. Further details are towards the end of this article, following the game description and functions.
Synthetic Bitcoin Margin Trading Markets
A user can open an account on the chain which have synthetic margin trading markets available for:
- BTCUSD, BTC to some other currency pairs
- Forex pairs (USD/OTHER)
- Crypto / BTC pairs
- Stock / USD pairs
A list of 126 tickers available in the game follows:
BTC_USD, BTC_GBP, BTC_EUR, USD_BGN, USD_NZD, USD_ILS, USD_RUB, USD_CAD, USD_PHP,
USD_CHF, USD_AUD, USD_JPY, USD_TRY, USD_HKD, USD_MYR, USD_HRK, USD_CZK, USD_IDR,USD_DKK, USD_NOK, USD_HUF, USD_GBP, USD_MXN, USD_THB, USD_ISK, USD_ZAR, USD_BRL,
USD_SGD, USD_PLN, USD_INR, USD_KRW, USD_RON, USD_CNY, USD_SEK, USD_EUR, KMD_BTC,ETH_BTC, ETH_BTC, LTC_BTC, BNB_BTC, NEO_BTC, LRC_BTC, QTUM_BTC,OMG_BTC, ZRX_BTC,
STRAT_BTC, IOTA_BTC, XVG_BTC, KMD_BTC, EOS_BTC, ZEC_BTC, DASH_BTC, XRP_BTC,
STORJ_BTC, XMR_BTC, BAT_BTC, BTS_BTC, LSK_BTC, ADA_BTC, WAVES_BTC, STEEM_BTC,RVN_BTC, DCR_BTC, XEM_BTC, ICX_BTC, HOT_BTC, ENJ_BTC, AAPL_USD, ADBE_USD,ADSK_USD, AKAM_USD, AMD_USD, AMZN_USD, ATVI_USD, BB_USD, CDW_USD, CRM_USD,CSCO_USD, CYBR_USD, DBX_USD, EA_USD, FB_USD, GDDY_USD, GOOG_USD, GRMN_USD,GSAT_USD, HPQ_USD, IBM_USD, INFY_USD, INTC_USD, INTU_USD, JNPR_USD, MSFT_USD,MSI_USD, MU_USD, MXL_USD, NATI_USD, NCR_USD, NFLX_USD, NTAP_USD, NVDA_USD,ORCL_USD, PANW_USD, PYPL_USD, QCOM_USD, RHT_USD, S_USD, SHOP_USD, SNAP_USD,SPOT_USD, SYMC_USD, SYNA_USD, T_USD, TRIP_USD, TWTR_USD, TXN_USD, VMW_USD,VOD_USD, VRSN_USD, VZ_USD, WDC_USD, XRX_USD, YELP_USD, YNDX_USD, ZEN_USD, BRK.A_USD
A user queries the chain for the on-chain price and the response contains 3 prices per sample:
- Mined (actually received) price
- Correlated price
- Smoothed price
These prices will be explained further at launch.
The overall trading mechanics are similar to other leveraged trading platforms but without a centralized trust. The leveraged trading platform has been written into blockchain enforceent using the Antara Framework. The customized set of blockchain rules are enforced across the network by all participants. The most basic leveraged trading platform rules are:
- When the loss exceeds position size - it can be liquidated.
- Any time the user can close their position to take their non-negative position equity - take profits.
One important difference which is important is that the prices shown have a programmed 24 hour delay - the way the trustless oracle has been programmed for this tech demo uses a smoothed curve for the pricing algorithm and it is smoothed over 24 hours. The users' actual positions takes 24 hours to become effective. Such trading might need some patience to begin. As the technology is refined to incorporate real-time pricing and a heterogenous group of trustless oracle feed seekers, the pricing algorithm can take on more complex forms beyond a demonstration of the fundamental blockchain platform.
Now to accommodate this programmed delay, the position price calculations for this game are set to the maximum price in the 24 hours after the user places their trade for longs and the minimum price in the 24 hours after for shorts.
Global Autonomous Fund Address - The House
All bets placed are against an autonomous fund which is a blockchain consensus rule that the whole network respects mathematically. There is not one single entity in control of this “house” fund. It is autonomous and funded through blockchain rules - from genesis and through the customized set of Antara Framework rules the developer designs.
A global fund address exists for Antara Modules on the chains they are deployed on. A global address provides a pool or house like mechanism. The "house" was first introduced with the Antara Dice module which was deployed on the KMDICE chain. It was the first provably fair & mineable dice game launched in 2018.
Paying Miners For Broadcasting Liquidated Transactions
All position liquidations (rekts) are paying to this autonomous fund's global address. A small % of the rekt payment is disbursed to the wallet broadcasting the valid rekt transaction. The wallet broadcasting this rekt position has to generate the transaction using a proof-of-work mechanism similar to the Antara Faucet module.
An example of a simple "rekt miner" written in python.
The trading game involves speculation - the aim is to be the best speculator. In this game, the speculation comes in three formats:
- Single ticker (bets)
- Multiple ticker (bets)
- Multiple stack (bets)
The word "bets" is used within the discord community colloquially for this game. It is a game that demonstrates the technology to create such a trading platform. The players are likely to be non-professional speculators in the financial markets - e.g. not professional. If you're professional - nobody needs to know how good or bad you are - because you're a player with a public key. Pseudo-anonymous. Join the game when it starts!
These are the easiest bets to place. The markets are already activated on chain.
Bitcoin Long Position Example
Size of 100 with 1x leverage in the BTC_USD market would look like this from the command line
komodo-cli -ac_name=MARGINGAMEDEMO pricesbet 100 1 "BTC_USD, 1"
As an RPC call from any programming language that supports HTTP requests
curl --user $rpcuser:$rpcpassword ...to be published in a future update...
will be published closer to launch.
What if you're Warren Buffet and you want to trade your own Berkshire Hathaway stock against KMD? You can't use a single ticker, you need multiple tickers to create your synthetic position. Moving onto multiple tickers.
For combining two markets, a simple stack based language (like bitcoin script is a stack based protocol) inspired by the Forth programming language. It was created by Komodo's Lead Developer jl777. It allows for maths operations between tickers and more.
Simply multiplying a BTC/USD market with a USD/EUR market, you can end up with a BTC/EUR price.
Another example using these operations in the format the daemon expects, creating an instruction like "BTC_USD, BTC_EUR, / 1" would end up with EUR/USD. These are pretty standard forex transformations.
Warren Buffet's Berkshire Hathaway Crypto Price Scenario
Earlier in the bitcoin long position example, the "Warren Buffet" trade scenario was proposed. This is how we get a Berkshire Hathaway price in KMD - and the same technique can be used for any market supported in the Antara Crypto Margin Trading Game. Subscribing to different feeds at the decentralized oracle level, and any supported combination of stocks, forex or any other market data can be turned into a blockchain fintech service.
- Pair I: KMD_BTC
- Pair II: BRK.A_USD
We want to have:
Using the Multiple Ticker option, we use 3 synthetics to achieve it in the format required:
"KMD_BTC, BTC_USD, BRK.A_USD, **/, 1"
- Multiply KMD_BTC with BTC_USD resulting in KMD_USD
- KMD_USD will be divided on USD_BRK.A (in other words, USD_BRK.A will be flipped and multiplied, this is how fractions are divided)
Resulting in Warren's KMD_BRK.A price of Berkshire Hathaway in KMD.
Multiple Stacks (Indexing or Grouping)
If you're still here, this part is where it gets uber interesting for the game. Trading on a basket or index of ticker symbols to create synthetic products with blockchain enforcement.
Finally, the language allows betting with any given weighted average of an arbitrary number of these tickers of synthetic prices which are made up of 1, 2 or 3 other Tickers that allows creating things that work like an index(or a basket):
A/B * B/C -> A/C
So by allowing all possible ways to combine 1, 2 and 3 symbols into a group G, we then can create a synthetic price of: G0K0 + G1K1 + ... Gn*Kn
Which is a form that allows you to create basically anything!
When Is Launch?
The LABS Notary Network, will be testing the margin trading platform with an unofficial & tentative plan to offer some trading incentives for early testers. LABS operates as an incentive based testnet for prospective projects and it's architecture is the first use of Komodo's MoMoM blockchain scaling technology.
The notary network of the LABS (which is different to the Komodo Notary Network) pays bounties at a maximum of 1008 LABS coin per 10080 blocks (approx 7 days). The bounties can be for any bug hunting and testing to do with any part of the application - cosmetic or mathematical. Testing is open access for anyone to participate, payments run through automated funds management and voting. More information to come in coming weeks.
First view of the rpc calls:
- pricesbet(amount,leverage,synthetic) - to open a bet. the resulting transaction id is called the “bettxid” of this bet. Used in most of the subsequent rpc calls
- priceslist([all|open|closed]) - returns a list of bets executed on chain, by default returns both opened and closed bets
- mypriceslist([all|open|closed]) - returns the list of bets executed on chain from the executor’s pubkey, by default returns both opened and closed bets
- pricesaddfunding bettxid amount - adds “amount” more funding to the bet referred by “bettxid” to reduce the risk of liquidation
- pricesinfo bettxid - returns information about the bet referred by the “bettxid”
- pricesrekt bettxid rektheight - creates the transaction that liquidates a bet that is rekt. The bet which has IsRekt: 1 flag in its pricesinfo call), This call performs some POW to deter spamming. All nodes on the network are incentivised to execute this transaction as it rewards some of the liquidated funds to the node that created the rekt transaction
- pricescashout bettxid - to cash out the bet referred by “bettxid” (equity should be positive, bet should be open and not rekted)
- pricesrefillfund amount - adds funds to the house (Global CC address)
- pricesgetorderbook - shows balance proportions of house orderbook pairs and also house wallet balance