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

[derivatives] Adding limit order and stop order #441

Open
kimurayu45z opened this issue Mar 16, 2023 · 0 comments
Open

[derivatives] Adding limit order and stop order #441

kimurayu45z opened this issue Mar 16, 2023 · 0 comments

Comments

@kimurayu45z
Copy link
Contributor

kimurayu45z commented Mar 16, 2023

enum ReservationType {
  UNKNOWN = 0;
  OVER_THRESHOLD = 1;
  UNDER_THRESHOLD = 2;
}

message MsgReserveOpenPosition {
  msg MsgOpenPosition = 1;
  ReservationType reservation_type = 2;
  string threshold_rate = 3; // sdk.Dec
}

message MsgReserveClosePosition {
  msg MsgClosePosition = 1;
  ReservationType reservation_type = 2;
  string threshold_rate = 3; // sdk.Dec
}

Architecture

  • Just preserve reservations in DB when Msgs are executed
    • Sort reservations by threshold_rate for each market.
      • OverReservations
      • UnderReservations
  • In every EndBlock handler, iterate sorted reservations.
    • If the oracle price crosses over the threshold_rate, execute the contained MsgOpenPosition or MsgClosePosition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant