diff --git a/build.gradle.kts b/build.gradle.kts index 3932e939d..19d1c3fa1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.11.19" +version = "1.11.20" 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 c4bcdb407..f8df2e489 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt @@ -1,5 +1,6 @@ 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 @@ -165,15 +166,15 @@ data class VaultDepositWithdrawSubmissionData( @Serializable data class VaultDepositData( val subaccountFrom: String, - val amount: Double + val quoteQuantums: String ) @JsExport @Serializable data class VaultWithdrawData( val subaccountTo: String, - val shares: Double, - val minAmount: Double + val shares: String, + val minQuoteQuantums: String, ) @JsExport @@ -201,7 +202,9 @@ object VaultDepositWithdrawFormValidator { private const val SLIPPAGE_PERCENT_WARN = 0.01 private const val SLIPPAGE_PERCENT_ACK = 0.04 - private const val SLIPPAGE_TOLERANCE = 0.01 + private const val EXTRA_SLIPPAGE_TOLERANCE = 0.01 + + private const val QUANTUMS_MULTIPLIER = 1_000_000 fun getVaultDepositWithdrawSlippageResponse(apiResponse: String): VaultDepositWithdrawSlippageResponse? { return parser.asTypedObject(apiResponse) @@ -331,7 +334,7 @@ object VaultDepositWithdrawFormValidator { VaultFormAction.DEPOSIT -> VaultDepositWithdrawSubmissionData( deposit = VaultDepositData( subaccountFrom = "0", - amount = amount, + quoteQuantums = amount.toBigDecimal().times(QUANTUMS_MULTIPLIER).toBigInteger().toString(), ), withdraw = null, ) @@ -340,8 +343,10 @@ object VaultDepositWithdrawFormValidator { withdraw = if (sharesToAttemptWithdraw != null && sharesToAttemptWithdraw > 0 && slippageResponse != null) { VaultWithdrawData( subaccountTo = "0", - shares = sharesToAttemptWithdraw, - minAmount = slippageResponse.expectedAmount * (1 - SLIPPAGE_TOLERANCE), + shares = sharesToAttemptWithdraw.toBigDecimal().toBigInteger().toString(), + minQuoteQuantums = (slippageResponse.expectedAmount * (1 - EXTRA_SLIPPAGE_TOLERANCE)).toBigDecimal().times( + QUANTUMS_MULTIPLIER, + ).toBigInteger().toString(), ) } 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 6380c2694..96045c275 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt @@ -1,5 +1,6 @@ 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 @@ -48,7 +49,7 @@ class VaultFormTests { submissionData = VaultDepositWithdrawSubmissionData( deposit = VaultDepositData( subaccountFrom = "0", - amount = 100.0, + quoteQuantums = "100000000", ), withdraw = null, ), @@ -99,8 +100,8 @@ class VaultFormTests { deposit = null, withdraw = VaultWithdrawData( subaccountTo = "0", - shares = 100.0, - minAmount = 98 * .99, + shares = "100", + minQuoteQuantums = (98 * .99).toBigDecimal().times(1000000).toBigInteger().toString(), ), ), summaryData = VaultFormSummaryData( diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 1fa8ca28e..0935cb300 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.19' + spec.version = '1.11.20' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''