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

Market: Adding liquidity should be free #51

Open
mdyring opened this issue Mar 8, 2021 · 6 comments
Open

Market: Adding liquidity should be free #51

mdyring opened this issue Mar 8, 2021 · 6 comments
Assignees
Labels
consensus-breaking enhancement New feature or request

Comments

@mdyring
Copy link
Contributor

mdyring commented Mar 8, 2021

Is your feature request related to a problem? Please describe.
To incentivise market makers, net adding liquidity over time should be free. This can be unpacked as:

  • Adding liquidity should be free, e.g. MsgAddLimitOrder and potentially MsgAddMarketOrder.
  • Removing liquidity should never be free, e.g. MsgCancelOrder.
  • Replacing liquidity should be free, but only if not done too often (to avoid spamming the chain).

Describe the solution you'd like

  1. Make the gas associated with all market messages identical, so that MsgCancelOrder potentially carries same cost as MsgCancelReplaceLimitOrder.
  2. New orders that add liquidity should receive a gas rebate proportional to how much of the order was filled already (0% fill means 100% rebate):
    if addToBook {
  3. Canceled orders always pay full gas.
  4. Replaced orders are only eligible for the gas rebate in 2. if they are replacing an order older than, say, 5 minutes. This requires Add creation timestamp to orders #34 to work.

Additional considerations
It must not be possible to exploit the rebate mechanism in a way where it becomes cheaper (or even free) to remove liquidity, i.e. crafting an order to get almost filled but adding a small amount to the book should not result in a rebate.

It must not be possible to spam the chain with useless transactions. Only behaviour that is net adding liquidity

Describe alternatives you've considered
Further investigation needed here.

@mdyring mdyring added enhancement New feature or request consensus-breaking labels Mar 8, 2021
@haasted haasted added this to the Stargate milestone May 4, 2021
@blewater blewater self-assigned this May 11, 2021
@blewater
Copy link
Contributor

potentially MsgAddMarketOrder
@mdyring Could you provide an example when a MsgAddMarketOrder does not add liquidity and should cost gas?

@mdyring
Copy link
Contributor Author

mdyring commented May 16, 2021

potentially MsgAddMarketOrder
@mdyring Could you provide an example when a MsgAddMarketOrder does not add liquidity and should cost gas?

Most Market orders will not be adding liquidity as they cross the spread (they trade above the last traded price with a slippage % added)

@blewater blewater linked a pull request May 18, 2021 that will close this issue
@blewater
Copy link
Contributor

Due to fixing my incorrect FOK handling (thx @haasted 👍 ), I realized this spec ramification:

  • FOK orders always cost the full Gas
  • IOC orders never receive the full rebate. May receive partial credit.

@mdyring
Copy link
Contributor Author

mdyring commented May 20, 2021 via email

@blewater
Copy link
Contributor

ACK

blewater added a commit that referenced this issue Jun 2, 2021
@blewater
Copy link
Contributor

blewater commented Jun 4, 2021

The SDK is still solidifying around related Gas proposals dealing with enhanced centralized gas management.
There's a meaningful mini thread (read the replies) around introducing middleware for post-transaction Gas management: cosmos/cosmos-sdk#9348 (reply in thread).
A GasMeter Refund Api ctx.GasMeter().RefundGas(amount, "") is likely being tested and backported to a future 0.42.x release: cosmos/cosmos-sdk#9403.
Let's allow time and chime-in in the ongoing discussion to bring awareness to our Gas management needs.

@haasted haasted removed this from the Stargate milestone Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus-breaking enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants