Skip to content

Commit

Permalink
Migrate to new cross-chain version (#2539)
Browse files Browse the repository at this point in the history
* Migrate to new cross-chain version

* Change params

* Remove getRoutes with prefer kyberswap-aggregator

* Remove comment code
  • Loading branch information
tienkane authored Sep 24, 2024
1 parent 7b1dfff commit 8e86439
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 65 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"ChromeAndroid >= 52"
],
"dependencies": {
"@0xsquid/sdk": "^2.8.1",
"@0xsquid/sdk": "^2.8.24",
"@apollo/client": "^3.7.1",
"@blocto/wagmi-connector": "^2.0.4",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
Expand Down
11 changes: 5 additions & 6 deletions src/components/Header/groups/SwapNavGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import styled from 'styled-components'
import { ReactComponent as MasterCard } from 'assets/buy-crypto/master-card.svg'
import { ReactComponent as Visa } from 'assets/buy-crypto/visa.svg'
// import MultichainLogoLight from 'assets/images/multichain_white.png'
// import SquidLogoLight from 'assets/images/squid_light.png'
import SquidLogoLight from 'assets/images/squid_light.png'
// import { ReactComponent as BridgeIcon } from 'assets/svg/bridge_icon.svg'
import { ReactComponent as BuyCrypto } from 'assets/svg/buy_crypto.svg'
// import { ReactComponent as CrossChainIcon } from 'assets/svg/cross_chain_icon.svg'
import { ReactComponent as CrossChainIcon } from 'assets/svg/cross_chain_icon.svg'
import { ReactComponent as LimitOrderIcon } from 'assets/svg/limit_order.svg'
import { TutorialIds } from 'components/Tutorial/TutorialSwap/constant'
// import { APP_PATHS, CHAINS_SUPPORT_CROSS_CHAIN } from 'constants/index'
import { APP_PATHS } from 'constants/index'
import { APP_PATHS, CHAINS_SUPPORT_CROSS_CHAIN } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
import { useTutorialSwapGuide } from 'state/tutorial/hooks'
Expand Down Expand Up @@ -103,7 +102,7 @@ const SwapNavGroup = () => {
</StyledNavLink>
)}

{/* {CHAINS_SUPPORT_CROSS_CHAIN.includes(chainId) && (
{CHAINS_SUPPORT_CROSS_CHAIN.includes(chainId) && (
<StyledNavLink
id="cross-chain-nav-link"
to={APP_PATHS.CROSS_CHAIN}
Expand All @@ -119,7 +118,7 @@ const SwapNavGroup = () => {
</Flex>
</Flex>
</StyledNavLink>
)} */}
)}

{/*
!(chainId === ChainId.LINEA_TESTNET) && (
Expand Down
2 changes: 1 addition & 1 deletion src/constants/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const MOCK_ACCOUNT_EVM = isAddressString(mock[0]?.trim())
const isSupportTestNet = ENV_LEVEL < ENV_TYPE.PROD && new URLSearchParams(window.location.search).get('test')
export const CROSS_CHAIN_CONFIG = {
AXELAR_SCAN_URL: isSupportTestNet ? 'https://testnet.axelarscan.io/gmp/' : 'https://axelarscan.io/gmp/',
API_DOMAIN: isSupportTestNet ? 'https://testnet.api.0xsquid.com' : 'https://v2.api.squidrouter.com',
API_DOMAIN: isSupportTestNet ? 'https://testnet.api.0xsquid.com' : 'https://apiplus.squidrouter.com',
INTEGRATOR_ID: 'kyberswap-api',
GAS_REFUND: 25, // %
}
7 changes: 3 additions & 4 deletions src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import ModalsGlobal from 'components/ModalsGlobal'
import ProtectedRoute from 'components/ProtectedRoute'
import Snowfall from 'components/Snowflake/Snowfall'
import SupportButton from 'components/SupportButton'
// import { APP_PATHS, CHAINS_SUPPORT_CROSS_CHAIN } from 'constants/index'
import { APP_PATHS } from 'constants/index'
import { APP_PATHS, CHAINS_SUPPORT_CROSS_CHAIN } from 'constants/index'
import { CLASSIC_NOT_SUPPORTED, ELASTIC_NOT_SUPPORTED, NETWORKS_INFO, SUPPORTED_NETWORKS } from 'constants/networks'
import { useActiveWeb3React } from 'hooks'
import { useAutoLogin } from 'hooks/useLogin'
Expand Down Expand Up @@ -239,9 +238,9 @@ export default function App() {
{/* From [email protected], :fromCurrency-to-:toCurrency no long works, need to manually parse the params */}
<Route path={`${APP_PATHS.SWAP}/:network/:currency?`} element={<SwapPage />} />
<Route path={`${APP_PATHS.PARTNER_SWAP}`} element={<PartnerSwap />} />
{/* {CHAINS_SUPPORT_CROSS_CHAIN.includes(chainId) && (
{CHAINS_SUPPORT_CROSS_CHAIN.includes(chainId) && (
<Route path={`${APP_PATHS.CROSS_CHAIN}`} element={<SwapV3 />} />
)} */}
)}

{isSupportLimitOrder(chainId) && (
<Route path={`${APP_PATHS.LIMIT}/:network/:currency?`} element={<SwapPage />} />
Expand Down
1 change: 1 addition & 0 deletions src/pages/CrossChain/SwapForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default function SwapForm() {
slippage: slippageTolerance / 100,
autoMode: 1,
},
// slippage: slippageTolerance / 100,
enableBoost: enableExpressExecution,
quoteOnly: !account,
}
Expand Down
16 changes: 5 additions & 11 deletions src/pages/CrossChain/useGetRoute.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DexName, RouteRequest, RouteResponse } from '@0xsquid/sdk/dist/types'
import { RouteRequest, RouteResponse } from '@0xsquid/sdk/dist/types'
import debounce from 'lodash/debounce'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'

Expand Down Expand Up @@ -44,23 +44,17 @@ export default function useGetRouteCrossChain(params: RouteRequest | undefined)
setTradeRoute(undefined)
return
}
let signal: AbortSignal | undefined
let route: RouteResponse | undefined

try {
controller.current?.abort?.()
controller.current = new AbortController()
signal = controller.current.signal
const signal: AbortSignal | undefined = controller.current.signal
setLoading(true)
setError(false)
isRefresh && setTradeRoute(undefined)
route = await squidInstance.getRoute({ ...debounceParams, prefer: [DexName.KYBERSWAP_AGGREGATOR] })

if (signal?.aborted) return
} catch (error) {}
try {
if (!route) {
route = await squidInstance.getRoute(debounceParams)
}
const route: RouteResponse | undefined = await squidInstance.getRoute(debounceParams)

if (signal?.aborted) return
setTradeRoute(route)
setError(false)
Expand Down
93 changes: 51 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
# yarn lockfile v1


"@0xsquid/sdk@^2.8.1":
version "2.8.5"
resolved "https://registry.yarnpkg.com/@0xsquid/sdk/-/sdk-2.8.5.tgz#5cd3f5da54e8352aee1264fa69f98ba27c3d02d3"
integrity sha512-DAcoDxbXQ2FPtbP7ogvDntIecT0Xwyb3RyGw4iXncpBnpwnDahBoO5T9kriqIGIJpHS3oxfmnidRcJjkmRTp7Q==
"@0xsquid/sdk@^2.8.24":
version "2.8.24"
resolved "https://registry.yarnpkg.com/@0xsquid/sdk/-/sdk-2.8.24.tgz#77f5ee9f8e3b951b6962583283c8a08c4d7880b1"
integrity sha512-lwOWmZPE/jt3XwbvHQ+qLufdIxuE12I7+xdo9ZrKqUxUKzss1bsS5xC9qRlIPwERYfneyOtUhBKfYqhhnmUYQA==
dependencies:
"@cosmjs/encoding" "^0.31.0"
"@cosmjs/stargate" "^0.31.0"
"@cosmjs/stargate" "^0.31.3"
"@ethersproject/abstract-signer" "^5.7.0"
"@ethersproject/wallet" "^5.7.0"
axios "^1.5.0"
cosmjs-types "^0.8.0"
ethers "6.7.1"
ethers "6.8.1"
ethers-multicall-provider "^5.0.0"
lodash "^4.17.21"
long "^5.2.3"

"@0xsquid/squid-types@^0.1.34":
version "0.1.34"
Expand All @@ -31,11 +33,6 @@
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7"
integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==

"@adraffy/[email protected]":
version "1.9.2"
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz#60111a5d9db45b2e5cbb6231b0bb8d97e8659316"
integrity sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==

"@adraffy/[email protected]":
version "1.9.4"
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.9.4.tgz#aae21cb858bbb0411949d5b7b3051f4209043f62"
Expand Down Expand Up @@ -1891,7 +1888,7 @@
ws "^7"
xstream "^11.14.0"

"@cosmjs/stargate@^0.31.0":
"@cosmjs/stargate@^0.31.3":
version "0.31.3"
resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.31.3.tgz#a2b38e398097a00f897dbd8f02d4d347d8fed818"
integrity sha512-53NxnzmB9FfXpG4KjOUAYAvWLYKdEmZKsutcat/u2BrDXNZ7BN8jim/ENcpwXfs9/Og0K24lEIdvA4gsq3JDQw==
Expand Down Expand Up @@ -2884,7 +2881,7 @@
"@ethersproject/constants" "^5.7.0"
"@ethersproject/logger" "^5.7.0"

"@ethersproject/[email protected]":
"@ethersproject/[email protected]", "@ethersproject/wallet@^5.7.0":
version "5.7.0"
resolved "https://registry.yarnpkg.com/@ethersproject/wallet/-/wallet-5.7.0.tgz#4e5d0790d96fe21d61d38fb40324e6c7ef350b2d"
integrity sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==
Expand Down Expand Up @@ -4202,11 +4199,6 @@
resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.1.tgz#6899660f6fbb97798a6fbd227227c4589a454724"
integrity sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==

"@noble/[email protected]":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183"
integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==

"@noble/[email protected]", "@noble/hashes@^1", "@noble/hashes@^1.0.0", "@noble/hashes@~1.3.2":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39"
Expand All @@ -4227,7 +4219,7 @@
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9"
integrity sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==

"@noble/secp256k1@1.7.1", "@noble/secp256k1@^1.6.3":
"@noble/secp256k1@^1.6.3":
version "1.7.1"
resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c"
integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==
Expand Down Expand Up @@ -11491,14 +11483,14 @@ ethers-multicall-provider@^5.0.0:
ethers "^6.0.0"
lodash "^4.17.0"

ethers@6.7.1:
version "6.7.1"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.7.1.tgz#9c65e8b5d8e9ad77b7e8cf1c46099892cfafad49"
integrity sha512-qX5kxIFMfg1i+epfgb0xF4WM7IqapIIu50pOJ17aebkxxa4BacW5jFrQRmCJpDEg2ZK2oNtR5QjrQ1WDBF29dA==
ethers@6.8.1, ethers@^6.0.0:
version "6.8.1"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.8.1.tgz#ee2a1a39b5f62a13678f90ccd879175391d0a2b4"
integrity sha512-iEKm6zox5h1lDn6scuRWdIdFJUCGg3+/aQWu0F4K0GVyEZiktFkqrJbRjTn1FlYEPz7RKA707D6g5Kdk6j7Ljg==
dependencies:
"@adraffy/ens-normalize" "1.9.2"
"@noble/hashes" "1.1.2"
"@noble/secp256k1" "1.7.1"
"@adraffy/ens-normalize" "1.10.0"
"@noble/curves" "1.2.0"
"@noble/hashes" "1.3.2"
"@types/node" "18.15.13"
aes-js "4.0.0-beta.5"
tslib "2.4.0"
Expand Down Expand Up @@ -11540,19 +11532,6 @@ ethers@^5.4.6, ethers@^5.6.9, ethers@^5.7.2:
"@ethersproject/web" "5.7.1"
"@ethersproject/wordlists" "5.7.0"

ethers@^6.0.0:
version "6.8.1"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.8.1.tgz#ee2a1a39b5f62a13678f90ccd879175391d0a2b4"
integrity sha512-iEKm6zox5h1lDn6scuRWdIdFJUCGg3+/aQWu0F4K0GVyEZiktFkqrJbRjTn1FlYEPz7RKA707D6g5Kdk6j7Ljg==
dependencies:
"@adraffy/ens-normalize" "1.10.0"
"@noble/curves" "1.2.0"
"@noble/hashes" "1.3.2"
"@types/node" "18.15.13"
aes-js "4.0.0-beta.5"
tslib "2.4.0"
ws "8.5.0"

ethers@^6.7.1:
version "6.9.0"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.9.0.tgz#a4534bdcdfde306aee94ef32f3d5c70d7e33fcb9"
Expand Down Expand Up @@ -14417,6 +14396,11 @@ long@^5.0.0:
resolved "https://registry.yarnpkg.com/long/-/long-5.2.1.tgz#e27595d0083d103d2fa2c20c7699f8e0c92b897f"
integrity sha512-GKSNGeNAtw8IryjjkhZxuKB3JzlcLTwjtiQCHKvqQet81I93kXslhDQruGI/QsddO83mcDToBVy7GqGS/zYf/A==

long@^5.2.3:
version "5.2.3"
resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1"
integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==

longest-streak@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-3.1.0.tgz#62fa67cd958742a1574af9f39866364102d90cd4"
Expand Down Expand Up @@ -18232,7 +18216,16 @@ strict-uri-encode@^2.0.0:
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -18305,7 +18298,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -18319,6 +18312,13 @@ strip-ansi@^3.0.1:
dependencies:
ansi-regex "^2.0.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -19921,7 +19921,7 @@ [email protected]:
dependencies:
workbox-core "6.5.4"

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -19939,6 +19939,15 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 8e86439

Please sign in to comment.