From 33d28f732ef218bd07f3892d24afc02fbfcca42b Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 3 Oct 2024 10:15:25 -0400 Subject: [PATCH 1/7] fix needSlippageAck --- .../functional/vault/VaultDepositWithdrawForm.kt | 2 +- .../exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 c3f44d299..83f1ce382 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt @@ -301,7 +301,7 @@ object VaultDepositWithdrawFormValidator { } else { 0.0 } - val needSlippageAck = slippagePercent >= SLIPPAGE_PERCENT_ACK && formData.inConfirmationStep + val needSlippageAck = slippagePercent >= SLIPPAGE_PERCENT_ACK && formData.inConfirmationStep && !formData.acknowledgedSlippage // Perform validation checks and populate errors list if (accountData == null) { diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt index 1b6f9b696..999e19bb6 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt @@ -35,7 +35,7 @@ internal class VaultSupervisor( } companion object { - private const val POLLING_DURATION = 60.0 + private const val POLLING_DURATION = 20.0 private const val MEGAVAULT_MODULE_ADDRESS = "dydx18tkxrnrkqc2t0lr3zxr5g6a4hdvqksylxqje4r" } From 7ff82f2eaae41a58b7fb20feff776d05e4f87f4d Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 3 Oct 2024 10:16:38 -0400 Subject: [PATCH 2/7] Update build.gradle.kts --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index d8e8fcf99..c751a9c6c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.12.16" +version = "1.12.17" repositories { google() From ac35aa6994fe2a037368ed10cb4b61cb6a4c7812 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 3 Oct 2024 10:16:41 -0400 Subject: [PATCH 3/7] Update v4_abacus.podspec --- v4_abacus.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 2deb0e99c..94ed7973e 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.16' + spec.version = '1.12.17' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = '' From 6582f9cb6fd7eed26482e9dee86832902deed3b6 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 3 Oct 2024 11:03:47 -0400 Subject: [PATCH 4/7] Update VaultDepositWithdrawForm.kt --- .../functional/vault/VaultDepositWithdrawForm.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 83f1ce382..c3f44d299 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/functional/vault/VaultDepositWithdrawForm.kt @@ -301,7 +301,7 @@ object VaultDepositWithdrawFormValidator { } else { 0.0 } - val needSlippageAck = slippagePercent >= SLIPPAGE_PERCENT_ACK && formData.inConfirmationStep && !formData.acknowledgedSlippage + val needSlippageAck = slippagePercent >= SLIPPAGE_PERCENT_ACK && formData.inConfirmationStep // Perform validation checks and populate errors list if (accountData == null) { From 625cbe6fc91c50f616f927d28f75896ca862cbb9 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 3 Oct 2024 11:38:46 -0400 Subject: [PATCH 5/7] added test --- .../functional/vault/VaultFormTests.kt | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) 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 5106e004c..5516fc108 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt @@ -271,4 +271,56 @@ class VaultFormTests { result, ) } + + @Test + fun testValidHighSlippageWithdraw() { + val result = VaultDepositWithdrawFormValidator.validateVaultForm( + formData = VaultFormData( + action = VaultFormAction.WITHDRAW, + amount = 500.0, + acknowledgedSlippage = true, + inConfirmationStep = true, + ), + accountData = VaultFormAccountData( + marginUsage = 0.5, + freeCollateral = 1000.0, + canViewAccount = true, + ), + vaultAccount = makeVaultAccount( + balanceUsdc = 500.0, + withdrawableUsdc = 500.0, + balanceShares = 500.0, + ), + slippageResponse = OnChainVaultDepositWithdrawSlippageResponse( + sharesToWithdraw = OnChainNumShares(numShares = 500.0), + expectedQuoteQuantums = 400.0 * 1_000_000, + ), + ) + + assertEquals( + VaultFormValidationResult( + errors = iListOf( + VaultFormValidationErrors().slippageTooHigh(0.1999), + ), + submissionData = VaultDepositWithdrawSubmissionData( + deposit=null, + withdraw=VaultWithdrawData( + subaccountTo = "0", + shares =500.0, + minAmount = 396.0 + ) + ), + summaryData = VaultFormSummaryData( + needSlippageAck = true, + marginUsage = 0.41666666666666663, + freeCollateral = 1400.0, + vaultBalance = 0.0, + withdrawableVaultBalance = 0.0, + estimatedSlippage = 0.19999999999999996, + estimatedAmountReceived = 400.0, + ), + ), + result, + ) + } } From 75cf8d88a3e21aec66c822ff10edaa914891ad80 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 3 Oct 2024 12:07:27 -0400 Subject: [PATCH 6/7] formatting --- .../functional/vault/VaultFormTests.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 5516fc108..b4eb876b3 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/functional/vault/VaultFormTests.kt @@ -273,7 +273,7 @@ class VaultFormTests { } @Test - fun testValidHighSlippageWithdraw() { + fun testValidHighSlippageWithdrawWithAck() { val result = VaultDepositWithdrawFormValidator.validateVaultForm( formData = VaultFormData( action = VaultFormAction.WITHDRAW, @@ -303,12 +303,12 @@ class VaultFormTests { VaultFormValidationErrors().slippageTooHigh(0.1999), ), submissionData = VaultDepositWithdrawSubmissionData( - deposit=null, - withdraw=VaultWithdrawData( + deposit = null, + withdraw = VaultWithdrawData( subaccountTo = "0", - shares =500.0, - minAmount = 396.0 - ) + shares = 500.0, + minAmount = 396.0, + ), ), summaryData = VaultFormSummaryData( needSlippageAck = true, From 4950cef8bb412a8b68ea58a79e66f5b36c161a90 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 3 Oct 2024 12:40:01 -0400 Subject: [PATCH 7/7] refresh indexer data as well for transfers --- .../exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt index 999e19bb6..8c93bdf9d 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/VaultSupervisor.kt @@ -58,7 +58,9 @@ internal class VaultSupervisor( fun refreshVaultAccount() { if (accountAddress != null && validatorConnected) { stopPollingValidatorData() + stopPollingIndexerData() startPollingValidatorData(accountAddress) + startPollingIndexerData(accountAddress) } }