Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed Jun 11, 2024
1 parent fb05ab2 commit 47931a2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
20 changes: 19 additions & 1 deletion dydx/dydx.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "3cd7346cace16cf660f9c22302c5ca6770335c67902f3fd155011356a9d43929",
"originHash" : "975d00e29efb8d2ca017c5e61df90418ac01f7d7143e85a3f9ddb4eb982154e4",
"pins" : [
{
"identity" : "bigint",
Expand Down Expand Up @@ -37,6 +37,15 @@
"version" : "2.0.2"
}
},
{
"identity" : "keyboardobserving",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nickffox/KeyboardObserving",
"state" : {
"branch" : "master",
"revision" : "48134b5460435cc9d048223ad7560ee2e40f3d4a"
}
},
{
"identity" : "percy-xcui-swift",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -181,6 +190,15 @@
"version" : "9.0.9"
}
},
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
"state" : {
"revision" : "121c146fe591b1320238d054ae35c81ffa45f45a",
"version" : "0.12.0"
}
},
{
"identity" : "wallet-mobile-sdk",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
}
}

viewModel.amount?.placeHolder = "0.00"
viewModel.amount?.placeHolder = dydxFormatter.shared.dollar(number: 0.0, digits: 2)

self.viewModel = viewModel

Expand All @@ -116,7 +116,10 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
.sink { [weak self] market, assetMap, input in
self?.updateState(market: market, assetMap: assetMap)
self?.updateFields(input: input)
self?.updateCalculatedValues(input: input, market: market)
self?.updateAmountLabel(input: input)
self?.updatePrePostValues(input: input)
self?.updateLiquidationPrice(input: input, market: market)
self?.updateButtonState(input: input)
}
.store(in: &subscriptions)
}
Expand All @@ -126,7 +129,7 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
viewModel?.sharedMarketViewModel = SharedMarketPresenter.createViewModel(market: market, asset: asset)
}

private func updateCalculatedValues(input: AdjustIsolatedMarginInput, market: PerpetualMarket) {
private func updateAmountLabel(input: AdjustIsolatedMarginInput) {
switch input.type {
case IsolatedMarginAdjustmentType.add:
viewModel?.amount?.label = DataLocalizer.localize(path: "APP.GENERAL.AMOUNT_TO_ADD")
Expand All @@ -135,7 +138,9 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
default:
viewModel?.amount?.label = DataLocalizer.localize(path: "APP.GENERAL.AMOUNT")
}
}

private func updatePrePostValues(input: AdjustIsolatedMarginInput) {
var crossFreeCollateralBefore: AmountTextModel?
var crossFreeCollateralAfter: AmountTextModel?
var crossMarginUsageBefore: AmountTextModel?
Expand Down Expand Up @@ -181,7 +186,9 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
viewModel?.positionReceipt?.leverage = AmountChangeModel(
before: positionLeverageBefore,
after: positionLeverageAfter)
}

private func updateLiquidationPrice(input: AdjustIsolatedMarginInput, market: PerpetualMarket) {
if let displayTickSizeDecimals = market.configs?.displayTickSizeDecimals?.intValue {
let before = input.summary?.liquidationPrice
// the non-zero check here is a band-aid for an abacus bug where there is a pre- and post- state even on empty input
Expand All @@ -202,7 +209,9 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
viewModel?.liquidationPrice?.direction = .none
}
}
}

private func updateButtonState(input: AdjustIsolatedMarginInput) {
if parser.asNumber(input.amount)?.doubleValue ?? 0 > 0 {
self.ctaButtonPresenter.viewModel?.ctaButtonState = .enabled()
} else {
Expand Down

0 comments on commit 47931a2

Please sign in to comment.