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

fix: lavy period when opened position #508

Merged
merged 1 commit into from
Apr 28, 2023
Merged

Conversation

Senna46
Copy link
Contributor

@Senna46 Senna46 commented Apr 27, 2023

Part of #499

Set LastLeviedAt time when opening a position.
Fix function ReportLevyPeriodPerpetualFuturesPosition corrected errors in position size evaluation.

@Senna46 Senna46 requested review from mkXultra and taiki1frsh April 27, 2023 02:59

imaginaryFundingRate := sdk.NewDecFromInt(netPosition).Mul(params.PerpetualFutures.ImaginaryFundingRateProportionalCoefficient)
imaginaryFundingRate := netPosition.Mul(params.PerpetualFutures.ImaginaryFundingRateProportionalCoefficient)
imaginaryFundingFee := sdk.NewDecFromInt(position.RemainingMargin.Amount).Mul(imaginaryFundingRate).RoundInt()
commissionFee := sdk.NewDecFromInt(position.RemainingMargin.Amount).Mul(params.PerpetualFutures.CommissionRate).RoundInt()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes seem reasonable. The addition of LastLeviedAt field will keep track of the time of the last levy, which can be useful in various scenarios. The calculation of netPosition and imaginaryFundingRate also seems correct, and the use of sdk.MustNewDecFromStr for converting OneMillionString to sdk.Dec is a good practice. However, one improvement could be to add some inline comments or documentation explaining the purpose of the code blocks and the variables being used.

@Senna46 Senna46 merged commit b49a25d into newDevelop Apr 28, 2023
@Senna46 Senna46 deleted the fix/lavy-period-temp branch April 28, 2023 09:36
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

Successfully merging this pull request may close these issues.

2 participants