Skip to content

Commit

Permalink
ack terms
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo committed Oct 16, 2024
1 parent 98b2a5b commit a64fff2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 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.28"
version = "1.12.31"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ data class VaultFormData(
val action: VaultFormAction,
val amount: Double?,
val acknowledgedSlippage: Boolean,
val acknowledgedTerms: Boolean,
val inConfirmationStep: Boolean,
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?,
Expand Down Expand Up @@ -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) {
Expand All @@ -354,6 +364,10 @@ object VaultDepositWithdrawFormValidator {
}
}

if (needTermsAck && !formData.acknowledgedTerms) {
errors.add(vaultFormValidationErrors.mustAckTerms())
}

when (formData.action) {
VaultFormAction.DEPOSIT -> {
if (postOpFreeCollateral != null && postOpFreeCollateral < 0) {
Expand Down Expand Up @@ -424,6 +438,7 @@ object VaultDepositWithdrawFormValidator {
// Prepare summary data
val summaryData = VaultFormSummaryData(
needSlippageAck = needSlippageAck,
needTermsAck = needTermsAck,
marginUsage = postOpMarginUsage,
freeCollateral = postOpFreeCollateral,
vaultBalance = postOpVaultBalance,
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.28'
spec.version = '1.12.31'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down

0 comments on commit a64fff2

Please sign in to comment.