Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: vaults submission types match better" #677

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.11.20"
version = "1.11.21"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<VaultDepositWithdrawSlippageResponse>(apiResponse)
Expand Down Expand Up @@ -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,
)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,7 +48,7 @@ class VaultFormTests {
submissionData = VaultDepositWithdrawSubmissionData(
deposit = VaultDepositData(
subaccountFrom = "0",
quoteQuantums = "100000000",
amount = 100.0,
),
withdraw = null,
),
Expand Down Expand Up @@ -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(
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.11.20'
spec.version = '1.11.21'
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down