From 1eeb1e7645e7dac8620465090242f73fc48bf663 Mon Sep 17 00:00:00 2001 From: aminsato Date: Sat, 30 Nov 2024 15:42:10 +0330 Subject: [PATCH] Add a max slippage of 0.5% --- .../main/kotlin/com/vultisig/wallet/data/api/MayaChainApi.kt | 2 ++ .../main/kotlin/com/vultisig/wallet/data/api/ThorChainApi.kt | 2 ++ .../com/vultisig/wallet/data/chains/helpers/THORChainSwaps.kt | 1 + 3 files changed, 5 insertions(+) diff --git a/data/src/main/kotlin/com/vultisig/wallet/data/api/MayaChainApi.kt b/data/src/main/kotlin/com/vultisig/wallet/data/api/MayaChainApi.kt index 8bf0c6f63..629214cce 100644 --- a/data/src/main/kotlin/com/vultisig/wallet/data/api/MayaChainApi.kt +++ b/data/src/main/kotlin/com/vultisig/wallet/data/api/MayaChainApi.kt @@ -9,6 +9,7 @@ import com.vultisig.wallet.data.api.models.cosmos.CosmosTransactionBroadcastResp import com.vultisig.wallet.data.api.models.cosmos.THORChainAccountResultJson import com.vultisig.wallet.data.api.models.cosmos.THORChainAccountValue import com.vultisig.wallet.data.chains.helpers.THORChainSwaps +import com.vultisig.wallet.data.chains.helpers.THORChainSwaps.Companion.TOLERANCE_BPS import io.ktor.client.HttpClient import io.ktor.client.call.body import io.ktor.client.request.get @@ -75,6 +76,7 @@ internal class MayaChainApiImp @Inject constructor( parameter("amount", amount) parameter("destination", address) parameter("streaming_interval", interval) + parameter("tolerance_bps", TOLERANCE_BPS) if (isAffiliate) { parameter("affiliate", THORChainSwaps.AFFILIATE_FEE_ADDRESS) parameter("affiliate_bps", THORChainSwaps.AFFILIATE_FEE_RATE) diff --git a/data/src/main/kotlin/com/vultisig/wallet/data/api/ThorChainApi.kt b/data/src/main/kotlin/com/vultisig/wallet/data/api/ThorChainApi.kt index d9c2b64f7..e213f273f 100644 --- a/data/src/main/kotlin/com/vultisig/wallet/data/api/ThorChainApi.kt +++ b/data/src/main/kotlin/com/vultisig/wallet/data/api/ThorChainApi.kt @@ -9,6 +9,7 @@ import com.vultisig.wallet.data.api.models.cosmos.NativeTxFeeRune import com.vultisig.wallet.data.api.models.cosmos.THORChainAccountResultJson import com.vultisig.wallet.data.api.models.cosmos.THORChainAccountValue import com.vultisig.wallet.data.chains.helpers.THORChainSwaps +import com.vultisig.wallet.data.chains.helpers.THORChainSwaps.Companion.TOLERANCE_BPS import com.vultisig.wallet.data.common.Endpoints import com.vultisig.wallet.data.utils.ThorChainSwapQuoteResponseJsonSerializer import io.ktor.client.HttpClient @@ -99,6 +100,7 @@ internal class ThorChainApiImpl @Inject constructor( parameter("amount", amount) parameter("destination", address) parameter("streaming_interval", interval) + parameter("tolerance_bps", TOLERANCE_BPS) if (isAffiliate) { parameter("affiliate", THORChainSwaps.AFFILIATE_FEE_ADDRESS) parameter("affiliate_bps", THORChainSwaps.AFFILIATE_FEE_RATE) diff --git a/data/src/main/kotlin/com/vultisig/wallet/data/chains/helpers/THORChainSwaps.kt b/data/src/main/kotlin/com/vultisig/wallet/data/chains/helpers/THORChainSwaps.kt index 6cb414aed..b3c3fd8d6 100644 --- a/data/src/main/kotlin/com/vultisig/wallet/data/chains/helpers/THORChainSwaps.kt +++ b/data/src/main/kotlin/com/vultisig/wallet/data/chains/helpers/THORChainSwaps.kt @@ -22,6 +22,7 @@ class THORChainSwaps( companion object { const val AFFILIATE_FEE_ADDRESS = "va" const val AFFILIATE_FEE_RATE = "50" // 50 BP + const val TOLERANCE_BPS = "50" } private fun getPreSignedInputData(