From d1204b178dc69b2c68d927fb6745ea1e9252dc56 Mon Sep 17 00:00:00 2001 From: tyleroooo Date: Wed, 25 Sep 2024 17:43:37 -0400 Subject: [PATCH] Revert "fix: vaults submission types match better" (#677) --- build.gradle.kts | 2 +- .../vault/VaultDepositWithdrawForm.kt | 19 +++++++------------ .../functional/vault/VaultFormTests.kt | 7 +++---- v4_abacus.podspec | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 19d1c3fa1..727667bc6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.11.20" +version = "1.11.21" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt index f8df2e489..c4bcdb407 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt @@ -1,6 +1,5 @@ package exchange.dydx.abacus.functional.vault -import com.ionspin.kotlin.bignum.decimal.toBigDecimal import exchange.dydx.abacus.output.input.ErrorFormat import exchange.dydx.abacus.output.input.ErrorParam import exchange.dydx.abacus.output.input.ErrorResources @@ -166,15 +165,15 @@ data class VaultDepositWithdrawSubmissionData( @Serializable data class VaultDepositData( val subaccountFrom: String, - val quoteQuantums: String + val amount: Double ) @JsExport @Serializable data class VaultWithdrawData( val subaccountTo: String, - val shares: String, - val minQuoteQuantums: String, + val shares: Double, + val minAmount: Double ) @JsExport @@ -202,9 +201,7 @@ object VaultDepositWithdrawFormValidator { private const val SLIPPAGE_PERCENT_WARN = 0.01 private const val SLIPPAGE_PERCENT_ACK = 0.04 - private const val EXTRA_SLIPPAGE_TOLERANCE = 0.01 - - private const val QUANTUMS_MULTIPLIER = 1_000_000 + private const val SLIPPAGE_TOLERANCE = 0.01 fun getVaultDepositWithdrawSlippageResponse(apiResponse: String): VaultDepositWithdrawSlippageResponse? { return parser.asTypedObject(apiResponse) @@ -334,7 +331,7 @@ object VaultDepositWithdrawFormValidator { VaultFormAction.DEPOSIT -> VaultDepositWithdrawSubmissionData( deposit = VaultDepositData( subaccountFrom = "0", - quoteQuantums = amount.toBigDecimal().times(QUANTUMS_MULTIPLIER).toBigInteger().toString(), + amount = amount, ), withdraw = null, ) @@ -343,10 +340,8 @@ object VaultDepositWithdrawFormValidator { withdraw = if (sharesToAttemptWithdraw != null && sharesToAttemptWithdraw > 0 && slippageResponse != null) { VaultWithdrawData( subaccountTo = "0", - shares = sharesToAttemptWithdraw.toBigDecimal().toBigInteger().toString(), - minQuoteQuantums = (slippageResponse.expectedAmount * (1 - EXTRA_SLIPPAGE_TOLERANCE)).toBigDecimal().times( - QUANTUMS_MULTIPLIER, - ).toBigInteger().toString(), + shares = sharesToAttemptWithdraw, + minAmount = slippageResponse.expectedAmount * (1 - SLIPPAGE_TOLERANCE), ) } else { null diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt index 96045c275..6380c2694 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt @@ -1,6 +1,5 @@ package exchange.dydx.abacus.functional.vault -import com.ionspin.kotlin.bignum.decimal.toBigDecimal import exchange.dydx.abacus.output.input.ValidationError import kollections.iListOf import kollections.toIList @@ -49,7 +48,7 @@ class VaultFormTests { submissionData = VaultDepositWithdrawSubmissionData( deposit = VaultDepositData( subaccountFrom = "0", - quoteQuantums = "100000000", + amount = 100.0, ), withdraw = null, ), @@ -100,8 +99,8 @@ class VaultFormTests { deposit = null, withdraw = VaultWithdrawData( subaccountTo = "0", - shares = "100", - minQuoteQuantums = (98 * .99).toBigDecimal().times(1000000).toBigInteger().toString(), + shares = 100.0, + minAmount = 98 * .99, ), ), summaryData = VaultFormSummaryData( diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 0935cb300..141225b20 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.11.20' + spec.version = '1.11.21' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''