Skip to content

Commit

Permalink
fix: min vault deposit/withdraw amount (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo authored Oct 31, 2024
1 parent dd5ec64 commit 4aa54b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ object VaultDepositWithdrawFormValidator {
private const val SLIPPAGE_TOLERANCE = 0.01
private const val EPSILON_FOR_ERRORS = 0.0001

private const val MIN_DEPOSIT_FE_THRESHOLD = 20.0
private const val MIN_DEPOSIT_FE_THRESHOLD = 5.0

fun getVaultDepositWithdrawSlippageResponse(apiResponse: String): OnChainVaultDepositWithdrawSlippageResponse? {
return parser.asTypedObject<OnChainVaultDepositWithdrawSlippageResponse>(apiResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class VaultFormTests {
val result = VaultDepositWithdrawFormValidator.validateVaultForm(
formData = VaultFormData(
action = VaultFormAction.DEPOSIT,
amount = 10.0,
amount = 4.0,
acknowledgedSlippage = false,
acknowledgedTerms = false,
inConfirmationStep = false,
Expand All @@ -358,10 +358,10 @@ class VaultFormTests {
summaryData = VaultFormSummaryData(
needSlippageAck = false,
needTermsAck = false,
marginUsage = 0.5025125628140703,
freeCollateral = 990.0,
vaultBalance = 1010.0,
withdrawableVaultBalance = 510.0,
marginUsage = 0.5010020040080161,
freeCollateral = 996.0,
vaultBalance = 1004.0,
withdrawableVaultBalance = 504.0,
estimatedSlippage = 0.0,
estimatedAmountReceived = null,
),
Expand Down Expand Up @@ -420,7 +420,7 @@ class VaultFormTests {
val result = VaultDepositWithdrawFormValidator.validateVaultForm(
formData = VaultFormData(
action = VaultFormAction.WITHDRAW,
amount = 10.0,
amount = 4.0,
acknowledgedSlippage = false,
acknowledgedTerms = false,
inConfirmationStep = false,
Expand All @@ -436,8 +436,8 @@ class VaultFormTests {
balanceShares = 500.0,
),
slippageResponse = OnChainVaultDepositWithdrawSlippageResponse(
sharesToWithdraw = OnChainNumShares(numShares = 5.0),
expectedQuoteQuantums = 10.0 * 1_000_000,
sharesToWithdraw = OnChainNumShares(numShares = 2.0),
expectedQuoteQuantums = 4.0 * 1_000_000,
),
)

Expand All @@ -450,12 +450,12 @@ class VaultFormTests {
summaryData = VaultFormSummaryData(
needSlippageAck = false,
needTermsAck = false,
marginUsage = 0.49751243781094523,
freeCollateral = 1010.0,
vaultBalance = 990.0,
withdrawableVaultBalance = 490.0,
marginUsage = 0.499001996007984,
freeCollateral = 1004.0,
vaultBalance = 996.0,
withdrawableVaultBalance = 496.0,
estimatedSlippage = 0.0,
estimatedAmountReceived = 10.0,
estimatedAmountReceived = 4.0,
),
),
result,
Expand Down Expand Up @@ -519,7 +519,7 @@ class VaultFormTests {
val result = VaultDepositWithdrawFormValidator.validateVaultForm(
formData = VaultFormData(
action = VaultFormAction.WITHDRAW,
amount = 6.0,
amount = 4.0,
acknowledgedSlippage = false,
acknowledgedTerms = false,
inConfirmationStep = false,
Expand All @@ -535,8 +535,8 @@ class VaultFormTests {
balanceShares = 500.0,
),
slippageResponse = OnChainVaultDepositWithdrawSlippageResponse(
sharesToWithdraw = OnChainNumShares(numShares = 3.0),
expectedQuoteQuantums = 6.0 * 1_000_000,
sharesToWithdraw = OnChainNumShares(numShares = 2.0),
expectedQuoteQuantums = 4.0 * 1_000_000,
),
)

Expand All @@ -549,12 +549,12 @@ class VaultFormTests {
summaryData = VaultFormSummaryData(
needSlippageAck = false,
needTermsAck = false,
marginUsage = 0.4985044865403788,
freeCollateral = 1006.0,
vaultBalance = 994.0,
withdrawableVaultBalance = 4.0,
marginUsage = 0.499001996007984,
freeCollateral = 1004.0,
vaultBalance = 996.0,
withdrawableVaultBalance = 6.0,
estimatedSlippage = 0.0,
estimatedAmountReceived = 6.0,
estimatedAmountReceived = 4.0,
),
),
result,
Expand Down

0 comments on commit 4aa54b2

Please sign in to comment.