Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEX Market Makers #2749

Open
DerpHerpenstein opened this issue Nov 23, 2024 · 0 comments
Open

DEX Market Makers #2749

DerpHerpenstein opened this issue Nov 23, 2024 · 0 comments

Comments

@DerpHerpenstein
Copy link

I had a thought recently and have been trying to think it through figured I would drop it here for discussion. Proper AMM's will require quite a bit of new logic, testing and new database tables.

There may be a way to get the vast majority of the functionality into the current dex without a lot of changes by making a discreet version. It would require a new api endpoint, a new column in the dex, and a few lines of code to create a new order on the opposite side when an order of this type is filled. The disadvantage is there will be alot of orders created in the dex... (if this gets popular there could be tens of thousands of filled dex orders per day, so that side of things needs to be considered? It would be a good thing, but the db would certainly increase in size quickly ). If this were to ever be implemented, it would require an xcp fee large enough to discourage people opening up tons of LPs for tens of dollars in assets. (or perhaps when X pools are open on a pair, new pools must have a value greater than the smallest X/Y pools? just an idea)

Anyway, the idea is pretty simple, a user would compose a transaction to create a "DEX Market Maker". They would specify the asset pair, the minimum price, the maximum price, spread, and the type (linear or logarithmic spacing). In this example lets say the user wants to list 250 MINTS in the range 1 XCP to 10 XCP per mint with a spread of 1% and a linear order type. This order is creating a group of DEX orders selling 25 MINTS each. The table below shows the values

Order # Price in XCP-linear Price in XCP-log
1 1.00 1.00
2 1.38 1.10
3 1.75 1.20
4 2.13 1.30
5 2.50 1.50
6 2.88 1.60
7 3.25 1.80
8 3.63 2.00
9 4.00 2.20
10 4.38 2.40
11 4.75 2.70
12 5.13 3.00
13 5.50 3.30
14 5.88 3.60
15 6.25 3.90
16 6.63 4.30
17 7.00 4.70
18 7.38 5.10
19 7.75 5.60
20 8.13 6.20
21 8.50 6.80
22 8.88 7.50
23 9.25 8.20
24 9.63 9.10
25 10.00 10.00

image

The power behind this is not the group of DEX orders created in one tx, it's what happens next. Lets say the price of MINTS goes from 0.9 XCP to 1.01 XCP. Order 1 is filled. When the CP node fills the order, it takes the the 25 XCP (25 MINTS at 1XCP each) and creates an order on that users behalf to then buy 25 MINTS at (orderPrice*(1-spread)) and credits the user (orderPrice*(spread) + rounding error). So if the spread is 1%, the user then is credited 0.25 xcp and has a buy order for 25 MINTS at a price of 0.99XCP each. Then if the price down and that order is filled, the user now has the same amount of MINTS they started with, and an additional 0.25XCP.

When a user wants to close their position, all of these orders are closed.

As multiple users open up DMMs, the liquidity will overlap, filling in the gaps in price. The great part about this is it unifies the current DEX with automatic market makers allowing for the reuse of the current dex primitives.

@adamkrellenstein adamkrellenstein changed the title DEX Market Makers Protocol Spec: DEX Market Makers Nov 23, 2024
@adamkrellenstein adamkrellenstein changed the title Protocol Spec: DEX Market Makers DEX Market Makers Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants