Skip to content

Commit

Permalink
Merge pull request #481 from oraichain/feat/switch-chart
Browse files Browse the repository at this point in the history
update: check pair swap equal
  • Loading branch information
haunv3 authored Dec 6, 2023
2 parents a020582 + 375e8ea commit fe7430b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@oraichain/kawaiiverse-txs": "^0.0.3",
"@oraichain/oraidex-common-ui": "^1.0.3",
"@oraichain/oraidex-contracts-sdk": "^1.0.26",
"@oraichain/oraidex-universal-swap": "^1.0.34",
"@oraichain/oraidex-universal-swap": "^1.0.35",
"@reduxjs/toolkit": "^1.9.3",
"@sentry/react": "^7.47.0",
"@tanstack/react-query": "^4.32.6",
Expand Down
22 changes: 16 additions & 6 deletions src/pages/UniversalSwap/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,33 @@ export const generateNewSymbol = (
): PairToken | null => {
let newTVPair: PairToken = { ...currentPair };
// example: ORAI/ORAI
if (fromToken.name === toToken.name) {
newTVPair.symbol = `${fromToken.name}/${toToken.name}`;
newTVPair.info = '';
let findedPair;
const isFromTokenEqualToToken = fromToken.name === toToken.name;
const fromTokenIsOrai = fromToken.name === 'ORAI';
if (isFromTokenEqualToToken) {
const symbol = fromTokenIsOrai ? 'USDT' : 'ORAI';
findedPair = PAIRS_CHART.find((p) => p.symbol.includes(fromToken.name) && p.symbol.includes(symbol));
if (!findedPair)
return {
...newTVPair,
symbol: `${fromToken.name}/${toToken.name}`,
info: ''
};

newTVPair.symbol = findedPair.symbol;
newTVPair.info = findedPair.info;
return newTVPair;
}

let findedPair = PAIRS_CHART.find((p) => p.symbol.includes(fromToken.name) && p.symbol.includes(toToken.name));
findedPair = PAIRS_CHART.find((p) => p.symbol.includes(fromToken.name) && p.symbol.includes(toToken.name));
// this case when pair NOT in pool
// start find pair
if (!findedPair) {
findedPair = PAIRS_CHART.find((p) => p.symbols.includes(fromToken.name));
}

if (!findedPair) {
findedPair = PAIRS_CHART.find((p) => p.symbols.includes(toToken.name));
}
// end find pair

if (!findedPair) {
// this case when user click button reverse swap flow of pair NOT in pool.
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2917,9 +2917,9 @@
react-use "^17.4.0"

"@oraichain/oraidex-common@^1.0.44":
version "1.0.44"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-1.0.44.tgz#88990da6104af1b0013a5746340915265f9b7eea"
integrity sha512-/bgbf0KcMWANms/ZaEc8KESAy9/UACPzgeGcGGXGhnIMsrvHOMc3a6EQpY40B4xqp/8Cs+up4Gww4o9DLNRj6g==
version "1.0.45"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-1.0.45.tgz#15ba8962e25e99ad0b3f5376f0a2d9ed87ae06e4"
integrity sha512-aaNXqWndvajzBN8rQXgyyi371D3GbDpYbg4ivvo6t2DkPJb5EfI8xYit0wHTfbjWHgRFdjUaJ24NzmaKpfBPpg==
dependencies:
"@ethersproject/providers" "^5.0.10"
"@keplr-wallet/types" "^0.11.38"
Expand All @@ -2940,10 +2940,10 @@
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.26.tgz#83c4c80185396a9c62d7ced4437bef7b178e0c37"
integrity sha512-Uai30rSSn7h46lBLFuVbW96ErXAWRxfvEP+CNm/TXyGIw8VRtTaebQAqldsbxzYwBVEYbwDwZMHRGQWrsJBkJg==

"@oraichain/oraidex-universal-swap@^1.0.34":
version "1.0.34"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.0.34.tgz#535eb6a22238408c15ba5d5835e07a2219534070"
integrity sha512-j8Wz/hgle8Rgmve9OKO970l0HlXfVUoSgyI6HFgLAVoORPsTI7tH2rXxFRTZpLHb/7gQ7BN2R1U9u1ucJiTtXw==
"@oraichain/oraidex-universal-swap@^1.0.35":
version "1.0.35"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.0.35.tgz#4c4ae8cd1b1138b6f50887dbf3616f1dddf64c99"
integrity sha512-7zjkpCfQoQInoS5L4GcIADQWFrh348QfTN+Eckc75akuUllIClMwOBC5i1VuCHqYlXplRO7qjId0n9aUICYTwQ==
dependencies:
"@oraichain/oraidex-common" "^1.0.44"
"@oraichain/oraidex-contracts-sdk" "^1.0.24"
Expand Down

0 comments on commit fe7430b

Please sign in to comment.