Skip to content

Commit

Permalink
update: check pair swap equal
Browse files Browse the repository at this point in the history
  • Loading branch information
haunv3 committed Dec 6, 2023
1 parent a020582 commit 38e9034
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/pages/UniversalSwap/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,26 @@ 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));
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

0 comments on commit 38e9034

Please sign in to comment.