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: fix isolated pnl transfer calc #664

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

moo-onthelawn
Copy link
Contributor

@moo-onthelawn moo-onthelawn commented Sep 19, 2024

noticed a bug when testing this feature - isolated margin percent inputs looked wrong esp when the amount was high - realized it was cuz the collateral transfer calculation was wrong - we need to include the isolatedPnlImpact in the balance used

(for some reason when I build locally now it keeps telling the testnet chain is halted? I tried with building a local abacus with no change but an extra space and it still said halted so assuming this is not related)

fix.mov

@moo-onthelawn moo-onthelawn marked this pull request as ready for review September 19, 2024 19:56
OrderSide.Buy -> entryPrice - (oraclePrice ?: entryPrice)
OrderSide.Sell -> (oraclePrice ?: entryPrice) - entryPrice
}
val pnlImpact = (diff * balance * tradeLeverage) / (entryPrice + diff * tradeLeverage)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check for dividing by zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha i alwayyyys forget this huh

ruixhuang
ruixhuang previously approved these changes Sep 19, 2024
@moo-onthelawn moo-onthelawn merged commit 8f66f3c into main Sep 19, 2024
3 checks passed
@moo-onthelawn moo-onthelawn deleted the mulan-fixIsolatedPnlCalcsAgain branch September 19, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants