diff --git a/packages/swapper/src/swappers/JupiterSwapper/swapperApi/getTradeQuote.ts b/packages/swapper/src/swappers/JupiterSwapper/swapperApi/getTradeQuote.ts index 9489f9847b5..826fb49e7a0 100644 --- a/packages/swapper/src/swappers/JupiterSwapper/swapperApi/getTradeQuote.ts +++ b/packages/swapper/src/swappers/JupiterSwapper/swapperApi/getTradeQuote.ts @@ -239,6 +239,7 @@ export const getTradeQuote = async ( affiliateBps, receiveAddress, slippageTolerancePercentageDecimal, + priceImpactPercentageDecimal: priceResponse.priceImpactPct, steps: [ { accountNumber, diff --git a/packages/swapper/src/swappers/JupiterSwapper/swapperApi/getTradeRate.ts b/packages/swapper/src/swappers/JupiterSwapper/swapperApi/getTradeRate.ts index 4cb194ea393..163b5d803f6 100644 --- a/packages/swapper/src/swappers/JupiterSwapper/swapperApi/getTradeRate.ts +++ b/packages/swapper/src/swappers/JupiterSwapper/swapperApi/getTradeRate.ts @@ -223,6 +223,7 @@ export const getTradeRate = async ( receiveAddress, potentialAffiliateBps: affiliateBps, affiliateBps, + priceImpactPercentageDecimal: priceResponse.priceImpactPct, slippageTolerancePercentageDecimal, steps: [ { diff --git a/packages/swapper/src/types.ts b/packages/swapper/src/types.ts index 54a671ea53f..7a7d902c432 100644 --- a/packages/swapper/src/types.ts +++ b/packages/swapper/src/types.ts @@ -310,6 +310,7 @@ type TradeQuoteBase = { potentialAffiliateBps: string // even if the swapper does not support affiliateBps, we need to zero-them out or view-layer will be borked affiliateBps: string // even if the swapper does not support affiliateBps, we need to zero-them out or view-layer will be borked isStreaming?: boolean + priceImpactPercentageDecimal?: string slippageTolerancePercentageDecimal: string | undefined // undefined if slippage limit is not provided or specified by the swapper isLongtail?: boolean quoteOrRate: 'quote' | 'rate' diff --git a/src/components/MultiHopTrade/hooks/quoteValidation/usePriceImpact.tsx b/src/components/MultiHopTrade/hooks/quoteValidation/usePriceImpact.tsx index 123ae7d2c1e..15d066fc10c 100644 --- a/src/components/MultiHopTrade/hooks/quoteValidation/usePriceImpact.tsx +++ b/src/components/MultiHopTrade/hooks/quoteValidation/usePriceImpact.tsx @@ -41,6 +41,10 @@ export const usePriceImpact = (tradeQuote: TradeQuote | TradeRate | undefined) = const priceImpactPercentage = useMemo(() => { if (!tradeQuote || !buyAsset || !buyAssetUsdRate || !sellAmountBeforeFeesUsd) return + if (tradeQuote.priceImpactPercentageDecimal) { + return bnOrZero(tradeQuote.priceImpactPercentageDecimal).times(100).abs() + } + // price impact calculation must use buyAmountBeforeFees because it relates to the liquidity in // the pool rather than a rate of input versus output