-
Notifications
You must be signed in to change notification settings - Fork 16
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
Refactor open interest and oi shares reduction #120
Conversation
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.
Consider removing oiTotalOnSide
and oiTotalSharesOnSide
from the function parameters and fetching these values with:
uint256 oiTotalOnSide = pos.isLong ? oiLong : oiShort;
uint256 oiTotalSharesOnSide = pos.isLong ? oiLongShares : oiShortShares;
or can be made with:
if (pos.isLong) {
oiLong = oiLong.subFloor(
pos.oiCurrent(fraction, oiLong, oiLongShares)
);
oiLongShares -= pos.oiSharesCurrent(fraction);
} else {
oiShort = oiShort.subFloor(
pos.oiCurrent(fraction, oiShort, oiShortShares)
);
oiShortShares -= pos.oiSharesCurrent(fraction);
}
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.
pending tests
Used brownie test for this PR since its a refactor and not a new feature. |
The merge-base changed after approval.
liquidate()
andunwind()
functions share a considerable amount of code. This PR creates an internal function to avoid these duplicates. Thanks Uncle Bob.Merge after #133