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

handle short position case for displaying liquidation price, live-update position row items #205

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

mike-dydx
Copy link
Collaborator

@mike-dydx mike-dydx commented Jul 1, 2024

Links (dYdX Internal Use Only)

Linear Ticket:

Figma Design: https://www.figma.com/design/mKevZOfE9nj6MZpiolKYW1/dYdX-%E2%80%BA-Mobile?node-id=5956-16570&t=H5PO3Em25YfPWYom-4


Description / Intuition

  • always show liq price for short positions
  • remove caching of position row items (was causing issue for swiftui not detecting view element diffs)
  • add width % to git PR template

Before/After Screenshots or Videos

Before After
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-07-01.at.12.27.31.mp4

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring or Technical Debt
  • Documentation update
  • Other (please describe: )

@mike-dydx mike-dydx changed the title handle short position case for displaying liquidation price handle short position case for displaying liquidation price, live-update position row items Jul 1, 2024
let currentLeverage = input.summary?.positionLeverage?.doubleValue ?? 0
let postLeverage = input.summary?.positionLeverageUpdated?.doubleValue ?? 0

viewModel?.liquidationPrice = dydxAdjustMarginLiquidationPriceViewModel()

if input.summary?.positionLeverageUpdated == nil {
let hasNoInput = input.summary?.positionLeverageUpdated == nil
Copy link
Contributor

Choose a reason for hiding this comment

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

i've seen positionLeverageUpdated sometimes be a weird value. on android i'm just checking input.amount == nil

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if input.amount is "0" though or "000" etc, i wanted to avoid that

viewModel?.liquidationPrice?.direction = .none
if currentLeverage <= 1 {
if currentLeverage <= 1 && side == Abacus.PositionSide.long_ {
Copy link
Contributor

@prashanDYDX prashanDYDX Jul 1, 2024

Choose a reason for hiding this comment

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

up to you on whether you want to simplify this if else - on Android i didn't end up doing any complex checks on leverage or side. i just used hasNoInput and liquidation price directly. if it is nil, it's because there is no liquidation price (leverage <= 1 and long).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How did u decide to display "None" or not then?

@mike-dydx mike-dydx merged commit 841d781 into develop Jul 1, 2024
2 checks passed
@mike-dydx mike-dydx deleted the mike/1.5.0-bugs branch July 1, 2024 17:30
mike-dydx added a commit that referenced this pull request Aug 20, 2024
…ate position row items (#205)

* handle short position case for displaying liquidation price

* remove viewmodel caching
mike-dydx added a commit that referenced this pull request Aug 21, 2024
…ate position row items (#205)

* handle short position case for displaying liquidation price

* remove viewmodel caching
mike-dydx added a commit that referenced this pull request Aug 21, 2024
…ate position row items (#205)

* handle short position case for displaying liquidation price

* remove viewmodel caching
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