Skip to content

Commit

Permalink
display usd value for withdraw flow [OTE-783] (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam authored Sep 12, 2024
1 parent 1b9234a commit 28240c4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ internal class TransferInputCalculator(val parser: ParserProtocol) {
val toAmountUSDC = parser.asDouble(parser.value(transfer, "route.toAmountUSDC"))
summary.safeSet("toAmountUSDC", toAmountUSDC)

val toAmountUSD = parser.asDouble(parser.value(transfer, "route.toAmountUSD"))
summary.safeSet("toAmountUSD", toAmountUSD)

val aggregatePriceImpact =
parser.asDouble(parser.value(transfer, "route.aggregatePriceImpact"))
summary.safeSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ internal class TransferInputCalculatorV2(
val toAmount = parser.asDouble(parser.value(route, "toAmount"))
val toAmountMin = parser.asDouble(parser.value(route, "toAmountMin"))
val toAmountUSDC = parser.asDouble(parser.value(route, "toAmountUSDC"))
val toAmountUSD = parser.asDouble(parser.value(route, "toAmountUSD"))
var aggregatePriceImpact = parser.asDouble(parser.value(route, "aggregatePriceImpact"))
aggregatePriceImpact = if (aggregatePriceImpact != null) aggregatePriceImpact / 100.0 else null

Expand All @@ -80,6 +81,7 @@ internal class TransferInputCalculatorV2(
toAmount = toAmount,
toAmountMin = toAmountMin,
toAmountUSDC = toAmountUSDC,
toAmountUSD = toAmountUSD,
aggregatePriceImpact = aggregatePriceImpact,
)
}
Expand All @@ -98,6 +100,7 @@ internal class TransferInputCalculatorV2(
val toAmount = parser.asDouble(parser.value(route, "toAmount"))
val toAmountMin = parser.asDouble(parser.value(route, "toAmountMin"))
val toAmountUSDC = parser.asDouble(parser.value(route, "toAmountUSDC"))
val toAmountUSD = parser.asDouble(parser.value(route, "toAmountUSD"))
var aggregatePriceImpact = parser.asDouble(parser.value(route, "aggregatePriceImpact"))
aggregatePriceImpact = if (aggregatePriceImpact != null) aggregatePriceImpact / 100.0 else null

Expand All @@ -113,6 +116,7 @@ internal class TransferInputCalculatorV2(
toAmount = toAmount,
toAmountMin = toAmountMin,
toAmountUSDC = toAmountUSDC,
toAmountUSD = toAmountUSD,
aggregatePriceImpact = aggregatePriceImpact,
)
}
Expand All @@ -132,6 +136,7 @@ internal class TransferInputCalculatorV2(
toAmount = null,
toAmountMin = null,
toAmountUSDC = null,
toAmountUSD = null,
aggregatePriceImpact = null,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ data class TransferInputSummary(
val toAmount: Double?,
val toAmountMin: Double?,
val toAmountUSDC: Double?,
val toAmountUSD: Double?,
val aggregatePriceImpact: Double?,
) {
companion object {
Expand All @@ -382,6 +383,7 @@ data class TransferInputSummary(
val toAmount = parser.asDouble(data["toAmount"])
val toAmountMin = parser.asDouble(data["toAmountMin"])
val toAmountUSDC = parser.asDouble(data["toAmountUSDC"])
val toAmountUSD = parser.asDouble(data["toAmountUSD"])
val aggregatePriceImpact = parser.asDouble(data["aggregatePriceImpact"])

return if (existing?.usdcSize != usdcSize ||
Expand All @@ -395,6 +397,7 @@ data class TransferInputSummary(
existing.toAmount != toAmount ||
existing.toAmountMin != toAmountMin ||
existing.toAmountUSDC != toAmountUSDC ||
existing.toAmountUSD != toAmountUSD ||
existing.aggregatePriceImpact != aggregatePriceImpact
) {
TransferInputSummary(
Expand All @@ -409,6 +412,7 @@ data class TransferInputSummary(
toAmount,
toAmountMin,
toAmountUSDC,
toAmountUSD,
aggregatePriceImpact,
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ internal fun TransferInputSummary.Companion.safeCreate(existing: TransferInputSu
toAmount = null,
toAmountMin = null,
toAmountUSDC = null,
toAmountUSD = null,
aggregatePriceImpact = null,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package exchange.dydx.abacus.calculator.v2

class TransferInputCalculatorV2Tests

0 comments on commit 28240c4

Please sign in to comment.