Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[CLOB-1017] final settlement deleveraging step in PrepareCheckState #848
[CLOB-1017] final settlement deleveraging step in PrepareCheckState #848
Changes from 16 commits
64598c8
81bd4b7
b2e6b2e
f81ad94
25bcb31
64503ff
b469e2e
01e35c2
073f8f6
16e0fd3
e37c37f
1b9d06b
22328c7
0418a25
7a52242
9bde41c
d0b741c
81b1f44
d88cdbc
e0efd39
67b63bb
136248e
795123b
17c8e3e
a42b20c
ed2192f
0b46719
1a52062
07d0b9a
7b15853
c62914f
ec22320
0171a7f
7ce548b
2bddbbe
82c56c0
6dae751
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled this onchain event out of
ProcessDeleveraging
so that we can easily set theisFinalSettlement
flag on the event. This information is not known to theProcessDeleveraging
function.This is similar to how
ProcessSingleMatch
works, the caller of the function is responsible for emitting the event instead of the event being inProcessSingleMatch
. This allows us to treat these "Process" functions solely as state-updating functions. Their callers are responsible for generating events.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is going to introduce a ton of MEV (although deleveraging is currently not included in MEV calculation IIRC), but still, we should probably iterate over these deterministically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that makes sense, can update this. Wasn't exactly sure of the types I'd be working with so just implemented the most naive approach at first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use a separate flag to limit the number of final settlement deleveraging ops? This looks through all subaccounts with open positions in the market so it's bounded right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this, but opted for re-using the flag in the interest of respecting the current performance implications of proposing deleveraging operations.
When you say this operation is bounded, what do you mean by that? In theory there is no limit to the number of subaccounts that can havae open positions in a market so it isn't bounded