Skip to content

Commit

Permalink
fix roundings
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed Oct 22, 2024
1 parent 1940f01 commit 9c956e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dydx/dydxFormatter/dydxFormatter/dydxFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public final class dydxFormatter: NSObject, SingletonProtocol {
let postfix = ["", "K", "M", "B", "T"]
var value = number.decimalValue
var index = 0
while value > 1000.0 && index < (postfix.count - 1) {
while value.magnitude > 1000.0 && index < (postfix.count - 1) {
value = value / 1000.0
index += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private class dydxVaultViewBuilderPresenter: HostedViewPresenter<dydxVaultViewMo
viewModel?.totalValueLocked = vault?.details?.totalValue?.doubleValue
viewModel?.thirtyDayReturnPercent = vault?.details?.thirtyDayReturnPercent?.doubleValue
viewModel?.vaultBalance = vault?.account?.balanceUsdc?.doubleValue
viewModel?.allTimeReturnUsdc = vault?.account?.allTimeReturnUsdc?.doubleValue
viewModel?.allTimeReturnUsdc = vault?.account?.allTimeReturnUsdc?.doubleValue.round(to: 2)

viewModel?.positions = vault?.positions?.positions?.map { (position) -> dydxVaultPositionViewModel? in
guard let leverage = position.currentLeverageMultiple?.doubleValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class dydxVaultPositionViewModel: PlatformViewModel {
}

fileprivate var notionalValueText: String {
let size = dydxFormatter.shared.condensedDollar(number: notionalValue) ?? "--"
let equity = dydxFormatter.shared.condensedDollar(number: equity) ?? "--"
let size = dydxFormatter.shared.condensedDollar(number: notionalValue, digits: 0) ?? "--"
let equity = dydxFormatter.shared.condensedDollar(number: equity, digits: 0) ?? "--"
return "\(size) / \(equity)"
}

Expand All @@ -55,7 +55,7 @@ public class dydxVaultPositionViewModel: PlatformViewModel {
}

fileprivate var pnlAmountText: String {
dydxFormatter.shared.dollar(number: pnlAmount, digits: 0) ?? "--"
dydxFormatter.shared.condensedDollar(number: pnlAmount, digits: 2) ?? "--"
}

fileprivate var pnlPercentageText: String {
Expand Down

0 comments on commit 9c956e8

Please sign in to comment.