Upload Orderbook Contracts as CW Pool

This proposal would add orderbooks as a new pool type. These pools allow limit orders to be placed at arbitrary price points while being compatible with all other deployments of liquidity on Osmosis.

What are Orderbooks?

Orderbooks enable users to place orders at specific prices, ensuring priority execution at the desired price without depending on the availability of prior liquidity in pools. They also empower market makers to offer narrower spreads compared to the fixed spreads enforced by concentrated liquidity, where the swap fee acts as a minimum spread for the pool. The reduced spread also allows more competitive prices for highly correlated pairs, such as pairs of asset variants or stablecoins.

Limit orders have two main benefits.

  • Trades that would otherwise see high slippage may be fulfilled with zero slippage once the target price is reached. Examples of these trades are buying a large amount of a highly liquid asset like ATOM or a small amount of an illiquid asset on Osmosis, such as PEPE.
  • Traders who want to buy or sell at a specific price may set their desired target price for execution rather than watching the market for manual trading or using centralized services.

Implementing as a Cosmwasm pool type will integrate orderbooks into the sidecar routing service, and limit orders will automatically be factored into routes for swaps using this service. Therefore, Osmosis’s existing volume will immediately flow through orderbooks when they have limit orders offering better execution prices than other sources of liquidity on Osmosis.

This implementation of an onchain orderbook uses a mechanism invented by the Osmosis Foundation that aims to be the most performant implementation of any currently live orderbook DEX in terms of runtime complexity. A complete whitepaper describing the mechanism will be released soon, but the implementation can be reviewed in the Github repo below, which was open sourced immediately prior to this post.

Osmosis governance will retain the admin of the order book contract to ensure transparency and decentralization. Osmosis contributors control a moderator account as a security measure, which can only freeze pools in case of a security vulnerability.

Contract Details

Commit: 9f7e2aea2da983ab4943d039b351b55dbcf36fd3

Compiler Version: optimizer-arm64:0.16.0

Checksum: 41e1e49ff96e826ad61a96ee28cab6ec132e2d82f0064874a9e0faecd3b0cc73

Code repository: GitHub - osmosis-labs/orderbook: Cosmwasm Orderbook Repo for Osmosis

9 Likes

This is incredibly exciting.

Will poke the code tomorrow!

2 Likes

This sounds exciting.

Orderbooks will improve the trading UX on Osmosis by allowing traders to place limit orders and bringing down slippage.

1 Like

This sounds really really cool!

Will the front-end for the users get the same UI/UX like we see on a CEX? Where users can easily place sell and buy orders?

And, will we see potential further developments like stop-loss orders, because having that on a DEX… would be a never-seen-before combination.

1 Like

It will likely be a very incremental process in terms of UX. Rollout at first will effectively be improved swap tooling rather than a full order book interface.

But, of course, that is just the interface planned by osmosis.zone rather than any other integrators, which is the beauty of implementing new pool types.

Stop losses have been mentioned in relation to Smart Accounts so certainly possible too.

1 Like

We welcome this feature with great pleasure. This was a well-awaited update that many of our community members have been eager to use. We want to shout out a big thank you to the teams who diligently worked to deliver this contract.

pro-delegators-sign

1 Like

Ok stoked for this!!!

Pretty neat to build an orderbook that can interact with AMM liquidity :slight_smile:

Is there a name for this type of orderbook or is it a completely original design?

It’d be interesting to understand why liquidity needs to be “claimed” from the contract post execution of a trade.

Any other design docs appreciated <3

Very excited about orderbooks coming to Osmosis. My only concern is that this proposal would add orderbooks as a new pool type. If I understand this correctly, it means that we won’t be able to use limit orders on the current pools and will need to create new pools to trade with limit orders. If my understanding is correct, then this fragments the liquidity even more, and it won’t be easy for large actors to trade using orderbooks with large positions in this case.

Otherwise, very excited to have the option to use this feature on Osmosis!

1 Like

There was an issue discovered upon further testing within the production environment with v1 of the Orderbook which required a fix to be implemented and the testing procedures expanded.

Uploading Orderbook V2 via a Cosmwasm pool approval proposal to replace the original Orderbook upload.

2 Likes