From a64fff29129eac0ee3d2fe1c3073f41274d666df Mon Sep 17 00:00:00 2001 From: Tyler Date: Wed, 16 Oct 2024 14:08:50 -0400 Subject: [PATCH] ack terms --- build.gradle.kts | 2 +- .../functional/vault/VaultDepositWithdrawForm.kt | 15 +++++++++++++++ v4_abacus.podspec | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f824b3693..15d9adf5c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.12.28" +version = "1.12.31" 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 a4defabe7..0d0e1936c 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt @@ -24,6 +24,7 @@ data class VaultFormData( val action: VaultFormAction, val amount: Double?, val acknowledgedSlippage: Boolean, + val acknowledgedTerms: Boolean, val inConfirmationStep: Boolean, ) @@ -164,6 +165,13 @@ internal class VaultFormValidationErrors( titleKey = "APP.VAULTS.ACKNOWLEDGE_HIGH_SLIPPAGE", ) + fun mustAckTerms() = createError( + code = "MUST_ACK_TERMS", + type = ErrorType.error, + fields = listOf("acknowledgeTerms"), + titleKey = "APP.VAULTS.ACKNOWLEDGE_MEGAVAULT_TERMS", + ) + fun vaultAccountMissing() = createError( code = "VAULT_ACCOUNT_MISSING", type = ErrorType.error, @@ -206,6 +214,7 @@ data class VaultWithdrawData( @Serializable data class VaultFormSummaryData( val needSlippageAck: Boolean?, + val needTermsAck: Boolean?, val marginUsage: Double?, val freeCollateral: Double?, val vaultBalance: Double?, @@ -328,6 +337,7 @@ object VaultDepositWithdrawFormValidator { 0.0 } val needSlippageAck = slippagePercent >= SLIPPAGE_PERCENT_ACK && formData.inConfirmationStep + val needTermsAck = formData.action == VaultFormAction.DEPOSIT && formData.inConfirmationStep // Perform validation checks and populate errors list if (accountData == null) { @@ -354,6 +364,10 @@ object VaultDepositWithdrawFormValidator { } } + if (needTermsAck && !formData.acknowledgedTerms) { + errors.add(vaultFormValidationErrors.mustAckTerms()) + } + when (formData.action) { VaultFormAction.DEPOSIT -> { if (postOpFreeCollateral != null && postOpFreeCollateral < 0) { @@ -424,6 +438,7 @@ object VaultDepositWithdrawFormValidator { // Prepare summary data val summaryData = VaultFormSummaryData( needSlippageAck = needSlippageAck, + needTermsAck = needTermsAck, marginUsage = postOpMarginUsage, freeCollateral = postOpFreeCollateral, vaultBalance = postOpVaultBalance, diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 0ef587c71..a20fa3785 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.12.28' + spec.version = '1.12.31' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''