diff --git a/packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts b/packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts index 70550b27d74..dd1458eb4e9 100644 --- a/packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts +++ b/packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts @@ -373,7 +373,7 @@ export const thorchainApi: SwapperApi = { } const latestOutTx = data.out_txs?.[data.out_txs.length - 1] - const hasOutboundTx = latestOutTx?.chain !== 'THOR' + const hasOutboundTx = latestOutTx !== undefined && latestOutTx.chain !== 'THOR' const buyTxHash = parseThorBuyTxHash(txHash, latestOutTx) @@ -386,6 +386,7 @@ export const thorchainApi: SwapperApi = { ) if (outboundTxConfirmations !== undefined && outboundTxConfirmations > 0) { + console.log({ outboundTxConfirmations, hasOutboundTx, buyTxHash }) return { buyTxHash, status: TxStatus.Confirmed, @@ -396,6 +397,8 @@ export const thorchainApi: SwapperApi = { const { message, status } = getLatestThorTxStatusMessage(data, hasOutboundTx) + console.log({ message, status }) + return { buyTxHash, status, diff --git a/packages/swapper/src/swappers/ThorchainSwapper/utils/getLatestThorTxStatusMessage.ts b/packages/swapper/src/swappers/ThorchainSwapper/utils/getLatestThorTxStatusMessage.ts index e47e4c99b8f..6e540f6b49f 100644 --- a/packages/swapper/src/swappers/ThorchainSwapper/utils/getLatestThorTxStatusMessage.ts +++ b/packages/swapper/src/swappers/ThorchainSwapper/utils/getLatestThorTxStatusMessage.ts @@ -61,7 +61,10 @@ export const getLatestThorTxStatusMessage = ( } } - return { message: obj.pending ? 'Swap pending' : 'Swap complete', status: TxStatus.Pending } + return { + message: obj.pending ? 'Swap pending' : 'Swap complete, awaiting finalization', + status: TxStatus.Pending, + } } case 'swap_finalised': { const obj = response.stages[key] @@ -69,7 +72,7 @@ export const getLatestThorTxStatusMessage = ( if (!hasOutboundTx && obj.completed) { return { - message: 'Swap finalized', + message: 'Swap finalized, awaiting transaction confirmation', status: TxStatus.Confirmed, } } diff --git a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/StreamingSwap.tsx b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/StreamingSwap.tsx index 5112be1351b..05d30593848 100644 --- a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/StreamingSwap.tsx +++ b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/StreamingSwap.tsx @@ -26,7 +26,7 @@ export const StreamingSwap = (props: StreamingSwapProps) => { {translate('trade.streamStatus')} {totalSwapCount > 0 && ( - {`${attemptedSwapCount} of ${totalSwapCount}`} + {`${attemptedSwapCount - failedSwaps.length} of ${totalSwapCount}`} )} @@ -36,7 +36,7 @@ export const StreamingSwap = (props: StreamingSwapProps) => { size='sm' min={0} max={totalSwapCount} - value={attemptedSwapCount} + value={attemptedSwapCount - failedSwaps.length} hasStripe={!isComplete} isAnimated={!isComplete} colorScheme={isComplete ? 'green' : 'blue'} diff --git a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/hooks/useThorStreamingProgress.tsx b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/hooks/useThorStreamingProgress.tsx index bf8ef51bdc0..d9c7c260322 100644 --- a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/hooks/useThorStreamingProgress.tsx +++ b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/hooks/useThorStreamingProgress.tsx @@ -153,9 +153,11 @@ export const useThorStreamingProgress = ( }, [cancelPolling, dispatch, hopIndex, poll, sellTxHash, confirmedTradeId]) const result = useMemo(() => { + const numSuccessfulSwaps = + (streamingSwapMeta?.attemptedSwapCount ?? 0) - (streamingSwapMeta?.failedSwaps?.length ?? 0) + const isComplete = - streamingSwapMeta !== undefined && - streamingSwapMeta.attemptedSwapCount === streamingSwapMeta.totalSwapCount + streamingSwapMeta !== undefined && numSuccessfulSwaps >= streamingSwapMeta.totalSwapCount return { isComplete,