Skip to content

Commit

Permalink
Merge pull request #29 from oraichain/update/swap
Browse files Browse the repository at this point in the history
pumb universal swap 1.1.19
  • Loading branch information
haunv3 authored Nov 8, 2024
2 parents a76b4c0 + 2764c47 commit 34ac961
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 50 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@oraichain/oraidex-common": "^1.1.28",
"@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",
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/pages/UniversalSwap/Swap/hooks/useFilteredTokens.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand All @@ -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 };
Expand Down
40 changes: 1 addition & 39 deletions src/pages/UniversalSwap/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3039,7 +3039,7 @@
react-use "^17.4.0"
react-use-websocket "^4.5.0"

"@oraichain/oraidex-common@^1.1.21", "@oraichain/oraidex-common@^1.1.28":
"@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==
Expand Down Expand Up @@ -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/[email protected].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/[email protected].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"
Expand Down

0 comments on commit 34ac961

Please sign in to comment.