Skip to content

Commit

Permalink
Fix issue of gas token not setting after validator is reconnected (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang authored Oct 1, 2024
1 parent 8c2c7a5 commit e13a869
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.12.9"
version = "1.12.10"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ data class VaultAccount(
val vaultTransfers: IList<VaultTransfer>?,
val totalVaultTransfersCount: Int?,
val vaultShareUnlocks: IList<VaultShareUnlock>?,
)
) {
val shareValue: Double?
get() =
if (balanceShares != null && balanceUsdc != null && balanceShares > 0) {
balanceUsdc / balanceShares
} else {
null
}
}

@JsExport
@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,11 @@ object VaultDepositWithdrawFormValidator {
vaultAccount: VaultAccount?,
amount: Double
): Double {
if (vaultAccount?.balanceUsdc == null || vaultAccount.balanceUsdc == 0.0 ||
vaultAccount.balanceShares == null || vaultAccount.balanceShares == 0.0
) {
val shareValue = vaultAccount?.shareValue ?: 0.0
if (shareValue == 0.0) {
return 0.0
}
return (amount / (vaultAccount.balanceUsdc / vaultAccount.balanceShares)).toLong().toDouble()
return (amount / shareValue).toLong().toDouble()
}

fun validateVaultForm(
Expand All @@ -236,11 +235,7 @@ object VaultDepositWithdrawFormValidator {
// Calculate post-operation values and slippage
val amount = formData.amount ?: 0.0

val shareValue = if (vaultAccount?.balanceUsdc != null && vaultAccount.balanceShares != null && vaultAccount.balanceShares > 0) {
vaultAccount.balanceUsdc / vaultAccount.balanceShares
} else {
null
}
val shareValue = vaultAccount?.shareValue
val sharesToAttemptWithdraw = if (amount > 0 && shareValue != null && shareValue > 0) {
// shares must be whole numbers
floor(amount / shareValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ class AsyncAbacusStateManagerV2(
dataNotification = dataNotification,
presentationProtocol = presentationProtocol,
)
adaptor?.gasToken = gasToken
pushNotificationToken?.let { token ->
adaptor?.registerPushNotification(token, pushNotificationLanguageCode)
}
Expand Down
2 changes: 1 addition & 1 deletion v4_abacus.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'v4_abacus'
spec.version = '1.12.9'
spec.version = '1.12.10'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down

0 comments on commit e13a869

Please sign in to comment.