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

Implement BSIP 74: Margin Call Fee Ratio #2129

Closed
1 of 17 tasks
jmjatlanta opened this issue Apr 3, 2020 · 13 comments
Closed
1 of 17 tasks

Implement BSIP 74: Margin Call Fee Ratio #2129

jmjatlanta opened this issue Apr 3, 2020 · 13 comments

Comments

@jmjatlanta
Copy link
Contributor

jmjatlanta commented Apr 3, 2020

This issue is to track the implementation of BSIP 74.

Impacts

  • API (the application programming interface)
  • Build (the build process or something prior to compiled code)
  • CLI (the command line wallet)
  • Deployment (the deployment process after building such as Docker, Travis, etc.)
  • DEX (the Decentralized EXchange, market engine, etc.)
  • P2P (the peer-to-peer network for transaction/block propagation)
  • Performance (system or user efficiency, etc.)
  • Protocol (the blockchain logic, consensus, validation, etc.)
  • Security (the security of system or user data, etc.)
  • UX (the User Experience)
  • Other (please add below)

Additional Context
Discussion about the BSIP itself can be found here. This issue is to discuss implementation details.

CORE TEAM TASK LIST

  • Evaluate / Prioritize Feature Request
  • Refine User Stories / Requirements
  • Define Test Cases
  • Design / Develop Solution
  • Perform QA/Testing
  • Update Documentation
@jmjatlanta
Copy link
Contributor Author

jmjatlanta commented Apr 3, 2020

It seems this is very much like the market fee. It is calculated at order execution time, and modifies the quantity of the asset sent or received. It is unlike an operation fee, that is deducted up-front at order creation time.

Prior to BSIP 74, no market fee was charged to the account that created the limit order that ended up going against the call order.

With BSIP 74, there will be a fee charged, which will go to the asset issuer. The fee amount is not based on asset_options.market_fee_percent but instead asset_options.extensions.margin_call_fee_ratio. This provides finer-grained control of fee amounts.

Note that this fee will only be charged to call orders that are matched to limit orders.

Please review and comment on my assumptions, as this will help to assure an implementation that matches the spirit of the BSIP.

@abitmore
Copy link
Member

abitmore commented Apr 3, 2020

The spirit is "the call order gets charged" but not the limit order gets charged, although technically it's almost the same thing but with a shift on price.

@abitmore abitmore changed the title Implement BSIP 74 Implement BSIP 74: Margin Call Fee Ratio Apr 3, 2020
@shulthz
Copy link

shulthz commented Apr 6, 2020

This fee must can be shared a part of it (e.g. like 20%) to the margin call buyer which can be set by the asset owner.
These shared fees must be continually unlocked during a vesting period like 48 hours.
This will encourage the buyer to eat the margin call, it's a very important part of this BSIP.

@jmjatlanta
Copy link
Contributor Author

This fee must can be shared a part of it (e.g. like 20%) to the margin call buyer which can be set by the asset owner.
These shared fees must be continually unlocked during a vesting period like 48 hours.
This will encourage the buyer to eat the margin call, it's a very important part of this BSIP.

I do not see these requirements in the BSIP specifications. Was it agreed and voted upon elsewhere?

@shulthz
Copy link

shulthz commented Apr 7, 2020

This fee must can be shared a part of it (e.g. like 20%) to the margin call buyer which can be set by the asset owner.
These shared fees must be continually unlocked during a vesting period like 48 hours.
This will encourage the buyer to eat the margin call, it's a very important part of this BSIP.

I do not see these requirements in the BSIP specifications. Was it agreed and voted upon elsewhere?

I have give these requirements long times ago, but the author maybe didn't understand the spirit of this BSIP.

This BSIP have two main aims:

  1. The margin call (with more lower MSSR) will not destroy the depth and price of DEX market like before;
  2. The shared fees (with locked time) will encourage the buyers to eat the margin call:
    The shared fees (with locked time) will not be exploited by the leveraged market of CEX any more;
    The shared fees (with locked time) will not affect the depth and price of CEX market largely;
    It can instead of MSSR largely.

@bitcrab
Copy link

bitcrab commented Apr 8, 2020

@jmjatlanta please ignore comments from @shulthz and work based on the BSIP itself.

@shulthz

This comment has been minimized.

@bitcrab

This comment has been minimized.

@shulthz

This comment has been minimized.

@shulthz

This comment has been minimized.

@MichelSantos
Copy link
Contributor

@dls-cipher @abitmore

The development of BSIP74 required extensive iterations because the original specifications were sometimes ambiguous, incomplete, or incompatible with all of the market situations and subtleties that are handled by the DEX mechanics. These high-level and low-level problems were identified through a series of development pushes which are documented in discussions during the first code pull request which continued during the creation of the second version of the specifications and continued further during the development towards the second version of the specifications.

A brief description of how margin calls are handled will provide some context of the encountered issues. Margin calls go through a two-step process that involves (1) matching a margin call against counter-offers on the order books, and (2) filling the margin call against the counter-offer. Both the matching process and filling process depends on such things as the "match price" and the "fill price". However those prices are highly dependent on other factors that were not addressed.

The development identified problems with the matching process in the original specifications:

  • the matching process was not addressed at all

  • the matching process needed to be handled differently between maker and taker margin calls because the match price is different

  • the match price also depends on the new margin call fee

The development also identified problems with the filling process in the original specifications:

All of these problems have been fully defined and subsequently developed. A new pull request will be submitted later today with the code and unit tests.

A third version of the BSIP74 specifications, which summarizes the resolved requirements, will also be submitted afterwards in a new pull request.

@abitmore
Copy link
Member

@MichelSantos thank you for the detailed info. Looking forward to the new commits.

@abitmore
Copy link
Member

Done via #2180.

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

5 participants