Skip to content

Commit

Permalink
pump sdk to test
Browse files Browse the repository at this point in the history
  • Loading branch information
marxeille committed Aug 9, 2024
1 parent 36bf9c0 commit b2ad265
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"react-native-pager-view": "^6.2.3",
"@oraichain/oraidex-contracts-sdk": "^1.0.33",
"@oraichain/cw-simulate": "^2.8.76",
"@oraichain/oraidex-universal-swap": "^1.0.96-beta.11",
"@oraichain/oraidex-universal-swap": "1.0.96-beta.15",
"@oraichain/oraidex-contracts-build": "^1.0.22",
"@oraichain/common-contracts-build": "^1.0.35",
"ethereum-multicall": "^2.21.0",
Expand Down
39 changes: 26 additions & 13 deletions packages/mobile/src/screens/universal-swap/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ORAIX_CONTRACT,
TokenItemType,
BigDecimal,
TON_ORAICHAIN_DENOM,
} from "@oraichain/oraidex-common";
import { showToast } from "@src/utils/helper";
import { API } from "@src/common/api";
Expand Down Expand Up @@ -59,22 +60,34 @@ export const handleErrorSwap = (message: string) => {
});
};

// smart router osmosis
export const isAllowAlphaSmartRouter = (fromToken, toToken) => {
const notAllowChainId = ["Neutaro-1"];
if (
notAllowChainId.includes(fromToken.chainId) ||
notAllowChainId.includes(toToken.chainId)
)
return false;
if (isAllowIBCWasm(fromToken, toToken)) return true;
// Case FromToken is Cosmos -> ToToken is Cosmos
export const isAllowAlphaSmartRouter = (fromToken, toToken, isAIRoute) => {
const isOraichain = fromToken.chainId === "Oraichain";
// const notAllowChainId = ['Neutaro-1'];
const allowTokenTon = [
fromToken.contractAddress,
fromToken.denom,
toToken.contractAddress,
toToken.denom,
]
.filter(Boolean)
.includes(TON_ORAICHAIN_DENOM);

if (allowTokenTon) return true;
// if (notAllowChainId.includes(fromToken.chainId) || notAllowChainId.includes(toToken.chainId)) return false;
if (isOraichain && !toToken.cosmosBased) return false;
if (isOraichain) return isAIRoute;

if (fromToken.cosmosBased && toToken.cosmosBased) return true;
if (fromToken.cosmosBased && !toToken.cosmosBased) return true;
if (!fromToken.cosmosBased) return true;
return false;
};
export const isAllowIBCWasm = (fromToken, toToken) => {
// Case FromToken is Evm -> ToToken is Cosmos
if (!fromToken.cosmosBased && toToken.cosmosBased) return true;

export const isAllowIBCWasm = (fromToken, toToken, isAIRoute) => {
if (fromToken.cosmosBased && toToken.cosmosBased) return !isAIRoute;
if (fromToken.cosmosBased && !toToken.cosmosBased) return true;

if (!fromToken.cosmosBased) return true;
return false;
};
export const getTransactionUrl = (
Expand Down
28 changes: 11 additions & 17 deletions packages/mobile/src/screens/universal-swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,17 @@ export const UniversalSwapScreen: FunctionComponent = observer(() => {
fromTokenDenom,
toTokenDenom
);
const useIbcWasm = isAllowIBCWasm(originalFromToken, originalToToken);

let useAlphaSmartRouter =
useIbcWasm ||
(isAllowAlphaSmartRouter(originalFromToken, originalToToken) && isAIRoute);
if (
[
originalFromToken.contractAddress,
originalFromToken.denom,
originalToToken.contractAddress,
originalToToken.denom,
]
.filter(Boolean)
.includes(TON_ORAICHAIN_DENOM)
) {
useAlphaSmartRouter = true;
}
const useIbcWasm = isAllowIBCWasm(
originalFromToken,
originalToToken,
isAIRoute
);
const useAlphaSmartRouter = isAllowAlphaSmartRouter(
originalFromToken,
originalToToken,
isAIRoute
);

const {
minimumReceive,
isWarningSlippage,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4553,10 +4553,10 @@
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.45.tgz#42dae0fdd9e005f920ba305b987009f791acc365"
integrity sha512-/nYztdxEX5LQM4DMJQmi9HvZrBVoY3nLAmYqSKZGZ0U1h1SxU7O/o22R3/pQwB+sAJdcibaI8ygC0ov7jC8paA==

"@oraichain/oraidex-universal-swap@^1.0.96-beta.11":
version "1.0.96-beta.11"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.0.96-beta.11.tgz#789ad5da6386ea22cbceb1fcafb167a6500e4b1f"
integrity sha512-tz2PEFhdtU4kDMq5rFlJskt0ZunWS5ZuYogQUD2/EXmGccyjcC0Qdj/cI2LPDB8QgjmngNWSBDKMYFmfWYP7eg==
"@oraichain/oraidex-universal-swap@1.0.96-beta.15":
version "1.0.96-beta.15"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-universal-swap/-/oraidex-universal-swap-1.0.96-beta.15.tgz#207e5643030792620d8ba3fbcb12f040750efbd1"
integrity sha512-vOqvXjbg6mXrHdaeUw/pi70yGlnLvpvipUJ/UwISFvHelOnG4VgjZce3/5MvT0U+vjh049Ypwx9PaRBcyNPXNQ==
dependencies:
"@oraichain/common" "^1.0.3"
"@oraichain/oraidex-common" "^1.0.91"
Expand Down

0 comments on commit b2ad265

Please sign in to comment.