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

BUG2-179 Fix UI display of token name in trade screens. #308

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class dydxClosePositionInputEditViewPresenter: HostedViewPresenter<dydxClosePosi
} else {
sizeViewModel.usdcSize = nil
}
sizeViewModel.tokenSymbol = asset?.id ?? configsAndAsset?.assetId
sizeViewModel.tokenSymbol = asset?.displayableAssetId ?? configsAndAsset?.assetId
visible.append(sizeViewModel)

if parser.asNumber(percentViewModel.value)?.doubleValue != closePositionInput.size?.percent?.doubleValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,13 @@ private class dydxTakeProfitStopLossViewPresenter: HostedViewPresenter<dydxTakeP
}
.store(in: &subscriptions)

AbacusStateManager.shared.state.market(of: marketId)
.compactMap { $0 }
.sink { [weak self] market in
self?.update(market: market)
Publishers
.CombineLatest(
AbacusStateManager.shared.state.market(of: marketId).compactMap { $0 },
AbacusStateManager.shared.state.configsAndAssetMap
)
.sink { [weak self] market, configsMap in
self?.update(market: market, configsMap: configsMap)
}
.store(in: &subscriptions)

Expand Down Expand Up @@ -250,12 +253,13 @@ private class dydxTakeProfitStopLossViewPresenter: HostedViewPresenter<dydxTakeP
}
}

private func update(market: PerpetualMarket?) {
viewModel?.oraclePrice = dydxFormatter.shared.dollar(number: market?.oraclePrice?.doubleValue, digits: market?.configs?.displayTickSizeDecimals?.intValue ?? 2)
viewModel?.customAmountViewModel?.sliderTextInput.accessoryTitle = market?.assetId
viewModel?.customAmountViewModel?.sliderTextInput.minValue = market?.configs?.minOrderSize?.doubleValue.magnitude ?? 0
private func update(market: PerpetualMarket, configsMap: [String: MarketConfigsAndAsset]) {
let configs = configsMap[market.id]
viewModel?.oraclePrice = dydxFormatter.shared.dollar(number: market.oraclePrice?.doubleValue, digits: market.configs?.displayTickSizeDecimals?.intValue ?? 2)
viewModel?.customAmountViewModel?.sliderTextInput.accessoryTitle = configs?.asset?.displayableAssetId
viewModel?.customAmountViewModel?.sliderTextInput.minValue = market.configs?.minOrderSize?.doubleValue.magnitude ?? 0
// abacus stepSizeDecimals is not accurate for 10/100/1000 precision
if let stepSize = market?.configs?.stepSize?.doubleValue, stepSize > 0 {
if let stepSize = market.configs?.stepSize?.doubleValue, stepSize > 0 {
viewModel?.customAmountViewModel?.sliderTextInput.numberFormatter.fractionDigits = Int(-log10(stepSize))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ internal class dydxTradeInputEditViewPresenter: HostedViewPresenter<dydxTradeInp
} else {
sizeViewModel.usdcSize = nil
}
sizeViewModel.tokenSymbol = asset?.id ?? configsAndAsset?.assetId
sizeViewModel.tokenSymbol = configsAndAsset?.asset?.displayableAssetId ?? asset?.id
visible.append(sizeViewModel)

if tradeInput.options?.needsLeverage ?? false {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private class dydxTradeStatusViewPresenter: HostedViewPresenter<dydxTradeStatusV
if let size = tradeInput.summary?.size {
viewModel?.orderViewModel.size = dydxFormatter.shared.localFormatted(number: size, digits: configs?.stepSizeDecimals?.intValue ?? 1)
}
if let token = asset?.id ?? configsAndAsset?.assetId {
if let token = asset?.displayableAssetId ?? configsAndAsset?.assetId {
viewModel?.orderViewModel.token?.symbol = token
}

Expand Down Expand Up @@ -236,7 +236,7 @@ private class dydxTradeStatusViewPresenter: HostedViewPresenter<dydxTradeStatusV

viewModel?.orderViewModel.type = DataLocalizer.localize(path: "APP.GENERAL.MARKET")
viewModel?.orderViewModel.size = dydxFormatter.shared.localFormatted(number: closePositionInput.summary?.size, digits: configs?.stepSizeDecimals?.intValue ?? 1)
if let token = asset?.id ?? configsAndAsset?.assetId {
if let token = asset?.displayableAssetId ?? configsAndAsset?.assetId {
viewModel?.orderViewModel.token?.symbol = token
}
viewModel?.orderViewModel.date = submissionDate
Expand Down
Loading