From 4a3093e62206eca91b0bac06b35f705e3d653b0c Mon Sep 17 00:00:00 2001 From: abstract829 Date: Wed, 19 Jun 2024 11:01:02 -0400 Subject: [PATCH] update router-sdk and add phoenix --- package.json | 2 +- src/functions/generateRoute.ts | 19 ++++++++++++------- src/services/pairs.ts | 14 ++++++++++++++ yarn.lock | 29 ++++++++++++++++++++++++----- 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 8bb7332b..cc183687 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "react-virtualized-auto-sizer": "^1.0.20", "react-window": "^1.8.9", "redux": "^4.2.1", - "soroswap-router-sdk": "1.2.6", + "soroswap-router-sdk": "^1.2.8", "swr": "^2.2.0", "typescript": "5.3.3", "use-resize-observer": "^9.1.0" diff --git a/src/functions/generateRoute.ts b/src/functions/generateRoute.ts index bc8eecf5..216869a5 100644 --- a/src/functions/generateRoute.ts +++ b/src/functions/generateRoute.ts @@ -3,7 +3,7 @@ import { useFactory } from 'hooks'; import { useContext, useMemo } from 'react'; import { CurrencyAmount, Networks, Protocols, Router, Token, TradeType } from 'soroswap-router-sdk'; import { AppContext } from 'contexts'; -import { fetchAllSoroswapPairs } from 'services/pairs'; +import { fetchAllPhoenixPairs, fetchAllSoroswapPairs } from 'services/pairs'; export interface GenerateRouteProps { amountTokenAddress: string; @@ -28,13 +28,18 @@ export const useRouterSDK = () => { const router = useMemo(() => { return new Router({ - getPairsFn: async () => { - const data = await fetchAllSoroswapPairs(network); - - return data; - }, + getPairsFns: [ + { + protocol: Protocols.SOROSWAP, + fn: async () => fetchAllSoroswapPairs(network), + }, + { + protocol: Protocols.PHOENIX, + fn: async () => fetchAllPhoenixPairs(network), + }, + ], pairsCacheInSeconds: 60, - protocols: [Protocols.SOROSWAP], + protocols: [Protocols.SOROSWAP, Protocols.PHOENIX], network, maxHops, }); diff --git a/src/services/pairs.ts b/src/services/pairs.ts index c24f58f2..fa280f34 100644 --- a/src/services/pairs.ts +++ b/src/services/pairs.ts @@ -24,3 +24,17 @@ export const fetchAllSoroswapPairs = async (networkPassphrase: string) => { }); return data; }; + +export const fetchAllPhoenixPairs = async (networkPassphrase: string) => { + const networkName = passphraseToBackendNetworkName[networkPassphrase]; + + const { data } = await axios.get( + `https://info.soroswap.finance/api/pairs/phoenix`, + { + params: { + network: networkName, + }, + }, + ); + return data; +}; diff --git a/yarn.lock b/yarn.lock index 32261ab6..6a7bb85e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5135,6 +5135,17 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" +glob@10.3.10: + version "10.3.10" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.10.tgz#0351ebb809fd187fe421ab96af83d3a70715df4b" + integrity sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g== + dependencies: + foreground-child "^3.1.0" + jackspeak "^2.3.5" + minimatch "^9.0.1" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + path-scurry "^1.10.1" + glob@^10.2.2, glob@^10.3.10, glob@^10.3.12: version "10.3.14" resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.14.tgz#36501f871d373fe197fc5794588d0aa71e69ff68" @@ -5764,7 +5775,7 @@ iterator.prototype@^1.1.2: reflect.getprototypeof "^1.0.4" set-function-name "^2.0.1" -jackspeak@^2.3.6: +jackspeak@^2.3.5, jackspeak@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-2.3.6.tgz#647ecc472238aee4b06ac0e461acc21a8c505ca8" integrity sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ== @@ -7251,6 +7262,14 @@ path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-scurry@^1.10.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" + integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + path-scurry@^1.11.0: version "1.11.0" resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.0.tgz#332d64e9726bf667fb348e5a1c71005c09ad741a" @@ -8296,10 +8315,10 @@ soroban-client@1.0.0-beta.4: stellar-base v10.0.0-beta.4 urijs "^1.19.1" -soroswap-router-sdk@1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/soroswap-router-sdk/-/soroswap-router-sdk-1.2.6.tgz#40633e8a9d028263a80a504b325b6ec068dea5b4" - integrity sha512-i2IkVoFWlf+gxsoR1egiXWEagKC8UJj0Wj+3Z/tBZvRgvbdyoMVTv2LefB4xWrRoCC4nPiLQxcej4qPLqcrNAQ== +soroswap-router-sdk@^1.2.8: + version "1.2.8" + resolved "https://registry.yarnpkg.com/soroswap-router-sdk/-/soroswap-router-sdk-1.2.8.tgz#17d5a6e69b39ce61aa6ca312f4f0f6dd28d8ec73" + integrity sha512-m8kHw5EGStNlYyE4eTBP5o5475yCNTAE+zyGUWW3uScQsLWinm7yRxq6U2biWMocMmj5Eo2rDQUmhJyrUpDanw== dependencies: "@stellar/stellar-sdk" "^11.3.0" axios "^1.6.5"