diff --git a/CHANGELOG.md b/CHANGELOG.md index 9234eb72..9bd34524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- changed: Standardize DEX quotes to 5% slippage and estimate quote + ## 2.4.3 (2024-06-03) - added: (Exolix) Add Piratechain diff --git a/src/swap/defi/lifi.ts b/src/swap/defi/lifi.ts index 8bbe2d64..09ce9522 100644 --- a/src/swap/defi/lifi.ts +++ b/src/swap/defi/lifi.ts @@ -45,8 +45,8 @@ const asInitOptions = asObject({ integrator: asOptional(asString, 'edgeapp') }) -/** Allow up to 20% slippage even for variable rate quotes */ -const MAX_SLIPPAGE = '0.2' +/** Allow up to 5% slippage even for variable rate quotes */ +const MAX_SLIPPAGE = '0.05' const LIFI_SERVERS_DEFAULT = ['https://li.quest'] const EXPIRATION_MS = 1000 * 60 const EXCHANGE_INFO_UPDATE_FREQ_MS = 60000 diff --git a/src/swap/defi/thorchain.ts b/src/swap/defi/thorchain.ts index c1edb37b..e66bebce 100644 --- a/src/swap/defi/thorchain.ts +++ b/src/swap/defi/thorchain.ts @@ -854,7 +854,8 @@ const calcSwapFrom = async ({ total_swap_seconds: maxFulfillmentSeconds } = bestQuote - const canBePartial = streamingSwapBlocks > 1 + const canBePartial = !isEstimate || streamingSwapBlocks > 1 + let toThorAmountWithSpread: string if (canBePartial) { log(`volatilitySpreadStreamingFinal: ${volatilitySpreadStreamingFinal}`) @@ -984,7 +985,9 @@ const calcSwapTo = async ({ total_swap_seconds: maxFulfillmentSeconds } = bestQuote - const canBePartial = streamingSwapBlocks > 1 + // If we get a streaming quote, this should be considered a fully executing + // transaction since we don't put a slippage limit + const canBePartial = !isEstimate || streamingSwapBlocks > 1 // Get the percent drop from the 'to' amount the user wanted compared to the // 'to' amount returned by the API. Add that percent to the 'from' amount to diff --git a/src/swap/defi/thorchainDa.ts b/src/swap/defi/thorchainDa.ts index 8c9f6cbe..b909456e 100644 --- a/src/swap/defi/thorchainDa.ts +++ b/src/swap/defi/thorchainDa.ts @@ -97,8 +97,8 @@ const asThorSwapQuoteResponse = asObject({ routes: asArray(asThorSwapRoute) }) -/** Max slippage for 20% for estimated quotes */ -const DA_VOLATILITY_SPREAD_DEFAULT = 0.2 +/** Max slippage for 5% for estimated quotes */ +const DA_VOLATILITY_SPREAD_DEFAULT = 0.05 const THORSWAP_DEFAULT_SERVERS = ['https://api.thorswap.net/aggregator'] type ExchangeInfo = ReturnType diff --git a/src/swap/defi/uni-v2-based/plugins/spookySwap.ts b/src/swap/defi/uni-v2-based/plugins/spookySwap.ts index 5b2157ae..e6d0fcb2 100644 --- a/src/swap/defi/uni-v2-based/plugins/spookySwap.ts +++ b/src/swap/defi/uni-v2-based/plugins/spookySwap.ts @@ -168,7 +168,7 @@ export function makeSpookySwapPlugin( savedAction: { actionType: 'swap', swapInfo, - isEstimate: false, + isEstimate: true, toAsset: { pluginId: request.toWallet.currencyInfo.pluginId, tokenId: request.toTokenId, diff --git a/src/swap/defi/uni-v2-based/plugins/tombSwap.ts b/src/swap/defi/uni-v2-based/plugins/tombSwap.ts index 4ebdff6f..38ce4c64 100644 --- a/src/swap/defi/uni-v2-based/plugins/tombSwap.ts +++ b/src/swap/defi/uni-v2-based/plugins/tombSwap.ts @@ -168,7 +168,7 @@ export function makeTombSwapPlugin( savedAction: { actionType: 'swap', swapInfo, - isEstimate: false, + isEstimate: true, toAsset: { pluginId: request.toWallet.currencyInfo.pluginId, tokenId: request.toTokenId, diff --git a/src/swap/defi/uni-v2-based/plugins/velodrome.ts b/src/swap/defi/uni-v2-based/plugins/velodrome.ts index 09a59694..d9bfeaf9 100644 --- a/src/swap/defi/uni-v2-based/plugins/velodrome.ts +++ b/src/swap/defi/uni-v2-based/plugins/velodrome.ts @@ -215,7 +215,7 @@ export function makeVelodromePlugin( savedAction: { actionType: 'swap', swapInfo, - isEstimate: false, + isEstimate: true, toAsset: { pluginId: request.toWallet.currencyInfo.pluginId, tokenId: request.toTokenId, @@ -267,7 +267,7 @@ export function makeVelodromePlugin( savedAction: { actionType: 'swap', swapInfo, - isEstimate: false, + isEstimate: true, toAsset: { pluginId: request.toWallet.currencyInfo.pluginId, tokenId: request.toTokenId,