DeFi on Hive: Automated Market Making for the Masses

in #defi3 years ago

In the past month or so, I've made a 48% return on a small investment of 400 HIVE and a 24.8% return on 250 STEEM. Not bad, considering this was an experimental test of a new product just launched as part of Hive Engine & Steem Engine.

I'm the lead smart contract developer for the Engine platform, and responsible for building out the back-end that runs our new DSwap Market Maker. Like any good developer, I like to eat my own dog food. Meaning I actually use the products I build on a daily basis, seeing what works & what doesn't, trying out new ideas, and just generally making sure nothing is gonna explode.

After a month of such testing, early results are in, and if this doesn't get you excited to jump out of bed in the morning, I don't know what will!

Automated market making, you say? Whazzat?

Revolutionary, ground-breaking stuff, is what it is. For a bit of background, you can refer to these earlier posts by @aggroed :

Basically, DSwap gives you a hassle free way to setup your very own market maker bot on Hive Engine (and soon on Steem Engine as well). All you have to do is click a few buttons and fill out some settings on a web form. That's it. This is extremely powerful. Up until now, such bots were the sole domain of elite techies & programmers who have the special skills needed to code and run them.

But not anymore.

Now anyone with a Hive account can have their own market maker running in about 5 minutes. No technical skills needed.

Wowsa! Show me the money!

Gladly. When you sign into DSwap for the first time, you'll have to register for the market maker, which requires a small fee in BEE (Hive Engine's native utility token). After registering, you'll be presented with your account dashboard which looks something like this (I already have the market maker configured to place orders for me on several markets):

Basically, you can choose which Hive Engine token symbol you want the market maker to trade for you (or more than one, if you upgrade to premium service). Then you answer some questions to tell the market maker how it should place orders:

Then the market maker will start automatically placing orders for you. Every 10 minutes (or every 5 minutes for premium service), it will analyze the state of the order books and decide if it needs to adjust any orders. It will continue doing this, 24 hours a day, 7 days a week, 365 days a year, until you tell it to stop.

Now you can sit back, relax, and watch your profits pile up.

That sounds too easy... what's the catch?

Well... the devil is in the details, as they say. Let me be clear: this is not a totally passive, set-it-and-forget-it type of investment. It requires hands on, active management. You need to monitor the performance of the market maker, tweak settings every now & then as market conditions change, and be ready to step in if something goes wrong. During periods of rapid price movement, for example, it can be easy for too much one-sided trading to result in losses for the market maker, so at such times you'll want to disable the bot and wait for the turmoil to pass.

Performance and returns will vary considerably depending on the characteristics of individual markets, and how you've configured the market maker. It is entirely possible you will lose money. Making a profit in this game is one part science and one part art.

Have you got what it takes?

Umm... maybe?

Don't despair! Even if you're not a savvy market expert, there are some basic rules of thumb you can use to minimize the chance of losses and maximize your potential for gain. Here are some tips distilled from my month's worth of experimenting:

Tips For Success

  1. Start small: add just a single market at first, ideally this should be for a favorite token that you know & love (my very first market was SIM). Have the market maker place small orders, no more than 50 SWAP.HIVE on the buy side and an equivalent amount of tokens on the sell side.

  2. When in doubt, go with the defaults: if you're not sure about a particular market setting, just go with the default. The defaults are fairly sensible in most cases, and you can always change them later.

  3. Ignore small orders: The order books are often filled to the brim with puny, negligible orders, typically from other bots. You want to set the market maker to ignore such orders so they don't interfere with your market making. That's this question down at the bottom of the settings page:

  4. Target markets with large spreads: the bigger the spread (defined as the difference between highest bid price and lowest ask price), the bigger your potential for profit. Small spreads result in smaller profits and bigger risk.

  5. Target markets with high volume: the flip side of rule #4 is that markets with big spreads are often ones that are thinly traded, with low volume. Which is very boring. High volume is the bread & butter of good market making, you want lots of buys & sells sloshing money back & forth to hit your orders. So the Holy Grail is to find a market that has both large spreads and large trading volume. Otherwise, go for one or the other.

  6. Target markets with stable prices: rapid price movement is the enemy of automated market making. Volatility is welcome, as long as the price stays in a well defined range. You want a price chart that looks like this:

    Not one that looks like this:

  7. Use a dedicated account: don't market make with your main Hive account that has 50,000 SWAP.HIVE (unless you really want to risk that much money all at once). Setup a new, dedicated alt account that you will only use for DSwap. Put a small amount of SWAP.HIVE on it to start with, and add more over time as you get confident with the market maker. This allows you to control your maximum possible losses.

  8. Premium service is absolutely worth it: you'll need premium service to unlock the market maker bot's full power for you. It offers many advantages over basic service, such as the ability to use more powerful order placing strategies and place orders on multiple markets. That said, starting off with basic service is best. See how it goes for a week or two, get comfortable with things, and if you can stay profitable then think about ramping up your market making with a premium upgrade. It'll pay for itself in the long run.

So how exactly did you make 48% in a month?

Well, mostly by following the above tips.

I started small, with just a single token symbol. I monitored that market for a few weeks before adding any more, checking my orders once or twice a day and adjusting settings if I didn't like how orders were being placed. One key thing I watched was the spread: if my orders were too close together, I modified settings to ensure they got placed a little farther back in the order book.

Once I gained confidence in the market maker and saw profits starting to slowly accumulate, I upgraded to premium service and added 3 more markets. My idea was to keep all my money working for me, making sure most of my capital was spread out in active orders and not just sitting idle in my account doing nothing. I did leave some reserves of SWAP.HIVE though, so I'd have a little cushion if multiple buys got hit in a short period of time.

As profits continue to accumulate and I notice more capital sitting in my account unused, I'll probably add more markets. But it's important not to grow too fast; I won't add new markets unless I have enough excess SWAP.HIVE to support them. I also like to keep order sizes roughly the same across all markets, so my capital is more or less evenly distributed.

Once I reach a certain point, I will begin increasing order sizes so I can make profits faster. However I'm not there yet. I still keep my orders around 50 SWAP.HIVE in size, same as I did at the very beginning a month ago.

Did you take advantage of any particular market patterns?

You betcha! Over the past several days, DEC has been a great cash cow for me. It's a market making dream right now! Here's what the depth chart looks like as of this writing:

This kind of valley pattern is quite favorable. Notice the huge walls on the buy & sell sides, with a fairly large gap between them filled with small orders. In this situation, you can use the market maker bot's wall nestling premium order strategy to place orders snugly up against the big walls on both sides (around the circled areas, say).

Then you simply let trades pogo back & forth between the walls, hitting your orders along the way and giving you nice juicy profits as the market maker buys low & sells higher, over and over again. Which is exactly what I've been doing.

I'm excited! Where can I learn more?

Feel free to pop into the Engine Discord and ask around. Someone is usually around to point you in the right direction, and for market maker related queries you can ping me directly (I can't guarantee a timely response though as I'm often very busy).

If you need technical assistance it's better to raise a support ticket. Our support staff typically respond within 24-48 hours on business days.

Technical Resources

Did I mention the smart contracts that power the market maker are completely open source? You can find them here:

  • botcontroller.js - smart contract for managing user account data, registering / upgrading accounts, enabling / disabling markets, etc
  • marketmaker.js - smart contract that runs the bot's order placing logic

Comprehensive technical documentation is available here:

Even if you're not technically minded, it's worth skimming through the docs as it describes how the market maker functions in detail, what all the settings mean, and gives a point by point comparison of basic vs premium service features.

If you are a developer, the docs will teach you how to control the market maker bot using custom json transactions. That's useful if you want to manage the market maker by script or wish to program a whole new front-end as an alternative to the DSwap web site.

So head on over to DSwap today and get started. Have fun diving down the rabbit hole!


Images in this post are mostly screen shots I took myself. DSwap logo available from the Engine team, title image is licensed for public use from Pixabay.


Very cool. Thanks for giving us non-tekkies an opportunity to do some auto-trading on the Engine 👍🏾

My pleasure. Techies shouldn't get to have all the fun, we're all about equal opportunity here! 😉

Now that is how you do it! Excellent presentation in every respect! You've got me interested, I know exactly what I'm getting into (it's not without risk), have some great tips to consider, and it looks like it might even be fun!

Edit: Forgot to also say "I'm in control", i.e. not 'loaning' to an anonymous unknown.

Thanks, and good luck if you give it a try! Hope it works out well for you.

Very cool thanks! My first thought was DEC! I just sold 65,000 to try and do some swing trades. Made 200 hive and I think I’ll take 50 of it to try this out!

Nicely done! Hope the market maker meets your needs.

Does immediately recognising these tokens just from these charts make me l33t?

1337ness confirmed

I miss some Steem on my deposit from @commentcoin Acc of steem. Hope you can fix it. Thank you

Hell yes it does!

This post was shared and voted inside the discord by the curators team of discovery-it
Join our community! hive-193212
Discovery-it is also a Witness, vote for us here
Delegate to us for passive income. Check our 80% fee-back Program

So 100 Bee of register and then 200 stake just to use the service?
Bullshit. Thats fucked up.
Please unregister my account @sidekicker and send back the 100 Bee...

The service runs on decentralized smart contracts, meaning we have no control to do things like cancel account registrations. And fees get burnt, they don't go to us, so there's nothing to refund. If you decide not to use the market maker, simply turn off your account or don't add a market.

100 BEE at the moment costs around $17, which is a fairly small amount given the potential upside. And you don't lose your stake (you can unstake it any time you want), that simply represents the fact that while you use the market maker you are consuming system resources which has a small cost.

It would have been quite nice if you have mention the fees by numbers in this post :)
No where does it state it requires additional a buy of 200 bees if one doesn't have them x)

So thanks for the useless info! :D

It clearly states so.

Here is a good introduction about what a market maker do:

Looks like some good background reading, thanks for sharing.

Cool dashboard!

Nice. I look forward to testing it out

I said fuck it and wanted to try your service..
Explain this to me then.



Can you take a look at the pictures above and help me? :)

It costs 1 BEE to update settings for basic service (premium service does not have such a fee). The error message is misleading, it should say BEE instead of BEER. I'll ask our web site developers to fix it, sorry about that.

I also have one bee which isn't staked and I still cant update x)

We're investigating this and will get back to you. I apologize for the less than smooth experience you've been having so far.

This should be fixed now. Please try again and confirm if it works.

I gave up and unstaked my bees. Not worth the time

What does the time limit of 14d mean? Is the bot not working anymore after 14 days?

Basic service runs continuously for 14 days (the countdown pauses if you turn off your account for some reason). After that, your account will become disabled for a cooldown period of another 14 days. Once the cooldown period expires, the time limit resets and you can re-enable your account again.

Premium service has no such time restrictions.

So the Basic Service has a 100 Bee fee plus I need 200 Bee to be staked in the wallet, is that correct?

Nice post

This a great opportunity for trader. I will learn more about DSwap function to accurately use it.

Is it true that for the Premium you don´t need to stake 1000 Bee like explained but 1000 plus 200 more for each trading pair?

That's correct. The 1000 BEE is a base amount for premium access, and then it's 200 additional BEE staked per trading pair after that. Staking represents your entitlement to use a certain amount of system processing power. As you add more markets, the amount of processing power you are utilizing increases, and thus so do the staking requirements.

Note however that if you don't have enough stake to run the market maker on several markets simultaneously, you can simply delete an existing market configuration, then add new configuration for a different market. So you can experiment with moving from market to market and see which one works best for you.

Thank you! I knew this was going to be an invaluable tool when aggroed posted after the the live test and I'm very excited to learn how to use it. I've been looking for something like this for some time now.

Congratulations @cryptomancer! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You received more than 9000 as payout for your posts. Your next target is to reach a total payout of 10000

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Next Hive Power Up Day is February 1st 2021

With this bot, only those who have the most will win, because they are the ones who will have the most coins and will dominate the market, I mean the same as always, the one who has the most and who we... bye