Skip to main content

· 2 min read
H.

banner

What's Been Done

  • Over the weeks, we have been observing some users to submit deliberately mispriced orders and as a result, displacing the price reported in market statistics. We have adopted feedback from our community member Bluemoon to filter trade prices according to the current order book. The price field now is a stabler measure of the market. For existing API users who require stable price sources, there is nothing you need to do; for developers who want to see all trades including the mispriced ones, please check out Trade History API.

  • You can now access all market statistics with Market Statistics API by leaving the market_id field blank.

  • Over the course of the week, we added several tokens, including Little Lambo Coin, Green Wings, and Easter Egg. These community developers are have a blast with all kinds of activities! Active participation from community members is a critical factor to a project's success, and we enjoy co-hosting all sorts of events to foster the communities.

  • We implemented support for fee on Hashgreen DEX and will soon roll out on the mainnet. Under dust storm conditions, it might take a few hours to settle your trades, but now you will be able to optionally receive a little bit less XCH or pay a little more XCH as the network fee to expedite your orders. The frontend will indicate the suggested fee according to network conditions, and usually a 0.0001 XCH will get your offers settled in no time!

  • The UI/UX team continues to implement the product facelift.

What's Rolling

  • Goby integration, after reaching out to the Goby team, turns out to be not possible at the time of writing since the ability to make offers from Goby is still being implemented. Current integrations on other platforms rely on the offer taking feature, which has already been a part of previous Goby feature set. As briefly explained in a blog post, we believe an efficient DeFi system would require the operators aggregate the offers, so we are now waiting good news from the Goby team about the offer making functionality.

  • We soon will start listing all tokens on the TAIL Database, compacted in the new market selection menu. You can even star your favorite CATs!

· 3 min read
H.

banner

This is a long overdue update to the community! During the past two weeks, we are looking at other aspects of development on the Chia Blockchain.

What's Been Done

  • We worked with many project developers, including NINE, NioCoin, Zomb Studios, and FundMyLaptop on their airdropping campaign with our in-house airdrop tools. The need for such a tool for project developers cannot be overstated, and we managed to test it fairly thoroughly over the duststorm, sending out thousands of transactions on Chia. The airdrop tools is aimed for a open source later this month.

  • The chialisp team is developing a chialisp library that enables secure smart coin development on Chia, much like OpenZeppelin on Ethereum. The goal is to not only establish a set of tools for easier smart coin development, but also re-implement some standards (e.g., CATs) for these advanced developers to understand the use case. Below is an sneak peek on the square root function we implemented which would be a core utility function for AMMs!

(
;; Babylonian method for square root.

(defun cypher.math.sqrt-loop-babylonian (var var1 var2)

(if (> var1 var2)
(cypher.math.sqrt-loop-babylonian
var var2 (/ (+ (/ var var2) var2) 2))
var1
)
)

(defun cypher.math.sqrt (var)
(if (> var 3)
(cypher.math.sqrt-loop-babylonian var var (+ (/ var 2) 1))
(if (> var 0) 1 (if (= var 0) 0 (x)))
)
)
)
  • The backend team wrapped up integration with the TAIL Database. We now have all the community CATs in our database, and once the new market selection menu is rolled out, you will be able to easily search up token markets!

  • The UI/UX team worked through the first draft on the user interface refactor on Figma.

  • We onboarded a frontend engineer, Henry, to help with mobile wallet integration. He will work with Goby wallet to enable that one-click trading experience.

What's Rolling

  • Goby integration is apparently the most requested feature! However, unlike offerpool and offerbin, Hashgreen implements our technology to be an offer aggregator so the raw offer files are never exposed to fellow users. We instead ask the wallet to upload a counter-offer to our website, which we can then be combined with existing offer on Hashgreen for blockchain execution.

  • Due to the shear number of CATs out there, we are prioritizing the market selection menu refactoring. The upgraded menu would allow you to easily navigate hundreds of CATs, star your favorite ones, and group CATs by their types.

  • We noticed that there is a need for a robust transaction micro-service to handle dApp requests, especially during the duststorm where fee is non-zero and when everyone suffers. This transaction micro-service will not only deterministically make sure a transaction is delivered, but also provide on-chain fee estimates for our upcoming dApps.

· 3 min read
H.

banner

What's Been Done

API Access

Trading API has been the biggest update for the week. We are committed to provide a diverse set of API for developers so the community can grow with us. At the same time, we would like you to be explicit about the usage of Hashgreen APIs in your products to spread the words! Let us know your story and the creative use of both open market information and statistics.

  • We added USD quotes and USD volume in the market stat endpoint. The fully diluted market cap for the base currency in USD (the token in the front of the trading pair) is also provided as a ball park measure of how big the token is.

Note that the reference prices are only estimates are can be vulnerable to self-trading exploits. Please do not use currency price quotes directly in mission critical systems but only as a good reference.

User Interface

  • The frontend team has been working hard on i18n (check out the beta site), and will be soon be pushed to the production site. We are offering Chinese and Spanish as a taste test, and are preparing for a community-based translation campaign!

i18n

  • The aforementioned market statistics are now displayed as a part of the market header. You can easily judge market liquidity based on the USD volume.

i18n

  • We've also worked through a bunch of frontend bug fixes including market selection menu overflow and asset filter menu. We won't bother detailing them but rest assured we are incorporating community feedback.

What's Rolling

  • Now that we have the fully diluted market cap, we are making a market overview menu to highlight the most traded and the highest cap tokens.

  • The fully diluted market cap does not holistically represent the true market capitalization as any whale can HODL the majority of the tokens. What is more representative is the market cap based on circulating supply which can be tricky to automatically detect on Chia. We are working on some smart algorithms to pick that up from the blockchain.

  • In the long run, we realize we need a more elegant product UI to streamline user experience. The recently onboarded UI designer is starting to work hard on the refactor.

  • We had some very fruitful discussion on the mathematical design of automated market makers (AMM). There are some pretty important implications translating everything from account-based to coin-based models, and we are pretty sure we nailed it correctly.

· 3 min read
H.

banner

Happy lunar new year everyone! The Asia-based Hashgreen dev team had a great lunar new year over the past week! We find that our Discord community has been very active, and some updates might get buried under the exciting updates on new CAT tokens joining the family every other few days. Hence we are starting to update you about our technical progress on a weekly basis.

What's Been Done

User Interface

  • We added the light/dark scheme switch to make your eyes more comfortable, located in the footer section.
  • Right beside the market selection button, there is a row of market statistics showing 24h high, 24h low, volume, and the current price.

API Access

  • To facilitate automatic trading, we released our first API doc on trading, including the ability to list markets, order books, and personal order creation/cancellation. We envision more and more participants can be in this process to reach the best market efficiency, involving arbitrage loops across Hashgreen DEX and other exchanges. In the loop, you will have to involve Stably Prime as they are the only stablecoin issuer on Chia right now.

  • The statistics of markets can now be retrieved via stat API. In the first version, we provide 24-hour statistics on the traded volumes, and are working towards representing the volumes in USD.

Personnel

  • We onboarded a UI/UX designer, Ann, to help us improve our product further. There are some complicated integration with our partners including the official Chia wallet, a in-development Chrome extension wallet, and potentially one other browser-based wallet. We imagine the UX flow to be increasingly complicated, and hence it is time to involve specialists.

What's Rolling

  • I18n is coming! We aim to build Hashgreen DEX to be a platform everyone in the world can enjoy, and we soon will need your help to translate our product!

  • The smart contract team is working on several chialisp designs, which can be a pretty prolonged process as it requires not only security audit but implementation and integration with wallet partners. One of the most immediate improvement to the Hashgreen DEX is to use an alternate version of offers to allow partial filling of offers.

  • The next critical piece for the on-chain economy and DeFi will be Automated Market Maker (AMM)! AMM implementation on the Chia Blockchain will require some bells and whistles though, and we are working very hard to propose a first draft. This set of chialisp implementation will not only be secure and fair from a user's perspectively, eliminating potential extractable values. All of these are still in development, but we want to stay tuned for more exciting updates!

· 13 min read
H.

Hashgreen successfully released a decentralized exchange on Jan 12, 2022, in a joint live event with Chia Network. If you were not at the event with us, here is a clip of the presentation on the Hashgreen Decentralized Exchange (DEX).

Chia Blockchain introduced its first on-chain atomic token swap standard, powered by the underlying smart coin language Chialisp. Using this standard, users can start exchanging tokens on the chain, including the Chia (XCH) token and other Chia Asset Tokens (CATs). This functionality opens a lot of possibilities on the blockchain, including the first batch of dApps, with Hashgreen DEX being one of them.

We at Hashgreen have been working hard for months to develop the project and integrate our interface into the official Chia wallet. After the successful launch, we received many questions on how and why we decided to build Hashgreen DEX this way.

In today's post, we want to take you through a journey - a journey on Chia's most basic technical building blocks, how and why we crafted the first DEX on the Chia Blockchain, and finally, how we envision DeFi will look like on Chia.

Prologue

Let's not pretend this has never happened. You opened up your Chia wallet, trying to exchange some Chia (XCH) for some Stably USD (USDS) on the Hashgreen DEX. This popped out, saying you have a lot less spendable balance than you have total balance...

Oh No!

...what happened! If I have all the XCH, why am I unable to send them all, or make an offer out of it? Well, UTXO is the main culprit here.

UTXO

Short for unspent transaction outputs, this is nothing new and was introduced by Bitcoin. Instead of having a balance sheet for every user on the blockchain, Chia tracks your funds using UTXOs (or, rather, coin set to be more accurate), which is a technically fancy way of referring to coins. Coins have predefined ways to be spent, and are capable of producing coin outputs when they are spent. Moreover, any given coin is only ever created once and spent once -- and that's it! This philosophy focuses on tracking the change of state on the blockchain as opposed to recording the whole state.

info

You can easily track how many coins are created in the blockchain using explorers.

The choice of using UTXOs on Chia leads to many interesting and advantageous properties:

  • The verification of coin spending is highly parallelizable since each coin can only have one interaction. In contrast, account-model-based blockchains need to handle transactions sequentially.

  • The balance is a first-class citizen on the Chia Blockchain! Instead of being a state stored in a mapping table, every coin on Chia has an explicit amount, the total of which has to stay constant. (Well except when you farmed a block, you receive 2 XCH in total out of thin air.)

  • Since the transactions in a single block are order-less (i.e. their order does not matter as long as they are included in the block), the attack surface of smart contracts reduces drastically. In other blockchains, we often hear the term Miner Extractable Value (MEV), which refers to the profit that a miner could secure by manipulating the ordering of the transactions.

info

It is estimated that over $576M MEV, as of the time of writing, has been extracted from Ethereum.

With these seemingly wonderful advantages, it sounds like a no-brainer that every chain should adopt this model as opposed to the account model. Apparently there are some trade-offs; trade-offs that takes additional effort to mitigate but are definitely worth it.

Implications to Users

Let's hop back onto our spendable balance problem.

When we make transactions, we are in fact spending a coin or coins that might sum up to more than what we try to send. For example, imagine you are a lucky farmer who farmed a 1.75 XCH coin and wish to send 0.1 XCH to your friend to let them HODL. When you send the XCH, you are actually destroying the initial 1.75 XCH coin, creating a 0.1 XCH for your friend, and sending the rest 1.65 XCH back to yourself. During the wait for the change coin to come back, your funds are effectively reduced, and that is why the Chia wallet shows a lower spendable balance as you cannot double-spend a coin.

Offers are more or less the same: as you create offers to exchange your tokens, you do not want to accidentally spend your coins and invalidate the offer. The Chia wallet was kind enough to soft-lock the coin so that it cannot be used, until you either cancel the offer or when the offer has been fulfilled.

Implications to Developers

The UTXO model, while having a significantly smaller attack surface than that of the account model, is trickier for protocol design. If you still remember, transactions in the same block are spent simultaneously and every coin is only spent exactly once. This implies that if we want to build a more advanced application, we have to design while keeping the ability to perform multiple interactions in mind. Take a very basic application for example - an automated market maker (AMM).

The most renowned instance of an AMM is Uniswap where swappers would exchange their assets with a liquidity pool at a market price determined by the amount of assets held in the pool. When Uniswap contracts are executed, they run sequentially, creating an interaction between the swapper and the pool each time. Yet on the Chia Blockchain, we cannot naively queue up user exchange requests sequentially, since there is only one pool with one coin present. This produces several challenges: For example, exchange operations would need to be aggregated somehow to interact with the pool together. Furthermore, we need to ensure price fairness, resist against denial of service attacks, and overcome many other problems!

There are many proposed solutions on other UTXO-based blockchains, and for the sake of brevity, we will include the discussion in future posts.

tip

In short, clever design choices have to be made for dApps, but when smart contracts are carefully crafted, UTXO-based blockchains have better security guarantees and efficiency.

Chia's Take

Bitcoin was successful, but as a store of value, not as a successful technological demonstration. Bram Cohen himself wrote about how Chia's technical motivation stemmed from Bitcoin, and as a last-mover, Chia was able to get things right the first try.

On day one, Chia shipped with the full capability to process smart contracts (or, smart coins, to be more accurate). The on-chain language, chialisp, powers many existing features such as singleton, Chia Asset Token (CAT), and even offers. The programs for smart coins themselves were not actually stored on-chain, but rather, its Merkle root hash is. One does not have to reveal the program until the coins are spent, thus greatly reducing the attack surface. These smart coin primitives are also extremely composable, giving developers building blocks for their decentralized applications.

To date, there is a prosperous community around CATs -- project developers issuing their own tokens and project followers HODLing and trading. We at Hashgreen believe there are more exciting things to come in the Chia ecosystem, but first, let us take a look at how we built the Hashgreen DEX and why it is designed in this way.

Hashgreen DEX

Chia wrote an in-depth analysis about how offers work technologically and how they can be used in dApps. In case you have not read it, here's a quick summary:

info

Offers are serialized off-chain commitments to swap coins for coins. Anyone can take that file and complete the other side of the swap, sending it to the blockchain to settle. Without the other half of the trade, no one would be able to spend your coins or steal your funds.

It is intuitive that, you can send your offer files around in channels like Keybase and Discord, yet you will soon realize -- the prices you get are nowhere close to optimal. Liquidity is plain disastrous with vanilla peer-to-peer trading, and this is the main push for more advanced dApps. Some examples are OfferBin and OfferPool which provide offer upload, sorting, and download services. They operate just like Craigslist: users are responsible for submitting the offers, and pushing aggregated offers to full nodes on their own.

Problems We Solve

Interestingly, Hashgreen did consider this solution, and we observed several potential problems with this Craigslist approach and ultimately went with our current DEX approach.

  1. User Contention

    These Craigslist-like offer pastebins will ultimately face an unsolvable challenge with offer contention. Concretely, contention happens when an offer was downloaded by different parties and spent in the same block. In a fee market, the spends with lower fees will be discarded while the one with the highest fee will go through. While the fee rule itself is totally fair, users with an honest intention to trade in the market but using lower fees will unwillingly have to give up and look for other trades.

    Most users do not experience contention now since the market velocity is relatively slow at this point, yet in some cases when there are sudden spikes in trades, contention will become obvious. The SM1 token backed by Chris from The Chia Plot went on a sale on OfferBin, and one unfortunate conclusion Chris drew was that too many people participating in the auction can cause problems on OfferBin, in line with what we discussed above.

    That is exactly why we opted for a download-free solution: instead of users bringing the offers home and making their counter-offers, we aggregate offers on two sides, immediately bringing both down from the order book, and pushing them to the chain on your behalf. Not only are we unable to mess with your fund, but we also are unable to cheat you since the swaps are guaranteed by chialisp.

  2. Scalability

    We want there to be market makers in the game. We want there to be arbitrageurs in the game. We want there to be hobby day traders in the game. None of these would be possible without an API interface that is easy to play with and use. Hashgreen is drafting up documentation on trading API, which would be finalized soon. After its release, we expect people to take advantage of other existing markets to form a closed loop to both stabilize the price and increase liquidity. One interesting thing we have observed, at the time of writing, the XCH/USDS pair is typically higher in price than other XCH/USD pairs in different markets. We hypothesize that many interested buyers are gradually entering the market, obtaining XCH with their freshly withdrawn Stably USD, and obviously someone else can obtain XCH at a slightly lower price in overseas markets.

  3. Expandability

    There are many plans from Hashgreen to upgrade our DEX. To be a fully functioning DEX, one would typically expect there to be features like partial order fills, limit orders, and even market orders. We've identified some upgrade paths to the existing offers in order to support these features, and it wouldn't require a huge UX remake to integrate them. On the contrary, it might be somewhat confusing to implement these features into Craigslist-like services.

  4. Interoperability

    News about automatic market maker (AMM) development is on the street. Once an AMM is out on the market, we can easily hook you up to trade against AMMs with zero wait time for matching. Plus, we are always working closely with the Chia team to create a smoother trading UX experience from Hashgreen DEX to your Chia wallet!

Open Questions

Admittedly, several aspects need to be discussed in-depth about the DEX working principles, and we will briefly mention them here.

  • Operator Extractable Values (OEV)

    OEV not only covers the previously mentioned miner extractable values (MEV), but also covers the values extractable by aggregators like Hashgreen DEX. In principle, if there are enough orders on the market, they can create an overlap in prices. Aggregators, having observed this phenomenon, can pocket the spread by buying up the cheaper sell offer and selling off the more expensive buy offer simultaneously, pocketing the spread. While we are honest and only match exact offers from two sides, it is not guaranteed that every aggregator will be a good actor. In our preliminary exploration with AMMs, we have found some countermeasures to ensure aggregator honesty in a trustless manner with chialisp. The detail of the mechanisms will certainly be revealed and explained in-depth after we release the product, but for the time being we would love to work behind the curtains for some more.

  • Decentralization

    OfferPool sets out to be another offer pastebin site to combat the centralization of offer files. The arguments of anti-centralization do make sense up to a certain point, since those were the driving force behind the existence of blockchain technology. However, when already operating on a decentralized infrastructure, how much more decentralization is required is debatable, as having scattered decentralized services might lead to inefficiency in the application. Take an AMM for example, having more total values locked (TVL) in the protocol means that service users would enjoy a better price. Despite being centralized in terms of capital concentration, not a single party is able to single-handedly control the capital since the rules behind the capital movement are crystal clear. Hence we believe the better argument is that, the protocols need to be fully transparent to allow the blockchain to do its job at ensuring decentralized and trustless execution.

Summary

Working on the Chia Blockchain certainly brings many unique challenges to the Hashgreen team, and we want to tell you that this MIT-based team is not afraid of challenges!

Along the way, we have heard of perspectives on Chia's development purely based on its price, but this is simply an unhealthy view on a tech-heavy project. Being one of the first developers on Chia, we are journeying through its infancy as well as you are, and enabling more and more applications on our way. At any given point in time, we might find ourselves having to make trade-offs in either protocol design or system deployment, but rest assured that we take a first principled approach with the user's best interest at top priority. In order for us to communicate these complex ideas with you, we are starting this blog to periodically fill you in with more development progress and technological insights for the Chia Blockchain.

If you have more questions, you can refer to the FAQs or follow us on social media (Discord and Twitter). Thanks for staying with us!