diff --git a/src/functions/generateRoute.ts b/src/functions/generateRoute.ts index 6b7d6851..1a2c6c2e 100644 --- a/src/functions/generateRoute.ts +++ b/src/functions/generateRoute.ts @@ -124,7 +124,8 @@ export const useSoroswapApi = () => { tradeType: TradeType.EXACT_INPUT, trade: { amountIn: BigInt(amountAsset.value), - amountOutMin: BigInt(quoteAmount.toString()), + amountOutMin: BigInt(quoteAmount.toString()), // fixme: this should count the slippage + expectedAmountOut: BigInt(quoteAmount.toString()), path: [amountAsset.currency.contract, quoteAsset.contract], }, } @@ -139,7 +140,8 @@ export const useSoroswapApi = () => { tradeType: TradeType.EXACT_OUTPUT, trade: { amountOut: BigInt(amount), - amountInMax: BigInt(quoteAmount.toString()), + expectedAmountIn: BigInt(quoteAmount.toString()), + amountInMax: BigInt(quoteAmount.toString()), // fixme: this should count the slippage path: [quoteAsset.contract, amountAsset.currency.contract], }, }; diff --git a/src/helpers/horizon/getHorizonPath.ts b/src/helpers/horizon/getHorizonPath.ts index 879e7a42..4c5c6052 100644 --- a/src/helpers/horizon/getHorizonPath.ts +++ b/src/helpers/horizon/getHorizonPath.ts @@ -180,6 +180,7 @@ export const parseHorizonResult = async ( trade: { amountIn: BigInt(inputAmount.value), amountOutMin: BigInt(outputAmount.value), + expectedAmountOut: BigInt(outputAmount.value), path: formattedPath, }, } @@ -194,6 +195,7 @@ export const parseHorizonResult = async ( tradeType: TradeType.EXACT_OUTPUT, trade: { amountOut: BigInt(outputAmount.value), + expectedAmountIn: BigInt(inputAmount.value), amountInMax: BigInt(inputAmount.value), path: formattedPath, }, diff --git a/src/hooks/useBestTrade.ts b/src/hooks/useBestTrade.ts index 42b7e8dd..dabb4e39 100644 --- a/src/hooks/useBestTrade.ts +++ b/src/hooks/useBestTrade.ts @@ -92,6 +92,7 @@ export function useBestTrade( if (!data || !currencyIn || !currencyOut) return; if (tradeType === TradeType.EXACT_INPUT) { const result = (data as ExactInBuildTradeReturn | ExactInSplitBuildTradeReturn).trade; + setInputAmount({ value: result?.amountIn.toString(), @@ -99,11 +100,11 @@ export function useBestTrade( }); setOutputAmount({ - value: result?.amountOutMin.toString(), + value: result?.expectedAmountOut.toString(), currency: currencyOut, }); - setExpectedAmount(result?.amountOutMin.toString()); + setExpectedAmount(result?.expectedAmountOut.toString()); } if (tradeType === TradeType.EXACT_OUTPUT) { diff --git a/src/state/routing/types.ts b/src/state/routing/types.ts index ed308777..c2880ad1 100644 --- a/src/state/routing/types.ts +++ b/src/state/routing/types.ts @@ -77,6 +77,7 @@ export interface ExactInBuildTradeReturn extends CommonBuildTradeReturnFields { tradeType: TradeType.EXACT_INPUT; trade: { amountIn: bigint; + expectedAmountOut: bigint; amountOutMin: bigint; path: string[]; }; @@ -86,6 +87,7 @@ export interface ExactOutBuildTradeReturn extends CommonBuildTradeReturnFields { tradeType: TradeType.EXACT_OUTPUT; trade: { amountOut: bigint; + expectedAmountIn: bigint; amountInMax: bigint; path: string[]; }; @@ -95,6 +97,7 @@ export interface ExactInSplitBuildTradeReturn extends CommonBuildTradeReturnFiel tradeType: TradeType.EXACT_INPUT; trade: { amountIn: bigint; + expectedAmountOut: bigint; amountOutMin: bigint; distribution: DexDistribution[]; }; @@ -104,6 +107,7 @@ export interface ExactOutSplitBuildTradeReturn extends CommonBuildTradeReturnFie tradeType: TradeType.EXACT_OUTPUT; trade: { amountOut: bigint; + expectedAmountIn: bigint; amountInMax: bigint; distribution: DexDistribution[]; };