diff --git a/packages/universal-swap/src/handler.ts b/packages/universal-swap/src/handler.ts index 7cb2929b..0ab2b5c7 100644 --- a/packages/universal-swap/src/handler.ts +++ b/packages/universal-swap/src/handler.ts @@ -1252,7 +1252,18 @@ export class UniversalSwapHandler { ); if (alphaSmartRoutes?.routes?.length && swapOptions.isAlphaIbcWasm) { - let receiverAddresses = UniversalSwapHelper.generateAddress({ oraiAddress, injAddress }); + const addressParams = { + oraiAddress, + injAddress, + evmInfo: + !originalToToken.cosmosBased && evmAddress + ? { + [originalToToken.chainId]: evmAddress + } + : {} + }; + + let receiverAddresses = UniversalSwapHelper.generateAddress(addressParams); if (recipientAddress) receiverAddresses[currentToNetwork] = toAddress; return this.alphaSmartRouterSwapNewMsg(swapRoute, universalSwapType, receiverAddresses); diff --git a/packages/universal-swap/src/helper.ts b/packages/universal-swap/src/helper.ts index 5a236673..a98b92a7 100644 --- a/packages/universal-swap/src/helper.ts +++ b/packages/universal-swap/src/helper.ts @@ -419,23 +419,34 @@ export class UniversalSwapHelper { } /** - * useAlphaIbcWasm case: (evm -> oraichain -> osmosis -> inj/tia not using wasm) + * useAlphaIbcWasm case: + * evm -> oraichain -> osmosis -> inj/tia + * tia/inj -> osmosis -> oraichain -> evm */ - if (swapOption.isAlphaIbcWasm && !fromToken.cosmosBased) { + if (swapOption.isAlphaIbcWasm) { if (!alphaSmartRoute) throw generateError(`Missing router with alpha ibc wasm!`); const routes = alphaSmartRoute.routes; const alphaRoutes = routes[0]; + let paths = alphaRoutes.paths; - if (alphaSmartRoute.routes.length > 1) throw generateError(`Missing router with alpha ibc wasm max length!`); + // if from is EVM only support one routes + if (!fromToken.cosmosBased && alphaSmartRoute.routes.length > 1) { + throw generateError(`Missing router with alpha ibc wasm max length!`); + } - const paths = alphaRoutes.paths.filter((_, index) => index > 0); + if (!fromToken.cosmosBased) { + paths = alphaRoutes.paths.filter((_, index) => index > 0); + } let receiverAddresses = UniversalSwapHelper.generateAddress({ injAddress: addresses.injAddress, oraiAddress: addresses.sourceReceiver, - evmInfo: { - [toToken.chainId]: addresses.evmAddress - } + evmInfo: + !toToken.cosmosBased && addresses.evmAddress + ? { + [toToken.chainId]: addresses.evmAddress + } + : {} }); if (addresses?.recipientAddress) receiverAddresses[toToken.chainId] = addresses?.recipientAddress;