File tree Expand file tree Collapse file tree
apps/flipcash/shared/tokens/src/main/kotlin/com/flipcash/app/tokens/ui
services/opencode/src/main/kotlin/com/getcode/opencode/model/financial Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ class BuySellSwapTokenViewModel @Inject constructor(
134134 val netTransferAmount: Fiat
135135 get() = when (purpose) {
136136 is TokenSwapPurpose .BalanceIncrease -> enteredAmount
137- else -> enteredAmount - feeAmount
137+ else -> Fiat (fiat = enteredAmount.decimalValue - feeAmount.decimalValue, currencyCode = enteredAmount.currencyCode)
138138 }
139139
140140 val transactionLimit: Fiat
@@ -473,7 +473,7 @@ class BuySellSwapTokenViewModel @Inject constructor(
473473 val amountFiat = LocalFiat .valueExchangeIn(
474474 amount = Fiat (data.amountData.amount, rate.currency),
475475 token = Token .usdf,
476- balance = stateFlow.value.reservesBalance,
476+ balance = stateFlow.value.reservesBalance.convertingToUsdIfNeeded(rate) ,
477477 rate = rate
478478 )
479479
Original file line number Diff line number Diff line change @@ -114,11 +114,10 @@ data class LocalFiat(
114114 debug : Boolean = BuildConfig .DEBUG ,
115115 trace : Boolean = true,
116116 ): LocalFiat {
117- val usdBalance = balance?.convertingToUsdIfNeeded(rate)
118117 val usdValue = amount.convertingToUsdIfNeeded(rate)
119118 // cap the entered amount as well, since our display rounds HALF_UP
120119 // e,g entered 0.02 USD, but balance is 0.016 USD
121- val cappedValue = usdBalance ?.let { min(it, usdValue) } ? : usdValue
120+ val cappedValue = balance ?.let { min(it, usdValue) } ? : usdValue
122121
123122 if (token.address == Mint .usdf) {
124123 // this doesn't need a calculated value exchange since we are USDC
@@ -155,7 +154,7 @@ data class LocalFiat(
155154 rate = rate,
156155 amount = amount,
157156 usdValue = usdValue,
158- balance = usdBalance ,
157+ balance = balance ,
159158 cappedValue = cappedValue,
160159 token = token,
161160 supply = supply,
You can’t perform that action at this time.
0 commit comments