Application of the Week

This week I’m featuring Apay’s new market making bot!

Bootstrapping liquidity is tough, and it’s generally a problem tackled by specialists with market making expertise. Apay, however, wanted to make it easier for more people to get involved in improving liquidity on the Stellar decentralized exchange, so they created a market making bot inspired by an Ethereum DEX, Uniswap.

The way it works: users deposit funds into a market making bot in return for an Apay-issued token that represents percentage ownership in the liquidity (or total balance) of the bot. The bot then calculates the price of a given pair as ratio between its balances (described below).

Here’s an example:

Let’s say a bot is running a BTC / USDT pair. It holds a balance of 1 BTC and 7,000 USDT and the bot sets the price of BTC at 7,000 USDT / BTC. There are also 100 APAYBTC tokens issued to users who have deposited funds in to the bot, each representing a percentage ownership in the liquidity. The bot starts trading around the 7,000/1 median price.

Say Alice is one of those users and she made an initial deposit of 0.1 BTC and 700 USDT. Since the value of each APAYBTC token is 0.01 BTC + 70 USD, Alice owns 10 of the APAYBTC tokens.

Now let’s say BTC’s price slowly rises to 14,000/1, and after trading back and forth, the bot ends up with a balance of 0.76 BTC and 10,650 USDT. At this point, if Alice decides to redeem her 10 APAYBTC tokens, she receives 0.076 BTC + 1,065 USDT. You’ll notice that Alice received 0.024 less BTC than she deposited, but 365 USDT more — which is higher than her original deposit. Interestingly, the result would be similar if the BTC price dropped to 3,500/1: she would get more BTC and less USDT, but the total output value would exceed the value of her initial deposit.

If you want to learn more about Apay’s new market making bot, check out their recent blog post here.

Warning: Trading is risky regardless of whether it’s done by a bot or a human. You shouldn’t make decisions about using this bot without doing your own research first and understanding the risks involved.