From 202cb2d11b6b9fc4123c745667b8f0969535eb9b Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Fri, 8 Nov 2024 16:23:04 +0700 Subject: [PATCH] pumb universal swap 1.1.19 --- package.json | 5 ++- .../Swap/hooks/useFilteredTokens.ts | 6 +-- src/pages/UniversalSwap/helpers.ts | 40 +------------------ yarn.lock | 18 ++++----- 4 files changed, 16 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index 401aafec0..4a8da1a77 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "@oraichain/oraidex-common": "^1.1.23", "@oraichain/oraidex-common-ui": "1.0.11", "@oraichain/oraidex-contracts-sdk": "^1.0.26", - "@oraichain/oraidex-universal-swap": "1.1.15", + "@oraichain/oraidex-universal-swap": "1.1.19", "@reduxjs/toolkit": "^1.9.3", "@sentry/react": "^7.47.0", "@tanstack/react-query": "^4.32.6", @@ -122,7 +122,8 @@ "resolutions": { "bech32": "1.1.4", "bitcoinjs-lib": "5.2.0", - "axios": "0.26.1" + "axios": "0.26.1", + "@oraichain/oraidex-common": "1.1.28" }, "engines": { "node": "^18 || ^20" diff --git a/src/pages/UniversalSwap/Swap/hooks/useFilteredTokens.ts b/src/pages/UniversalSwap/Swap/hooks/useFilteredTokens.ts index 514f53589..829070dab 100644 --- a/src/pages/UniversalSwap/Swap/hooks/useFilteredTokens.ts +++ b/src/pages/UniversalSwap/Swap/hooks/useFilteredTokens.ts @@ -1,6 +1,6 @@ import { SwapDirection, UniversalSwapHelper } from '@oraichain/oraidex-universal-swap'; import { useEffect, useState } from 'react'; -import { TokenItemType } from '@oraichain/oraidex-common'; +import { BTC_CONTRACT, TokenItemType } from '@oraichain/oraidex-common'; const useFilteredTokens = ( originalFromToken: TokenItemType, @@ -20,7 +20,7 @@ const useFilteredTokens = ( searchTokenName, SwapDirection.To ); - setFilteredToTokens(filteredToTokens); + setFilteredToTokens(filteredToTokens.filter((fi) => fi?.contractAddress !== BTC_CONTRACT)); const filteredFromTokens = UniversalSwapHelper.filterNonPoolEvmTokens( originalToToken.chainId, @@ -29,7 +29,7 @@ const useFilteredTokens = ( searchTokenName, SwapDirection.From ); - setFilteredFromTokens(filteredFromTokens); + setFilteredFromTokens(filteredFromTokens.filter((fi) => fi?.contractAddress !== BTC_CONTRACT)); }, [originalFromToken, originalToToken, searchTokenName, toTokenDenomSwap, fromTokenDenomSwap]); return { filteredToTokens, filteredFromTokens }; diff --git a/src/pages/UniversalSwap/helpers.ts b/src/pages/UniversalSwap/helpers.ts index d5b9a3405..ec51d1001 100644 --- a/src/pages/UniversalSwap/helpers.ts +++ b/src/pages/UniversalSwap/helpers.ts @@ -413,49 +413,11 @@ const listAllowSmartRoute = { * @returns boolean */ export const isAllowIBCWasm = (fromToken: TokenItemType, toToken: TokenItemType) => { - const fromTokenIsOraichain = fromToken?.chainId === 'Oraichain'; - const fromTokenIsCosmos = fromToken?.cosmosBased; - - const toTokenIsOraichain = toToken?.chainId === 'Oraichain'; - const toTokenIsCosmos = toToken?.cosmosBased; - - // ----------------------------------- new msg - // from chainId and to chainId is CELESTIA_CHAIN_ID or INJECTVE_CHAIN_ID - if ([toToken?.chainId, fromToken?.chainId].includes(COSMOS_CHAIN_ID_COMMON.CELESTIA_CHAIN_ID)) return false; - if ([toToken?.chainId, fromToken?.chainId].includes(COSMOS_CHAIN_ID_COMMON.INJECTVE_CHAIN_ID)) return false; - // cosmos -> cosmos - if (fromTokenIsCosmos && toTokenIsCosmos) return false; - // ----------------------------------- - - // Oraichain -> Oraichain or Cosmos - if (fromTokenIsOraichain) { - if (toToken?.chainId == 'Neutaro-1') return true; - if (toTokenIsOraichain || toTokenIsCosmos) return false; - } - // Oraichain or Cosmos -> Evm - if ((fromTokenIsOraichain || fromTokenIsCosmos) && !toTokenIsCosmos) return true; - // Evm -> EVM - if (!fromTokenIsCosmos && !toTokenIsCosmos && toToken?.chainId === fromToken?.chainId) return false; - // Evm -> Oraichain or Cosmos - if (!fromTokenIsCosmos) return true; - - // Cosmos -> Cosmos or Oraichain - if (fromTokenIsCosmos && toTokenIsCosmos) { - const key = [fromToken, toToken].map((e) => e.chainId).join('-'); - const hasTokenUsingSmartRoute = - listAllowSmartRoute[key]?.fromCoinGeckoIds.includes(fromToken?.coinGeckoId) && - listAllowSmartRoute[key]?.toCoinGeckoIds.includes(toToken?.coinGeckoId); - if (hasTokenUsingSmartRoute) return false; - return true; - } - return false; }; export const isAllowAlphaIbcWasm = (fromToken: TokenItemType, toToken: TokenItemType) => { - if ([toToken.chainId, fromToken.chainId].includes(COSMOS_CHAIN_ID_COMMON.INJECTVE_CHAIN_ID)) return true; - if ([toToken.chainId, fromToken.chainId].includes(COSMOS_CHAIN_ID_COMMON.CELESTIA_CHAIN_ID)) return true; - return false; + return true; }; export const getAverageRatio = ( diff --git a/yarn.lock b/yarn.lock index f09c73ad4..62c4f21eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3039,10 +3039,10 @@ react-use "^17.4.0" react-use-websocket "^4.5.0" -"@oraichain/oraidex-common@^1.1.21", "@oraichain/oraidex-common@^1.1.23": - version "1.1.23" - resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-1.1.23.tgz#7f9b57182972dc4f2f3a9a1fe103c0b12b24fec8" - integrity sha512-f7JYAWZH0Hb0UAH1df5oORWZXeiEIX3gN1a5e+udUDuTqexzC2kVJ5TZyj4KDgJo6JyEjVr10zrzWm+tcFR4fg== +"@oraichain/oraidex-common@1.1.28", "@oraichain/oraidex-common@^1.1.23", "@oraichain/oraidex-common@^1.1.27": + version "1.1.28" + resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-1.1.28.tgz#9bf25c825e3ee7a76bf8c00174579ca2b81d6fdb" + integrity sha512-+1CiI9E03MWtNQ3D7dDWtwbONikpdY1+USmvU6gOKd26uhDqDHKgi7MGnmz2t+Z8/4oqY36aySZhh3d9ybakxg== dependencies: "@cosmjs/amino" "0.31.3" "@cosmjs/cosmwasm-stargate" "0.31.3" @@ -3081,13 +3081,13 @@ resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.44.tgz#9ff41ec388dd92ba112c2eef545d11fd6e18c684" integrity sha512-fMY/QOzO/afPlAVkLGH1bcpJTs6V/URrJju2r4UoE9f5HUWC/6OC6+H5dWuIgq26frp8wjH23mNCQAlmHzji8g== -"@oraichain/oraidex-universal-swap@1.1.15": - version "1.1.15" - resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.1.15.tgz#e1c987b896ec0cd56de1ba94cbddcf96f9b5c184" - integrity sha512-iK0nKrGC81MEBVKz4sTkFndjAPEvHXhHObZHtcJtYp7GIvmonHTFWIJWyw1rufAJYonfp5m/XFdm+Ai3ebxkjw== +"@oraichain/oraidex-universal-swap@1.1.19": + version "1.1.19" + resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.1.19.tgz#c960407c98501aeedd17dc058b3e4a428c81d4da" + integrity sha512-fv34AiSxGIPzI8zEIaWaI82FtP2CENdCqV4wYC5ucAXCGEuUArmxs6rD0M/Z1vVw0+GmZ8/J9YDZS485ZNE4Pw== dependencies: "@oraichain/common" "^1.0.3" - "@oraichain/oraidex-common" "^1.1.21" + "@oraichain/oraidex-common" "^1.1.27" "@oraichain/oraidex-contracts-sdk" "^1.0.49" "@oraichain/osor-api-contracts-sdk" "^1.0.2" bech32 "1.1.4"