-
Notifications
You must be signed in to change notification settings - Fork 125
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
remove branched context for OI calculation #1674
Conversation
WalkthroughThe recent changes in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Keeper
User ->> Keeper: Request subaccount update
Keeper ->> Keeper: Calculate new collateralization
Keeper ->> Keeper: Calculate new margin requirements
Keeper ->> User: Return updated subaccount status
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
// Get the new collateralization and margin requirements with the update applied. | ||
bigNewNetCollateral, | ||
bigNewInitialMargin, | ||
bigNewMaintenanceMargin, | ||
err := k.internalGetNetCollateralAndMarginRequirements( | ||
branchedContext, | ||
ctx, |
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 handling errors more gracefully in internalGetNetCollateralAndMarginRequirements
.
The current implementation directly returns nil
values for all outputs in case of an error. This might lead to misleading zero values being interpreted as valid data. It would be safer to return explicit error values or handle errors more gracefully to avoid misinterpretations.
Refactor suggestion for internalCanUpdateSubaccounts
.
The function internalCanUpdateSubaccounts
is quite complex and handles multiple responsibilities. Consider breaking it down into smaller, more focused functions. This could improve readability, maintainability, and ease of testing.
Optimize calculations in GetNetCollateralAndMarginRequirements
.
The function GetNetCollateralAndMarginRequirements
performs multiple calculations that could be optimized. Consider caching results of frequently computed values, especially those that do not change often, to reduce computational overhead.
Improve error handling in applyUpdatesToPositions
.
The function applyUpdatesToPositions
could improve its error handling by providing more detailed error messages and possibly suggesting resolutions. This would help developers understand and resolve conflicts more effectively.
Superceeded by #1691 |
Changelist
Remove use of branched context for OI calculation. This is a breaking optimization
Summary by CodeRabbit