Skip to content

Commit

Permalink
fix custom amount issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed May 2, 2024
1 parent 16cbdeb commit 475cca7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ private class dydxTakeProfitStopLossViewPresenter: HostedViewPresenter<dydxTakeP
viewModel?.takeProfitStopLossInputAreaViewModel?.lossInputViewModel?.set(value: formattedStopLossUsdcDiff, forUnit: .dollars)
viewModel?.takeProfitStopLossInputAreaViewModel?.lossInputViewModel?.set(value: formattedStopLossUsdcPercentage, forUnit: .percentage)

// logic primarily to pre-populate custom amount. need to account 3 situations: 1 take profit order or 1 stop loss order or both
if let customSize = triggerOrdersInput?.size?.doubleValue.magnitude, customSize != position?.size?.current?.doubleValue.magnitude {
// logic primarily to pre-populate custom amount.
// we do not want to turn on custom amount if it is not already on and the order size is the same amount as the position size. The custom amount may already be on if user manually turned it on, or a pre-existing custom amount exists that is less than the position size
if let customSize = triggerOrdersInput?.size?.doubleValue.magnitude, customSize != position?.size?.current?.doubleValue.magnitude || viewModel?.customAmountViewModel?.isOn == true {
let formattedSize = dydxFormatter.shared.raw(number: customSize, digits: marketConfig.displayStepSizeDecimals?.intValue ?? 2)
viewModel?.customAmountViewModel?.programmaticallySet(newValue: formattedSize)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Utilities

public class dydxCustomAmountViewModel: PlatformTextInputViewModel {

@Published private var isOn: Bool = false
@Published private (set) public var isOn: Bool = false
@Published public var toggleAction: ((Bool) -> Void)?

@Published public var assetId: String? {
Expand Down

0 comments on commit 475cca7

Please sign in to comment.