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

Merge to main (1.0.1) #88

Merged
merged 64 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
03422e4
Update .gitignore to ignore all .idea files and all build directories…
prashanDYDX Mar 12, 2024
8206789
Turn on Gradle parallel execution and caching.
prashanDYDX Mar 13, 2024
9b4720e
Add "app_deployment" key (#21)
ruixhuang Mar 13, 2024
9a5ff0a
Initial setup of StrictMode - only logging in debug. (#22)
prashanDYDX Mar 13, 2024
bfaedb7
Use limitedParallelism and MainScope() in AbacusThreadingImp. (#25)
prashanDYDX Mar 14, 2024
6a07df2
Handle exception with invalid URLs (#26)
ruixhuang Mar 14, 2024
cf3d37a
MOB-348 Show Squid routing error on deposit/withdrawal (#28)
ruixhuang Mar 14, 2024
a6adc3b
Update AppModule.kt and used dependencies to follow Dagger Best Pract…
prashanDYDX Mar 14, 2024
948d1dd
Correlate x-request-id to correlate route requests from Squid transac…
ruixhuang Mar 14, 2024
6465dc6
Fix build (#29)
ruixhuang Mar 15, 2024
4ec10a7
MOB-362: Some url links don't work with the deployment build (#31)
ruixhuang Mar 15, 2024
fad8804
Update rest of Dagger modules to follow best practices. (#30)
prashanDYDX Mar 15, 2024
1ceea81
Remove network selector from settings for release build (#33)
ruixhuang Mar 18, 2024
885b278
MOB-363: Android: "System" theme setting not working (#32)
ruixhuang Mar 18, 2024
98b9fc9
Fix a crash on url tapping (#34)
ruixhuang Mar 19, 2024
2015769
Remove hardcoded scheme in the setting links. (#35)
ruixhuang Mar 19, 2024
102d1c8
Add Firebase Performance monitoring. (#37)
prashanDYDX Mar 19, 2024
aa3bcd6
Bump Abacus and update the system link. (#36)
ruixhuang Mar 20, 2024
14c0675
Fix the release build issue of wallet amount not showing up on deposi…
ruixhuang Mar 20, 2024
0f36547
Fix Subaccount transfer for France (#39)
ruixhuang Mar 22, 2024
c09f3a5
Clean up the start-up sequence (#41)
ruixhuang Mar 22, 2024
a158ab5
Update Cartera and WalletConnnect to the latest version (#40)
ruixhuang Mar 22, 2024
414cd03
MOB-285: Call startTrade() after setMarket() (#43)
ruixhuang Mar 22, 2024
d74f70c
Update the v4-native-client.js to replace # with ___ (#42)
ruixhuang Mar 26, 2024
8ea0afe
Move startWorkers back to Activity.onCreate() (#44)
ruixhuang Mar 26, 2024
32e3968
MOB-410 Add tracking for onboarding, transfer, wallet connection (#46)
ruixhuang Mar 29, 2024
bd5ce3e
Add link to send logcat messages via email (#45)
ruixhuang Mar 30, 2024
075f5b6
MOB-432 previous branch was based on a wrong branch (#48)
johnqh Apr 1, 2024
6d5866b
Bump Abacus (#50)
ruixhuang Apr 1, 2024
6e53a93
MOB-421 add settings control to turn in-app notifications on/off comp…
ruixhuang Apr 2, 2024
2ac0191
Feature/mob 396 position cell with margin type (#51)
johnqh Apr 3, 2024
da4c37f
Convert AbacusState flows into StateFlows. (#52)
prashanDYDX Apr 3, 2024
3921d2b
MOB-422 Withdrawal gating (#53)
ruixhuang Apr 3, 2024
c19691e
Doing the paddings better. (#56)
johnqh Apr 3, 2024
449c249
Update Android Gradle Plugin (#55)
ruixhuang Apr 3, 2024
711e4e7
MOB-446 create new add price triggers panel screen (#58)
ruixhuang Apr 4, 2024
3c7196f
MOB-443 add limit price to price triggers screen (#60)
ruixhuang Apr 5, 2024
96f1834
Feature/mob 356 trade input (#57)
johnqh Apr 5, 2024
48822ed
Feature/mob 257 weekly dates (#61)
johnqh Apr 5, 2024
de98092
Update SharingStarted usages from Lazily to WhileSubscribed(). (#62)
prashanDYDX Apr 5, 2024
0ffc8e3
Fix issue of text input losing calculated value when not focused (#64)
ruixhuang Apr 10, 2024
41f045b
Inject coroutine scopes and dispatchers instead of hardcoding. (#65)
prashanDYDX Apr 11, 2024
252e95d
Revert "Update SharingStarted usages from Lazily to WhileSubscribed()…
ruixhuang Apr 11, 2024
68c881b
Fix margin issues with portfolio position items (#67)
ruixhuang Apr 11, 2024
84036b5
Fix threading issue (#68)
ruixhuang Apr 11, 2024
d8b2274
Bump Abacus and v4-client (#69)
ruixhuang Apr 11, 2024
d97a8f7
MOB-440 TP/SL order submission and data binding (#63)
ruixhuang Apr 12, 2024
ecb0e34
Fix an issue of order/fill status display (#72)
ruixhuang Apr 12, 2024
f3c1152
Fix dollar() formatting crash in FR locale. (#74)
prashanDYDX Apr 17, 2024
808a307
Add formatting functions for size specified in double (1000.0, 0.001,…
ruixhuang Apr 19, 2024
45a118b
Fix rounding issue on leverage slider when locale is French (#75)
ruixhuang Apr 19, 2024
511c9c2
MOB-441 add TP/SL display to market screen (Android) (#71)
ruixhuang Apr 22, 2024
9572c2f
MOB-442 Support error states for TP/SL inputs (#77)
ruixhuang Apr 23, 2024
5829a09
Made localizer a computed property (#78)
ruixhuang Apr 23, 2024
0940328
MOB-455 Add retry to trade and close order submission (#76)
ruixhuang Apr 24, 2024
3f0096b
Turn on Kotlin incremental classpath snapshots. (#80)
prashanDYDX Apr 24, 2024
4f6309c
Fixing threading issues (#79)
ruixhuang Apr 24, 2024
be6f656
Feature/mob 360 target leverage (#59)
johnqh Apr 24, 2024
dcdb8f8
Fix market info's stats/about tab animation issue (#83)
ruixhuang Apr 25, 2024
7c49afa
MOB-14 Disable sparkline touching on market list (#84)
ruixhuang Apr 25, 2024
33ba783
Bump version (#81)
ruixhuang Apr 26, 2024
04852bf
Bump Abacus and add script to use locally built Abacus (#86)
ruixhuang Apr 26, 2024
2239315
Feature/mob 400 adjust margin screen (#85)
johnqh Apr 26, 2024
8c6963c
Merge branch 'develop' into features/merge_to_main
ruixhuang Apr 30, 2024
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
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

org.gradle.parallel=true
org.gradle.caching=true
# compilation avoidance for non public code changes
kotlin.incremental.useClasspathSnapshot=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
Expand Down
42 changes: 42 additions & 0 deletions scripts/build_abacus_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

# This script is used to build the abacus project locally.
#
# Please run this after making local change to the abacus project. The change will be
# picked up by the v4-native-android project (via the local maven repository). Note that
# the script needs to be run everytime a change is made to the abacus project.
#
# The script will update both the v4-abacus and v4-native-android repositories, so please make sure
# you clean-up/revert the changes after you are done with the local testing

ABACUS_DIR=~/v4-abacus
ANDROID_DIR=~/v4-native-android

# Create a random version number
NEW_VERSION="local.$(date +%s)"

# search for the first line that starts with "version" in build.gradle.kts
# get the value in the quotes
VERSION=$(grep "^version = " ${ABACUS_DIR}/build.gradle.kts | sed -n 's/version = "\(.*\)"/\1/p')

sed -i '' "s/version = \"$VERSION\"/version = \"$NEW_VERSION\"/" ${ABACUS_DIR}/build.gradle.kts
echo "Version bumped to $NEW_VERSION"

echo "Building Abacus ..."

cd ${ABACUS_DIR}
./gradlew publishToMavenLocal

cd ${ANDROID_DIR}

# get the version from the file
targetFileName="v4/build.gradle"
OLD_VERSION=$(grep "^ abacusVersion = " $targetFileName | sed -n 's/ abacusVersion = ''\(.*\)''/\1/p')

if [ -n "$NEW_VERSION" ] && [ -n "$OLD_VERSION" ]; then
echo "Bumping Abacus version from $OLD_VERSION to $NEW_VERSION"
sed -i '' "s/^ abacusVersion = $OLD_VERSION/ abacusVersion = '$NEW_VERSION'/" $targetFileName
echo "Version bumped to $NEW_VERSION"
else
echo "No version found"
fi
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencyResolutionManagement {
}
}
}
// mavenLocal()
mavenLocal()
}
}

Expand Down
2 changes: 1 addition & 1 deletion v4/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
minSdkVersion parent.minSdkVersion
targetSdkVersion parent.targetSdkVersion
versionCode 9
versionName "1.0.0"
versionName "1.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
2 changes: 1 addition & 1 deletion v4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ext {
compileSdkVersion = 34

// App dependencies
abacusVersion = '1.6.40'
abacusVersion = '1.6.46'
carteraVersion = '0.1.13'
kollectionsVersion = '2.0.16'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package exchange.dydx.trading.common.formatter

import exchange.dydx.utilities.utils.rounded
import java.math.BigDecimal
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.text.NumberFormat
import java.text.SimpleDateFormat
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import java.util.Date
import java.util.Locale
import java.util.regex.Pattern
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.abs
import kotlin.math.absoluteValue
import kotlin.math.round

@Singleton
class DydxFormatter @Inject constructor() {
Expand All @@ -37,12 +41,12 @@ class DydxFormatter @Inject constructor() {
DateTimeFormatter.ofPattern("MMM dd").withZone(ZoneOffset.UTC)
}

private val timeFormatter: SimpleDateFormat by lazy {
SimpleDateFormat("HH:mm:ss", locale)
private val timeFormatter: DateTimeFormatter by lazy {
DateTimeFormatter.ofPattern("HH:mm:ss", locale)
}

private val dateTimeFormatter: SimpleDateFormat by lazy {
SimpleDateFormat("yyyy-MM-dd HH:mm:ss", locale)
private val dateTimeFormatter: DateTimeFormatter by lazy {
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss", locale)
}

fun dollarVolume(number: Double?, digits: Int = 2): String? {
Expand Down Expand Up @@ -97,15 +101,14 @@ class DydxFormatter @Inject constructor() {
null
}
}
fun localFormatted(number: Double?, digits: Int): String? {
return localFormatted(number?.toBigDecimal(), digits)
}

fun localFormatted(number: BigDecimal?, digits: Int): String? {
fun localFormatted(number: Double?, digits: Int?): String? {
if (number != null) {
val number = if (digits != null) rounded(number, digits) else number
val decimalFormat = NumberFormat.getInstance(locale) as? DecimalFormat
decimalFormat?.minimumFractionDigits = maxOf(digits, 0)
decimalFormat?.maximumFractionDigits = maxOf(digits, 0)
if (digits != null) {
decimalFormat?.minimumFractionDigits = maxOf(digits, 0)
decimalFormat?.maximumFractionDigits = maxOf(digits, 0)
}

val formatted = decimalFormat?.format(number)
val parsed = decimalFormat?.parse(formatted)
Expand All @@ -118,39 +121,16 @@ class DydxFormatter @Inject constructor() {
return null
}

fun localFormatted(number: BigDecimal?, size: String): String? {
val digits = digits(size)
return localFormatted(number, digits)
fun dollar(number: Double?, size: Double? = null): String? {
return dollar(number = number, digits = digits(size))
}

private fun digits(size: String): Int {
val pattern = Pattern.compile("\\.(\\d+)")

val matcher = pattern.matcher(size)
if (matcher.find()) {
return matcher.group(1).length
}
return 2 // Default digits
}

fun dollar(number: Double?, size: String? = null): String? {
return dollar(number = number?.toBigDecimal(), size = size)
}

fun dollar(number: BigDecimal?, size: String? = null): String? {
return dollar(number, digits = digits(size ?: "0.01"))
}

fun dollar(number: Double?, digits: Int): String? {
return dollar(number = number?.toBigDecimal(), digits = digits)
}

fun dollar(number: BigDecimal?, digits: Int): String? {
fun dollar(number: Double?, digits: Int?): String? {
if (number == null) return null
val formattedNumber = localFormatted(number.abs(), digits)
val formattedNumber = localFormatted(abs(number), digits)
return formattedNumber?.let {
val rawDouble = raw(number.toDouble(), digits)?.toDouble() ?: 0.0
if (rawDouble >= 0.0) {
val rounded = if (digits != null && digits >= 0) number.rounded(toPlaces = digits) else number
if (rounded >= 0) {
"$$it"
} else {
"-$$it"
Expand All @@ -159,10 +139,6 @@ class DydxFormatter @Inject constructor() {
}

fun percent(number: Double?, digits: Int, minDigits: Int? = null): String? {
return percent(number = number?.toBigDecimal(), digits = digits, minDigits = minDigits)
}

fun percent(number: BigDecimal?, digits: Int, minDigits: Int? = null): String? {
if (number != null) {
percentFormatter.minimumFractionDigits = minDigits ?: digits
percentFormatter.maximumFractionDigits = digits
Expand Down Expand Up @@ -233,17 +209,19 @@ class DydxFormatter @Inject constructor() {
}
}

fun dateTime(time: Instant?): String? {
fun dateTime(time: Instant?, timeZone: ZoneId = ZoneId.systemDefault()): String? {
return if (time != null) {
dateTimeFormatter.format(Date.from(time))
val ldt: LocalDateTime = time.atZone(timeZone).toLocalDateTime()
dateTimeFormatter.format(ldt)
} else {
null
}
}

fun clock(time: Instant?): String? {
fun clock(time: Instant?, timeZone: ZoneId = ZoneId.systemDefault()): String? {
return if (time != null) {
timeFormatter.format(Date.from(time))
val ldt: LocalDateTime = time.atZone(timeZone).toLocalDateTime()
timeFormatter.format(ldt)
} else {
null
}
Expand All @@ -264,39 +242,104 @@ class DydxFormatter @Inject constructor() {
}
}

/*
xxxxx.yyyyy

Will take the number and round it to the closest step size
e.g. if number is 1021 and step size is "100" then output is "1000"
*/
fun decimalLocaleAgnostic(number: Double?, size: Double? = null): String? {
return raw(number = number, size = size, locale = Locale.US)
}

/*
xxxxx.yyyyy

*/
fun decimalLocaleAgnostic(number: Double?, digits: Int): String? {
fun decimalLocaleAgnostic(number: Double?, digits: Int?): String? {
return raw(number = number, digits = digits, locale = Locale.US)
}

/*
xxxxxx,yyyyy or xxxxx.yyyyy

Will take the number and round it to the closest step size
e.g. if number is 1021 and step size is "100" then output is "1000"
*/
fun raw(number: Double?, size: Double? = null, locale: Locale? = null): String? {
val digits = digits(size)
return raw(number = number, digits = digits, locale = locale ?: this.locale)
}

/*
xxxxxx,yyyyy or xxxxx.yyyyy
*/
fun raw(number: Double?, digits: Int? = null, locale: Locale = Locale.getDefault()): String? {
fun raw(number: Double?, digits: Int?, locale: Locale = Locale.getDefault()): String? {
return number?.let { value ->
if (value.isFinite()) {
if (digits != null) {
val rounded = rounded(value, digits)
val rawFormatter = DecimalFormat.getInstance(locale).apply {
minimumFractionDigits = maxOf(digits, 0)
maximumFractionDigits = maxOf(digits, 0)
roundingMode = RoundingMode.HALF_UP
isGroupingUsed = false
}
val formatted = rawFormatter.format(number)
val formatted = rawFormatter.format(rounded)
val number = rawFormatter.parse(formatted)
if (number.toDouble() == 0.0) { // handle -0.0
rawFormatter.format(0.0)
} else {
formatted
}
} else {
BigDecimal(number).toPlainString()
number.toString()
}
} else {
"∞"
}
}
}

private fun rounded(number: Double, digits: Int): Double {
if (digits >= 0) {
return number
} else {
val reversed = digits * -1
val divideBy = Math.pow(10.0, reversed.toDouble() - 1)
return round(number / divideBy).toInt() * divideBy
}
}

/*
Returns the number of digits for a given size specified in the format of 10^(-x)
e.g.
0.001 -> 3,
0.1 -> 1,
1 -> 0,
10 -> -1
1000 -> -3
*/
private fun digits(size: Double?): Int? {
if (size == null || size <= 0.0) return null

var size = size
if (size >= 1) {
var count = 0
while (size >= 1) {
count++
size /= 10
}
return count * -1
} else if (size <= 0.1) {
var count = 0
while (size <= 0.1) {
count++
size *= 10
}
return count
} else {
return null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ object TradeRoutes {
const val margin_type = "trade/margin_type"
const val target_leverage = "trade/target_leverage"
const val trigger = "trade/take_profit_stop_loss"
const val adjust_margin = "trade/adjust_margin"
}

object TransferRoutes {
Expand Down
Loading
Loading