Skip to main content

📖 Features

Highlight

Offer

HashgreenSwap (HGSwap) uses offers at its core. Whether it’s liquidity addition, liquidity removal, or token swaps, users can look up current prices of the pool and submit a corresponding offer to match the HGSwap’s pools. For example, one can create an offer swapping 1.000 XCH for 35.000 USDS, and the HGSwap dApp can combine it with the pool funds, creating a transaction (”spend bundle” for chialisp people) to be submitted to the blockchain.

This experience is different from current peer-to-peer (p2p) trading in that you do not need a counter-party to take your offer, as the HGSwap will always take your offer as long as your offering prices are at or around the market price. All transactions can settle within a block (less than a minute in real time) provided sufficient fees are included in the offer.

Key Features

Zap

“Zap” is the ability to add unequal funds to the pool. In Uniswap, you will have to add equal values in two tokens (e.g., 1 ETH and 1800 USDC) to deposit liquidity. HGSwap is built factoring in unequal fund addition, which allows several parties to provide liquidity so much more easily. As a XCH holder, you can directly add them to the XCH-USDS pool without having to convert half of them into USDS first; as a project developer, you can simply put in PROJ token into a PROJ-XCH pool to provide liquidity.

Simply put, it is a huge time and effort saver for the users to have the ability to “zap” into a liquidity pool, and you would not end up with annoying tiny amount of scrap tokens on either end.

Marketplace Aggregation

One of the core feature of offers is the ability to aggregate. There are plenty of marketplaces that currently hold an amazing repository of offer files, and these marketplaces can become big players against HGSwap by aggregating multiple offers into one and trading against it.

One thing to note is, many current offers on the market have prices far away from market prices, and generally they wouldn’t be able to be traded against HGSwap. Only offers with prices close to the market price have a chance to be included in the marketplace aggregation, thus making it possible for these marketplaces be profitable.

Permissioning

Chia is a coin-set model blockchain, and hence lack of permissioning can lead to denial-of-service attacks against any protocols. Concretely, a bad actor can consistently interact with HGSwap in each and every block while not performing any trade, thus blocking any actual users from using the service.

While it is true that the bad actor has to pay specific fees to continue to block the HGSwap, compared to the TVL (total value locked) of the pool it might be financially feasible and reasonable. This is a potentially weakness (not a security weakness though) of this version, and we aim to work with the community to continue to resolve the issue.

Airdrop to pool

You can airdrop your tokens or assets to a pool! While usually there is a 0.3% associated with the liquidity pools in terms of swapping, you can opt to donate everything into the pool and make it an airdrop! This will be a very useful inceptive tool for project developers as they can run campaigns to urge users to add liquidity into PROJ-XCH pools.

Money Matters

Fair Pricing

We don’t like to brag about ourselves, but we have employed advanced calculus to make detailed mathematical equations about the tokens and liquidity token payouts. The equations looks somewhat similar to the Uniswap’s A×B=V\sqrt{A \times B} = V, but has bells and whistles to ensure the fees are collected fairly in scenerios like “zapping” and when multiple offers are aggregated together. It looks somewhat like this:

(12logAA+12logBB)12ϕ12logAA12logBBlogVV\left( \frac{1}{2} \log \frac{A'}{A} + \frac{1}{2} \log \frac{B'}{B} \right) - \frac{1}{2} \phi \left| \frac{1}{2} \log \frac{A'}{A} - \frac{1}{2} \log \frac{B'}{B} \right| \ge \log \frac{V'}{V}

Don’t worry if you can’t understand, because you don’t have to. You can trust that the offers you are making will guarantee you can receiving at least the assets you are committing in the offer files, and leave the rest of the complicated maths to HGSwap.

Fee

We charge a 0.90% fee (like in Uniswap V1). 0.3% will go to the liquidity providers and 0.6% will go to HG token holders (a.k.a. protocol owners, or DAO participants). It is interesting to note that in cases like “zapping” where only half of the assets are effectively swapped, we cut your fee rate in half (because you are a great liquidity provider and we love you!).

The details of how protocol fees are distributed and utilized will be announced later, but it will likely be used to buy back $HG tokens from the market.

Future Works

The description of future works below might a little bit developer-facing and some Chia understanding is very required to continue.

Native Singleton Aggregation

It has been a very hot topic whether “singleton aggregation” is coming to the Chia Blockchain or not. Basically, with this feature on the consensus level, multiple users can interact with the same singleton (or, NFT) in the same block without a contention problem (i.e., only one of the users can successfully interact with the coin but the others will fail to perform so). Hence the aforementioned problems in the permissioning section will be largely alleviated, and the bad actors can no longer single-handedly block other users’ transactions against HGSwap.

End User Aggregation

Before the official singleton aggregation lands, it is feasible for the HGSwap dApp to look for pending transactions in the mempool, which other users have submitted for the intention of trading against HGSwap, and to build on top of the resulting singletons by replacing the original transaction.

The effect is, that subsequent users who are interested in interacting with HGSwap can “ride on the same coin”, which prevents users from fighting over the same coin; yet this requires the dApp to employ a strong backend service to achieve so as it needs to constantly listen to the mempool and provide the latest singleton information.

This approach will always be inferior to the native singleton aggregation as described above, but is a solution that any developer can accomplish.

Technicals

HashgreenSwap Smart Contracts

The HashgreenSwap smart contracts are the implementation of HashgreenSwap, an automated market maker (AMM) in chialisp language on the Chia blockchain. If you would like to verify the smart contract, please visit the GitHub repository here.

Cypher

The HashgreenSwap is built using an open-source chialisp library called Cypher. It is a library aiming at packing the most commonly used functionalities and alleviating common security issues for chialisp smart coin developers. It is extensively tested and hence increases the security promise we offer.