Skip to content

Commit d24ac22

Browse files
committed
chore(opencode): allow constructing a LocalFiat without an explicit rate
infer it from native and usdc amounts Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 728279d commit d24ac22

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • services/opencode/src/main/kotlin/com/getcode/opencode/model/financial

services/opencode/src/main/kotlin/com/getcode/opencode/model/financial/LocalFiat.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ data class LocalFiat(
2222
),
2323
)
2424

25+
constructor(usdc: Fiat, converted: Fiat): this(
26+
usdc = usdc,
27+
converted = converted,
28+
rate = Rate(
29+
fx = converted.decimalValue / usdc.decimalValue,
30+
currency = converted.currencyCode
31+
)
32+
)
33+
2534
companion object {
2635
val Zero = LocalFiat(
2736
usdc = Fiat(0),

0 commit comments

Comments
 (0)